be simpler for a quick report. See the <a href="edit/">report definition</a> for details on how this was written. </div> """ report = Report.create("Whois Example Report", description=description, position=11) report.add_section() # Define a Table that gets external hosts by avg bytes # This will be used as the base table for both analysis approaches table = NetProfilerGroupbyTable.create( '5-hosts', groupby='host', duration='1 hour', filterexpr='not srv host 10/8 and not srv host 192.168/16') table.add_column('host_ip', 'IP Addr', iskey=True, datatype='string') table.add_column('avg_bytes', 'Avg Bytes', units='B/s', sortdesc=True) # Using the custom analysis classes, this will create a new analysis table # and also add the extra column of interest. whoistable = WhoisTable.create('5-whois-hosts', tables={'t': table}) report.add_widget(yui3.TableWidget, whoistable, "Custom Analysis Link table", width=12) # Create an Analysis table that calls the 'whois' function to create the link
<p>Both approaches have benefits, the custom definitions allow far more flexibility in how things get defined, while the function approach can be simpler for a quick report. See the <a href="edit/">report definition</a> for details on how this was written. </div> """ report = Report.create("Whois Example Report", description=description, position=11) report.add_section() # Define a Table that gets external hosts by avg bytes # This will be used as the base table for both analysis approaches table = NetProfilerGroupbyTable.create( '5-hosts', groupby='host', duration='1 hour', filterexpr='not srv host 10/8 and not srv host 192.168/16' ) table.add_column('host_ip', 'IP Addr', iskey=True, datatype='string') table.add_column('avg_bytes', 'Avg Bytes', units='B/s', sortdesc=True) # Using the custom analysis classes, this will create a new analysis table # and also add the extra column of interest. whoistable = WhoisTable.create('5-whois-hosts', tables={'t': table}) report.add_widget(yui3.TableWidget, whoistable, "Custom Analysis Link table", width=12) # Create an Analysis table that calls the 'whois' function to create the link # Note that we need to manually add the extra column here, since our
url = reverse('report-view', kwargs=kwargs) line = '<li><a href="%s" target="_blank">%s</a></li>' % (url, r.title) lines.append(line) markup = """ <ul> %s </ul> """ % '\n'.join(lines) table = HTMLTable.create('Report Links', html=markup) report.add_widget(raw.TableWidget, table, 'report table', width=6) # Define a map and table, group by location p = NetProfilerGroupbyTable.create('maploc', groupby='host_group', duration=60, resolution='auto') p.add_column('group_name', label='Group Name', iskey=True) p.add_column('response_time', label='Resp Time', units='ms') p.add_column('network_rtt', label='Net RTT', units='ms') p.add_column('server_delay', label='Srv Delay', units='ms') report.add_widget(maps.MapWidget, p, "Response Time", width=5, height=300) # Define a Sharepoint Table s = SharepointTable.create('sp-documents', site_url='/', list_name='Shared Documents') s.add_column('BaseName', sortasc=True)
report.add_widget(c3.TimeSeriesWidget, p, "Overall Traffic", width=6) # Add a trigger to evaluate if traffic exceeds a certain threshold a = create_trigger(source=p, trigger_func=netprofiler_triggers.local_spike, params={'column': 'avg_bytes', 'std': 2}) a.add_destination( 'LoggingSender', options={'level': 'info'}, template='Logging Local Spike: time - {time}, value - {avg_bytes}' ) # Define a Table for Response Times p = NetProfilerGroupbyTable.create('location-resptime', groupby='host_group', duration=60) p.add_column('group_name', 'Group Name', iskey=True) p.add_column('response_time', 'Response Time', units='ms', sortdesc=True) report.add_widget(c3.BarWidget, p, "Locations by Response Time") # Add a trigger to evaluate if response time exceeds a certain threshold a = create_trigger(source=p, trigger_func=netprofiler_triggers.simple_trigger, params={'column': 'response_time', 'value': 0.3}) a.add_destination( 'LoggingSender', options={'level': 'info'}, template='Logging Response Time Exceeded Threshold'
add_netprofiler_hostgroup_field(report, section, 'ByLocation') # Define a Overall TimeSeries showing Avg Bytes/s p = NetProfilerTimeSeriesTable.create('ts-overall', duration=60, resolution="1min") p.add_column('time', 'Time', datatype='time', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s') report.add_widget(c3.TimeSeriesWidget, p, "Overall Traffic", width=12) # Define a Pie Chart for top ports p = NetProfilerGroupbyTable.create('ports-bytes', groupby='port_group', duration=60) p.add_column('portgroup', 'Port Group', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s', sortdesc=True) report.add_widget(c3.PieWidget, p, "Port Groups by Avg Bytes") # Define a Bar Chart for application ports p = NetProfilerGroupbyTable.create('application-bytes', groupby='application_port', duration=60) p.add_column('protoport_name', 'Application Port', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s', sortdesc=True) report.add_widget(c3.BarWidget, p, "Application Ports by Avg Bytes")
# - direction is hardcoded from the loop # - interface comes from the field # section = report.add_section("%s" % direction, section_keywords=['netprofiler_filterexpr', 'interface_expr']) section.fields.add(netprofiler_filterexpr) section.fields.add(interface_field) NetProfilerTable.extend_filterexpr( section, keyword='interface_filterexpr', template=('%s interface {interface}' % direction)) p = NetProfilerGroupbyTable.create('qos-%s-totals' % direction, groupby='dsc', duration=15, resolution=60, interface=True) p.fields.add(interface_field) TableField.create( keyword='%s_filterexpr' % direction, obj=p, hidden=True, post_process_template='%s interface {interface}' % direction ) p.fields_add_filterexprs_field('%s_filterexpr' % direction) p.add_column('dscp', 'Dscp', iskey=True, datatype="integer") p.add_column('dscp_name', 'Dscp Name', iskey=True, datatype="string") p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s') p.add_column('total_bytes', 'Total Bytes/s', units='B/s')
from steelscript.appfwk.apps.report.models import Report import steelscript.appfwk.apps.report.modules.maps as maps import steelscript.appfwk.apps.report.modules.yui3 as yui3 from steelscript.netprofiler.appfwk.datasources.netprofiler import NetProfilerGroupbyTable # # Google Map example # report = Report.create("Response Time Map", position=10) report.add_section() # Define a map and table, group by location p = NetProfilerGroupbyTable.create("maploc2", groupby="host_group", duration=60) p.add_column("group_name", iskey=True, label="Group Name", datatype="string") p.add_column("response_time", label="Resp Time", units="ms") p.add_column("network_rtt", label="Net RTT", units="ms") p.add_column("server_delay", label="Srv Delay", units="ms") p.add_column("avg_bytes", label="Response Time", units="B/s") p.add_column("peak_bytes", "Peak Bytes/s", units="B/s") p.add_column("avg_bytes_rtx", "Avg Retrans Bytes/s", units="B/s") p.add_column("peak_bytes_rtx", "Peak Retrans Bytes/s", units="B/s") # Create a Map widget report.add_widget(maps.MapWidget, p, "Response Time Map", width=12, height=500) # Create a Table showing the same data as the map report.add_widget(yui3.TableWidget, p, "Locations", width=12)
section = report.add_section() add_netprofiler_hostgroup_field(report, section, 'ByLocation') # Define a Overall TimeSeries showing Avg Bytes/s p = NetProfilerTimeSeriesTable.create('ts-overall', duration=60, resolution="1min") p.add_column('time', 'Time', datatype='time', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s') report.add_widget(c3.TimeSeriesWidget, p, "Overall Traffic", width=12) # Define a Pie Chart for top ports p = NetProfilerGroupbyTable.create('ports-bytes', groupby='port_group', duration=60) p.add_column('portgroup', 'Port Group', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s', sortdesc=True) report.add_widget(c3.PieWidget, p, "Port Groups by Avg Bytes") # Define a Bar Chart for application ports p = NetProfilerGroupbyTable.create('application-bytes', groupby='application_port', duration=60) p.add_column('protoport_name', 'Application Port', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s', sortdesc=True) report.add_widget(c3.BarWidget, p, "Application Ports by Avg Bytes") # Define a TimeSeries showing Avg Bytes/s for tcp/80
report.add_widget(c3.TimeSeriesWidget, p, "Bandwidth for tcp/80", altaxis=['avg_bytes_rtx']) # Define a TimeSeries showing Avg Bytes/s for tcp/443 p = NetProfilerTimeSeriesTable.create('ts-tcp443', duration=60, filterexpr='tcp/443') p.add_column('time', 'Time', datatype='time', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s') p.add_column('avg_bytes_rtx', 'Avg Retrans Bytes/s', units='B/s') report.add_widget(c3.TimeSeriesWidget, p, "Bandwidth for tcp/443") # Define a Pie Chart for locations p = NetProfilerGroupbyTable.create('location-bytes', groupby='host_group', duration=60) p.add_column('group_name', 'Group Name', iskey=True) p.add_column('avg_bytes', 'Avg Bytes/s', units='B/s', sortdesc=True) report.add_widget(c3.PieWidget, p, "Locations by Bytes") # Define a Table p = NetProfilerGroupbyTable.create('location-resptime', groupby='host_group', duration=60) p.add_column('group_name', 'Group Name', iskey=True) p.add_column('response_time', 'Response Time', units='ms', sortdesc=True) report.add_widget(c3.BarWidget, p, "Locations by Response Time")
report = Report.create("NetProfiler Utilization", position=10) report.add_section() # Define a Overall TimeSeries showing Avg Bytes/s p = NetProfilerTimeSeriesTable.create('opt-overall', duration=60, interface=True, resolution="1min") p.add_column('time', 'Time', datatype='time', iskey=True) p.add_column('in_avg_util', 'In Avg Util %', units='pct') p.add_column('out_avg_util', 'Out Avg Util %', units='pct') p.add_column('50-line', '50% Util', synthetic=True, compute_expression='50') p.add_column('70-line', '70% Util', synthetic=True, compute_expression='70') report.add_widget(c3.TimeSeriesWidget, p, "Overall Utilization", width=12) # Define a Pie Chart for locations p = NetProfilerGroupbyTable.create('util-table', groupby='interface', duration=60) p.add_column('interface', 'Interface', datatype='string', iskey=True) p.add_column('in_avg_util', 'In Avg Util %', units='pct') p.add_column('out_avg_util', 'Out Avg Util %', units='pct') p.add_column('in_peak_util', 'In Peak Util %', units='pct') p.add_column('out_peak_util', 'Out Peak Util %', units='pct') report.add_widget(tables.TableWidget, p, "Interface Utilization", width=12)
from steelscript.appfwk.apps.report.models import Report import steelscript.appfwk.apps.report.modules.maps as maps import steelscript.appfwk.apps.report.modules.yui3 as yui3 from steelscript.netprofiler.appfwk.datasources.netprofiler import NetProfilerGroupbyTable # # Google Map example # report = Report.create("Response Time Map", position=10) report.add_section() # Define a map and table, group by location p = NetProfilerGroupbyTable.create('maploc2', groupby='host_group', duration=60) p.add_column('group_name', iskey=True, label='Group Name', datatype='string') p.add_column('response_time', label='Resp Time', units='ms') p.add_column('network_rtt', label='Net RTT', units='ms') p.add_column('server_delay', label='Srv Delay', units='ms') p.add_column('avg_bytes', label='Response Time', units='B/s') p.add_column('peak_bytes', 'Peak Bytes/s', units='B/s') p.add_column('avg_bytes_rtx', 'Avg Retrans Bytes/s', units='B/s') p.add_column('peak_bytes_rtx', 'Peak Retrans Bytes/s', units='B/s') # Create a Map widget report.add_widget(maps.MapWidget, p, "Response Time Map", width=12, height=500) # Create a Table showing the same data as the map
p.add_column("time", "Time", datatype="time", iskey=True) p.add_column("avg_bytes", "Avg Bytes/s", units="B/s") p.add_column("avg_bytes_rtx", "Avg Retrans Bytes/s", units="B/s") report.add_widget(c3.TimeSeriesWidget, p, "Bandwidth for tcp/80", altaxis=["avg_bytes_rtx"]) # Define a TimeSeries showing Avg Bytes/s for tcp/443 p = NetProfilerTimeSeriesTable.create("ts-tcp443", duration=60, filterexpr="tcp/443") p.add_column("time", "Time", datatype="time", iskey=True) p.add_column("avg_bytes", "Avg Bytes/s", units="B/s") p.add_column("avg_bytes_rtx", "Avg Retrans Bytes/s", units="B/s") report.add_widget(c3.TimeSeriesWidget, p, "Bandwidth for tcp/443") # Define a Pie Chart for locations p = NetProfilerGroupbyTable.create("location-bytes", groupby="host_group", duration=60) p.add_column("group_name", "Group Name", iskey=True) p.add_column("avg_bytes", "Avg Bytes/s", units="B/s", sortdesc=True) report.add_widget(c3.PieWidget, p, "Locations by Bytes") # Define a Table p = NetProfilerGroupbyTable.create("location-resptime", groupby="host_group", duration=60) p.add_column("group_name", "Group Name", iskey=True) p.add_column("response_time", "Response Time", units="ms", sortdesc=True) report.add_widget(c3.BarWidget, p, "Locations by Response Time")