def create(cls, name, tables, func, columns=None, params=None, copy_fields=True, related_tables=None, **kwargs): """ Class method to create an AnalysisTable. """ options = TableOptions(tables=tables, related_tables=related_tables, func=func, params=params) table = Table(name=name, module=__name__, options=options, **kwargs) table.save() if columns: for c in columns: Column.create(table, c) keywords = [] if (tables or related_tables) and copy_fields: table_ids = [] for t in [tables, related_tables]: if t: table_ids.extend(t.values()) for table_id in table_ids: for f in Table.objects.get(id=table_id).fields.all(): if f.keyword not in keywords: table.fields.add(f) keywords.append(f.keyword) return table
def create(cls, name, tables, func, columns=None, params=None, copy_fields=True, **kwargs): """ Class method to create an AnalysisTable. """ options = TableOptions(tables=tables, func=func, params=params) table = Table(name=name, module=__name__, options=options, **kwargs) table.save() if columns: for c in columns: Column.create(table, c) keywords = [] if tables and copy_fields: for table_id in tables.values(): for f in Table.objects.get(id=table_id).fields.all(): if f.keyword not in keywords: table.fields.add(f) keywords.append(f.keyword) return table
def create_criteria_table(name): table = AnalysisTable.create('name', tables={}, func = analysis_echo_criteria) Column.create(table, 'key', 'Criteria Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Criteria Value', isnumeric=False) return table
def create_criteria_table(name): table = AnalysisTable.create('name', tables={}, func=analysis_echo_criteria) Column.create(table, 'key', 'Criteria Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Criteria Value', isnumeric=False) return table
def create(cls, name, html): logger.debug('Creating StaticHTMLTable %s' % name) options = TableOptions(html=html) t = Table(name=name, module=__name__, options=options) t.save() Column.create(t, 'html', label='html') return t
def create_sharepoint_column(table, name, datatype='', issortcol=False): c = Column.create(table, name, label=name, datatype=datatype, issortcol=issortcol) c.save() return c
def create_shark_column(table, name, label=None, datatype='', units='', iskey=False, issortcol=False, extractor=None, operation=None, default_value=None): options = ColumnOptions(extractor=extractor, operation=operation, default_value=default_value) c = Column.create(table, name, label=label, datatype=datatype, units=units, iskey=iskey, issortcol=issortcol, options=options) c.save() return c
def create_sharepoint_column(table, name, datatype='', issortcol=False, **kwargs): # convert to encoded values as stored in Sharepoint label = name name = name.replace(' ', '_x0020_') name = name.replace('.', '_x002e_') c = Column.create(table, name, label=label, datatype=datatype, issortcol=issortcol, **kwargs) c.save() return c
def timestable(name): table = AnalysisTable.create(name, tables={}, func=compute_times) Column.create(table, 'starttime', 'Start time', datatype='time', iskey=True, issortcol=True) Column.create(table, 'endtime', 'End time', datatype='time', iskey=True) Column.create(table, 'totalsecs', 'Total secs') fields_add_business_hour_fields(table) return table
def timestable(): name = 'business_hours.timestable' try: table = Table.objects.get(name=name) except ObjectDoesNotExist: table = AnalysisTable.create(name, tables={}, func=compute_times) Column.create(table, 'starttime', 'Start time', datatype='time', iskey=True, issortcol=True) Column.create(table, 'endtime', 'End time', datatype='time', iskey=True) Column.create(table, 'totalsecs', 'Total secs') return table
report.save() interface_field = TableField.create(keyword='interface', label='Interface', required=True) datafilter_field = TableField.create(keyword='datafilter', hidden=True, post_process_template='interfaces_a,{interface}') section = Section.create(report, title="Overall") # Define a Overall TimeSeries showing In/Out Utilization table = TimeSeriesTable.create('qos-overall-util', duration=15, resolution=60, interface=True) table.fields.add(interface_field) table.fields.add(datafilter_field) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'in_avg_util', 'Avg Inbound Util %', datatype='bytes', units='B/s') Column.create(table, 'out_avg_util', 'Avg Outbound Util %', datatype='bytes', units='B/s') yui3.TimeSeriesWidget.create(section, table, "Overall Utilization", width=12) # Define a Overall TimeSeries showing In/Out Totals table = TimeSeriesTable.create('qos-overall-total', duration=15, resolution=15*60, interface=True) table.fields.add(interface_field) table.fields.add(datafilter_field) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'in_total_bytes', 'Total Inbound Bytes', datatype='bytes', units='B/s') Column.create(table, 'out_total_bytes', 'Total Outbound Bytes', datatype='bytes', units='B/s')
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.datasource.forms import fields_add_time_selection, fields_add_resolution from . import synthentic_functions as funcs # Report report = Report(title='Synthetic No Resampling' ) report.save() # Section section = Section(report=report, title='Section 0') section.save() # Table table = AnalysisTable.create('test-synthetic-noresampling', tables={}, func = funcs.analysis_echo_criteria) fields_add_time_selection(table) fields_add_resolution(table) Column.create(table, 'time', 'Time', iskey=True, isnumeric=True, datatype='time') Column.create(table, 'value', 'Value', isnumeric=True) raw.TableWidget.create(section, table, 'Table')
report.save() section = Section.create(report) bizhours.fields_add_business_hour_fields(section) # # Define by-interface table from Profiler # basetable = GroupByTable.create('bh-basetable', 'interface', duration=60, resolution=3600, interface=True) # Define all of your columns here associated with basetable # For each data column (iskey=False), you must specify the aggreation method # in the bizhours.create below. Column.create(basetable, 'interface_dns', 'Interface', iskey=True, isnumeric=False) Column.create(basetable, 'interface_alias', 'Ifalias', iskey=True, isnumeric=False) Column.create(basetable, 'avg_util', '% Utilization', datatype='pct', issortcol=True) Column.create(basetable, 'in_avg_util', '% Utilization In', datatype='pct', issortcol=False) Column.create(basetable, 'out_avg_util', '% Utilization Out', datatype='pct', issortcol=False) # The 'aggregate' parameter describes how similar rows on different business days # should be combined. For example: # # Day Total Bytes Avg Bytes/s # --------- ------------ ----------- # Mon 28MB 100 # Tue 56MB 200 # ========== ============= =========== # Combined 84MB 150 # Method sum avg
from rvbd_portal_profiler.datasources.profiler import (GroupByTable, TimeSeriesTable) # # Profiler report # report = Report(title="Profiler", position=2) report.save() section = Section.create(report) # Define a Overall TimeSeries showing Avg Bytes/s table = TimeSeriesTable.create('ts-overall', duration=60, resolution="1min") Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'avg_bytes', 'Avg Bytes/s', datatype='bytes', units='B/s') yui3.TimeSeriesWidget.create(section, table, "Overall Traffic", width=12) # Define a TimeSeries showing Avg Bytes/s for tcp/80 table = TimeSeriesTable.create('ts-tcp80', duration=60, filterexpr='tcp/80', cacheable=False) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'avg_bytes', 'Avg Bytes/s', datatype='bytes', units='B/s') Column.create(table, 'avg_bytes_rtx', 'Avg Retrans Bytes/s',
# helper libraries from rvbd_portal.apps.plugins.builtin.whois.libs.whois import whois # # Profiler report # report = Report(title="Whois", position=5) report.save() section = Section.create(report) # Define a Table that gets external hosts by avg bytes table = GroupByTable.create('5-hosts', 'host', duration='1 hour', filterexpr='not srv host 10/8 and not srv host 192.168/16') Column.create(table, 'host_ip', 'IP Addr', iskey=True) Column.create(table, 'avg_bytes', 'Avg Bytes', units='s', issortcol=True) # Create an Analysis table that calls the 'whois' function to craete a link to 'whois' whoistable = AnalysisTable.create('5-whois-hosts', tables={'t': table.id}, func=whois) Column.create(whoistable, 'host_ip', label="IP Addr", iskey=True) Column.create(whoistable, 'avg_bytes', 'Avg Bytes', datatype='bytes', issortcol=True) Column.create(whoistable, 'whois', label="Whois link", datatype='html') yui3.TableWidget.create(section, whoistable, "Link table", width=12)
datafilter_field = TableField.create( keyword='datafilter', hidden=True, post_process_template='interfaces_a,{interface}') section = Section.create(report, title="Overall") # Define a Overall TimeSeries showing In/Out Utilization table = TimeSeriesTable.create('qos-overall-util', duration=15, resolution=60, interface=True) table.fields.add(interface_field) table.fields.add(datafilter_field) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'in_avg_util', 'Avg Inbound Util %', datatype='bytes', units='B/s') Column.create(table, 'out_avg_util', 'Avg Outbound Util %', datatype='bytes', units='B/s') yui3.TimeSeriesWidget.create(section, table, "Overall Utilization", width=12) # Define a Overall TimeSeries showing In/Out Totals table = TimeSeriesTable.create('qos-overall-total',
from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Shared Fields') report.save() section = Section(report=report, title='Section') section.save() x = TableField.create('x', 'X Value') for i in range(2): table = AnalysisTable.create('test-criteria-sharedfields-%d' % i, tables={}, func=funcs.analysis_echo_criteria) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) table.fields.add(x) y = TableField.create('y', 'Y Value', table, hidden=True, parent_keywords=['x'], post_process_func=Function( funcs.sharedfields_compute, params={'factor': 10 * (i + 1)})) raw.TableWidget.create(section, table, 'Table %d' % i)
import rvbd_portal_sample.datasources.sample_source as sample # # Sample report # report = Report(title="Sample") report.save() section = Section.create(report) # Criteria table table = analysis.create_criteria_table('sample-criteria') yui3.TableWidget.create(section, table, "Report Criteria", width=12, height=200) # Define a Overall TimeSeries showing Avg Bytes/s options=sample.TableOptions(beta=4) table = sample.Table.create(name='sample-table', duration='15min', resolution='1s', options=options) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'sin1', 'Sine Wave 1', options = sample.ColumnOptions(func='sin', period='5min', alpha=3)) Column.create(table, 'sin2', 'Sine Wave 2', options = sample.ColumnOptions(func='sin', period='8min', alpha=5)) Column.create(table, 'cos', 'Cosine Wave', options = sample.ColumnOptions(func='cos', period='3min', alpha=2.5)) yui3.TimeSeriesWidget.create(section, table, "Sample Waves", width=12)
html = """ <ul> %s </ul> """ % '\n'.join(lines) table = StaticHTMLTable.create('Report Links', html) raw.TableWidget.create(section, table, 'report table', width=6) # Define a map and table, group by location table = GroupByTable.create('maploc', 'host_group', duration=60, resolution='auto') Column.create(table, 'group_name', label='Group Name', iskey=True) Column.create(table, 'response_time', label='Resp Time', datatype='metric') Column.create(table, 'network_rtt', label='Net RTT', datatype='metric') Column.create(table, 'server_delay', label='Srv Delay', datatype='metric') maps.MapWidget.create(section, table, "Response Time", width=5, height=300) # Define a Sharepoint Table table = SharepointTable.create('sp-documents', '/', 'Shared Documents') create_sharepoint_column(table, 'BaseName', issortcol=True) create_sharepoint_column(table, 'Created', datatype='time') create_sharepoint_column(table, 'Modified', datatype='time') create_sharepoint_column(table, 'ID') create_sharepoint_column(table, 'EncodedAbsUrl')
report.save() section = Section.create(report) # # Table: Process Internal.pcap # table = WireSharkTable.create('pcap', resample=True, resolution='1s', resolutions=['1s', '1m']) Column.create(table, 'pkttime', datatype='time', iskey=True, options=WireSharkColumnOptions(field='frame.time_epoch')) Column.create(table, 'iplen', options=WireSharkColumnOptions(field='ip.len', fieldtype='int')) Column.create(table, 'iplen-bits', synthetic=True, compute_expression='8*{iplen}', resample_operation='sum') Column.create(table, 'max-iplen', synthetic=True, compute_expression='{iplen}',
lines.append(line) html = """ <ul> %s </ul> """ % '\n'.join(lines) table = StaticHTMLTable.create('Report Links', html) raw.TableWidget.create(section, table, 'report table', width=6) # Define a map and table, group by location table = GroupByTable.create('maploc', 'host_group', duration=60, resolution='auto') Column.create(table, 'group_name', label='Group Name', iskey=True) Column.create(table, 'response_time', label='Resp Time', datatype='metric') Column.create(table, 'network_rtt', label='Net RTT', datatype='metric') Column.create(table, 'server_delay', label='Srv Delay', datatype='metric') maps.MapWidget.create(section, table, "Response Time", width=5, height=300) # Define a Sharepoint Table table = SharepointTable.create('sp-documents', '/', 'Shared Documents') create_sharepoint_column(table, 'BaseName', issortcol=True) create_sharepoint_column(table, 'Created', datatype='time') create_sharepoint_column(table, 'Modified', datatype='time') create_sharepoint_column(table, 'ID') create_sharepoint_column(table, 'EncodedAbsUrl')
from rvbd_portal_profiler.datasources.profiler import GroupByTable # # Google Map example # # Google Map example report = Report(title="Response Time Map", position=4) report.save() section = Section.create(report) # Define a map and table, group by location table = GroupByTable.create('maploc2', 'host_group', duration=60) Column.create(table, 'group_name', iskey=True, label='Group Name') Column.create(table, 'response_time', label='Resp Time', datatype='metric') Column.create(table, 'network_rtt', label='Net RTT', datatype='metric') Column.create(table, 'server_delay', label='Srv Delay', datatype='metric') Column.create(table, 'avg_bytes', label='Response Time', datatype='metric') Column.create(table, 'peak_bytes', 'Peak Bytes/s', datatype='bytes', units='B/s') Column.create(table, 'avg_bytes_rtx', 'Avg Retrans Bytes/s', datatype='bytes', units='B/s') Column.create(table, 'peak_bytes_rtx', 'Peak Retrans Bytes/s', datatype='bytes', units='B/s') # Create a Map widget maps.MapWidget.create(section, table, "Response Time Map", width=12, height=500) # Create a Table showing the same data as the map yui3.TableWidget.create(section, table, "Locations", width=12)
# -*- coding: utf-8 -*- # Copyright (c) 2013 Riverbed Technology, Inc. # # This software is licensed under the terms and conditions of the # MIT License set forth at: # https://github.com/riverbed/flyscript-portal/blob/master/LICENSE ("License"). # This software is distributed "AS IS" as set forth in the License. from rvbd_portal.apps.datasource.models import Column from rvbd_portal.apps.report.models import Report, Section import rvbd_portal.apps.report.modules.yui3 as yui3 from rvbd_portal_profiler.datasources.profiler_devices import DevicesTable report = Report(title="Profiler Device List", position=10) report.save() section = Section.create(report) # # Device Table devtable = DevicesTable.create('devtable') Column.create(devtable, 'ipaddr', 'Device IP', iskey=True, isnumeric=False) Column.create(devtable, 'name', 'Device Name', isnumeric=False) Column.create(devtable, 'type', 'Flow Type', isnumeric=False) Column.create(devtable, 'version', 'Flow Version', isnumeric=False) yui3.TableWidget.create(section, devtable, "Device List", height=300, width=12)
# # Overall report # report = Report(title="Overall", position=1, field_order=['endtime', 'profiler_filterexpr', 'shark_filterexpr'], hidden_fields=['resolution', 'duration']) report.save() section = Section.create(report, title='Locations', section_keywords=['resolution', 'duration']) # Define a map and table, group by location table = GroupByTable.create('maploc', 'host_group', duration=60, resolution='auto') Column.create(table, 'group_name', label='Group Name', iskey=True) Column.create(table, 'response_time', label='Resp Time', datatype='metric') Column.create(table, 'network_rtt', label='Net RTT', datatype='metric') Column.create(table, 'server_delay', label='Srv Delay', datatype='metric') maps.MapWidget.create(section, table, "Response Time", width=6, height=300) yui3.TableWidget.create(section, table, "Locations by Avg Bytes", width=6) # Define a Overall TimeSeries showing Avg Bytes/s section = Section.create(report, title='Profiler Overall', section_keywords=['resolution', 'duration']) table = TimeSeriesTable.create('ts1', duration=1440, resolution='15min') Column.create(table, 'time', label='Time', datatype='time', iskey=True) Column.create(table, 'avg_bytes', label='Avg Bytes/s', datatype='bytes', units='B/s')
# # Define by-interface table from Profiler # basetable = GroupByTable.create('bh-basetable', 'interface', duration=60, resolution=3600, interface=True) # Define all of your columns here associated with basetable # For each data column (iskey=False), you must specify the aggreation method # in the bizhours.create below. Column.create(basetable, 'interface_dns', 'Interface', iskey=True, isnumeric=False) Column.create(basetable, 'interface_alias', 'Ifalias', iskey=True, isnumeric=False) Column.create(basetable, 'avg_util', '% Utilization', datatype='pct', issortcol=True) Column.create(basetable, 'in_avg_util', '% Utilization In',
from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Defaults') report.save() # Report-level criteria TableField.create(keyword='report-1', label='Report 1', obj=report, initial='r1') TableField.create(keyword='report-2', label='Report 2', obj=report, required=True) # Section section = Section(report=report, title='Section 0') section.save() # Section-level criteria TableField.create(keyword='section-1', label='Section 1', obj=section, initial='s1') TableField.create(keyword='section-2', label='Section 2', obj=section, required=True, initial='s2') # Table table = AnalysisTable.create('test-criteria-postprocess', tables={}, func = funcs.analysis_echo_criteria) # Table-level criteria TableField.create(keyword='table-1', label='Table 1', obj=table, initial='t1') TableField.create(keyword='table-2', label='Table 2', obj=table, initial='t2') Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table')
from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title="Criteria Post Process") report.save() section = Section(report=report, title="Section 0") section.save() table = AnalysisTable.create("test-criteria-postprocess", tables={}, func=funcs.analysis_echo_criteria) TableField.create("w", "W Value", table) TableField.create("x", "X Value", table) TableField.create("y", "Y Value", table) for (f1, f2) in [("w", "x"), ("w", "y"), ("x", "y")]: ( TableField.create( "%s%s" % (f1, f2), "%s+%s Value" % (f1, f2), table, hidden=True, parent_keywords=[f1, f2], post_process_func=Function(funcs.postprocess_field_compute, params={"fields": [f1, f2]}), ) ) Column.create(table, "key", "Key", iskey=True, isnumeric=False) Column.create(table, "value", "Value", isnumeric=False) raw.TableWidget.create(section, table, "Table")
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.datasource.forms import fields_add_time_selection, fields_add_resolution # Report from rvbd_portal.apps.report.tests.reports import synthetic_functions as funcs report = Report(title='Synthetic No Resampling' ) report.save() # Section section = Section(report=report, title='Section 0') section.save() # Table table = AnalysisTable.create('test-synthetic-resampling', tables={}, func = funcs.analysis_generate_data, resample = True, params = {'source_resolution': 60 }) fields_add_time_selection(table) fields_add_resolution(table) Column.create(table, 'time', 'Time', iskey=True, isnumeric=True, datatype='time') Column.create(table, 'value', 'Value', isnumeric=True) raw.TableWidget.create(section, table, 'Table')
# Criteria table table = analysis.create_criteria_table('sample-criteria') yui3.TableWidget.create(section, table, "Report Criteria", width=12, height=200) # Define a Overall TimeSeries showing Avg Bytes/s options = sample.TableOptions(beta=4) table = sample.Table.create(name='sample-table', duration='15min', resolution='1s', options=options) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'sin1', 'Sine Wave 1', options=sample.ColumnOptions(func='sin', period='5min', alpha=3)) Column.create(table, 'sin2', 'Sine Wave 2', options=sample.ColumnOptions(func='sin', period='8min', alpha=5)) Column.create(table, 'cos', 'Cosine Wave', options=sample.ColumnOptions(func='cos', period='3min', alpha=2.5))
# report = Report(title="PCAP Analysis (FileField)", position=8) report.save() section = Section.create(report) # # Table: Process Internal.pcap # table = WireSharkTable.create('pcap', resample=True, resolution='1s', resolutions=['1s','1m']) Column.create(table, 'pkttime', datatype='time', iskey=True, options=WireSharkColumnOptions(field='frame.time_epoch')) Column.create(table, 'iplen', options=WireSharkColumnOptions(field='ip.len', fieldtype='int')) Column.create(table, 'iplen-bits', synthetic=True, compute_expression='8*{iplen}', resample_operation='sum') Column.create(table, 'max-iplen', synthetic=True, compute_expression='{iplen}', resample_operation='max') Column.create(table, 'min-iplen', synthetic=True, compute_expression='{iplen}', resample_operation='min') Column.create(table, 'limit_100', synthetic=True, compute_expression='100', resample_operation='min')
from rvbd_portal_profiler.datasources.profiler import (GroupByTable, TimeSeriesTable) # # Profiler report # report = Report(title="Profiler", position=2) report.save() section = Section.create(report) # Define a Overall TimeSeries showing Avg Bytes/s table = TimeSeriesTable.create('ts-overall', duration=60, resolution="1min") Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'avg_bytes', 'Avg Bytes/s', datatype='bytes', units='B/s') yui3.TimeSeriesWidget.create(section, table, "Overall Traffic", width=12) # Define a TimeSeries showing Avg Bytes/s for tcp/80 table = TimeSeriesTable.create('ts-tcp80', duration=60, filterexpr = 'tcp/80', cacheable=False) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'avg_bytes', 'Avg Bytes/s', datatype='bytes', units = 'B/s') Column.create(table, 'avg_bytes_rtx', 'Avg Retrans Bytes/s', datatype='bytes', units = 'B/s') yui3.TimeSeriesWidget.create(section, table, "Bandwidth for tcp/80", altaxis=['avg_bytes_rtx'])