3 Replies Latest reply: Oct 29, 2014 11:27 AM by Christopher White RSS

Are there example scripts?

Frederico Billings

I'm using profiler to pull reports, but I'd like to go beyond the 10k row limit with the UI.  Is there a way to take an existing report within the UI and get the syntax for how I'd run it with python?  I've installed SteelScript, but am a python beginner, and can't seem to figure out how to extra metrics for host pairs with ports.  I've read through and downloaded/ran scripts from the "getting started with python" area, but they don't export to csv which is what I'm looking to do.

  • Re: Are there example scripts?
    Rossel Vermette

    You can look at the UI and maybe poll the traffic expression that was used to get the data, but you will have to build your report to get the data you are looking for.  I'm also a beginner with python, but between the help from the folks here and the example scripts, i've been able to poll what I've needed.  Below is an example of a report that I use that will create the output in a CSV format.  Hope this gets you started.


    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # <nbformat>3.0</nbformat>
    # <codecell>
    import steelscript
    from steelscript.netprofiler.core import NetProfiler
    from steelscript.common.service import UserAuth
    from steelscript.netprofiler.core.filters import TimeFilter, TrafficFilter
    from steelscript.netprofiler.core.report import TrafficSummaryReport
    from steelscript.netprofiler.core.app import NetProfilerApp
    from steelscript.common.utils import Formatter
    from steelscript.common.timeutils import TimeParser
    import pprint
    import argparse
    # Connection Information
    username = ''
    password = ''
    auth = UserAuth(username, password)
    host = ''
    parser = argparse.ArgumentParser(description='Parameter options')
    parser.add_argument('-sd','--sdate',help='Start Date',required=True)
    parser.add_argument('-ed','--edate',help='End Date',required=True)
    parser.add_argument('-st','--stime',help='Start Time',required=True)
    parser.add_argument('-et','--etime',help='End Time',required=True)
    parser.add_argument('-tex','--texpr',help='Traffic Expresion',required=True)
    parser.add_argument('-g','--gby',help='Group by client host group type',required=True)
    parser.add_argument('-ap','--app',help='Customn Lable for application name',required=True)
    rargs = parser.parse_args()
    t0 = TimeParser.parse_one('{s1} {s2}'.format(s1=rargs.sdate, s2=rargs.stime) )
    t1 = TimeParser.parse_one('{e1} {e2}'.format(e1=rargs.edate, e2=rargs.etime) )
    p = NetProfiler(host, auth=auth)
    report = TrafficSummaryReport(p)
    grpby = p.groupbys.host_group
    columns = [p.columns.key.group_name,
               p.columns.value.peak_rsec_server_delay ]
    sort_col = p.columns.value.response_time
    timefilter = TimeFilter(t0,t1)
    resolution = "1min"
    trafficexpr = TrafficFilter('"{tx}"'.format(tx=rargs.texpr) )
    report.run(grpby, columns, trafficexpr=trafficexpr, timefilter=timefilter, sort_col=sort_col, host_group_type=rargs.gby)
    printer = pprint.PrettyPrinter()
    data = report.get_data()
    for line in data:
      columns = ["%s" % cell for cell in line]
      print rargs.sdate, rargs.stime + ';' + rargs.edate, rargs.etime + ';' + rargs.app + ';' + ';'.join(columns)
  • Re: Are there example scripts?
    Christopher White

    Hey Folks,


    Recently we added a "steel mkworkspace" command that will populate a directory with some example scripts.  Right now this includes examples from netprofiler and netshark.  These are all command line scripts.  If using the steelscript-appfwk, use "steel appfwk mkproject" and this will create a "reports" directory with all the sample reports.


    Regarding columns -- try "steel netprofiler columns":


    List the available groupby options:

    $ steel netprofiler columns --list-groupbys <host> -u <username> -p <password>

    List the columns for a given groupby:

    $ steel netprofiler columns -g <groupby> <host> -u <username> -p <password>