Create port_probe.py and update l3_cxprofile and test_ip_variable_time so that they can use port_probe.py

Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
Matthew Stidham
2021-10-14 13:47:37 -07:00
parent 471b988b88
commit 2f4dfaea14
3 changed files with 152 additions and 33 deletions

View File

@@ -13,7 +13,8 @@ sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
LFCliBase = lfcli_base.LFCliBase
pandas_extensions = importlib.import_module("py-json.LANforge.pandas_extensions")
port_probe = importlib.import_module("py-json.port_probe")
ProbePort = port_probe.ProbePort
class L3CXProfile(LFCliBase):
def __init__(self,
@@ -120,7 +121,6 @@ class L3CXProfile(LFCliBase):
layer3_cols=None,
port_mgr_cols=None,
created_cx=None,
monitor=True,
report_file=None,
systeminfopath=None,
output_format=None,
@@ -221,18 +221,8 @@ class L3CXProfile(LFCliBase):
passes += 1
else:
self.fail("FAIL: Not all stations increased traffic")
self.exit_fail()
if port_mgr_cols is not None:
result = dict()
for dictionary in port_mgr_response['interfaces']:
if debug:
print('port mgr data: %s' % dictionary)
result.update(dictionary)
portdata_df = pd.DataFrame(result.values())
portdata_df['EID'] = result.keys()
result = dict()
result = dict() # create dataframe from layer 3 results
if type(layer_3_response) is dict:
for dictionary in layer_3_response['endpoint']:
if debug:
@@ -241,12 +231,51 @@ class L3CXProfile(LFCliBase):
else:
pass
layer3 = pd.DataFrame(result.values())
layer3['EID'] = result.keys()
layer3.columns = ['l3-'+x for x in layer3.columns]
if port_mgr_cols is not None:
timestamp_df = pd.concat([layer3, portdata_df])
if port_mgr_cols is not None: # create dataframe from port mgr results
if 'alias' not in port_mgr_cols:
port_mgr_cols.append('alias')
result = dict()
if type(port_mgr_response) is dict:
for dictionary in port_mgr_response['interfaces']:
if debug:
print('port mgr data: %s' % dictionary)
result.update(dictionary)
portdata_df = pd.DataFrame(result.values())
portdata_df.columns = ['port-'+x for x in portdata_df.columns]
portdata_df['alias'] = portdata_df['port-alias']
layer3_alias = list() # Add alias to layer 3 dataframe
for cross_connect in layer3['l3-name']:
for port in portdata_df['port-alias']:
if port in cross_connect:
layer3_alias.append(port)
layer3['alias'] = layer3_alias
timestamp_df = pd.merge(layer3, portdata_df, on='alias')
else:
timestamp_df = layer3
probe_port_df_list = list()
for station in sta_list:
probe_port = ProbePort(lfhost=self.lfclient_host,
lfport=self.lfclient_port,
eid_str=station,
debug=self.debug)
probe_results = dict()
probe_port.refreshProbe()
probe_results['Signal Avg Combined'] = probe_port.getSignalAvgCombined()
probe_results['Signal Avg per Chain'] = probe_port.getSignalAvgPerChain()
probe_results['Signal Combined'] = probe_port.getSignalCombined()
probe_results['Signal per Chain'] = probe_port.getSignalPerChain()
probe_results['Beacon Avg Signal'] = probe_port.getBeaconSignalAvg()
probe_df_initial = pd.DataFrame(probe_results.values()).transpose()
probe_df_initial.columns = probe_results.keys()
probe_df_initial.columns = ['probe '+x for x in probe_df_initial.columns]
probe_df_initial['alias'] = station.split('.')[-1]
probe_port_df_list.append(probe_df_initial)
probe_port_df = pd.concat(probe_port_df_list)
timestamp_df = pd.merge(timestamp_df, probe_port_df, on='alias')
timestamp_df['Timestamp'] = timestamp
timestamp_df['Timestamp milliseconds epoch'] = t_to_millisec_epoch
timestamp_df['Timestamp seconds epoch'] = t_to_sec_epoch
@@ -254,6 +283,7 @@ class L3CXProfile(LFCliBase):
timestamp_data.append(timestamp_df)
time.sleep(monitor_interval_ms)
df = pd.concat(timestamp_data)
df = df.drop('alias', 1)
df.to_csv(str(report_file), index=False)
# comparison to last report / report inputted

View File

@@ -1,6 +1,9 @@
#!/usr/bin/env python3
from LANforge.lfcli_base import LFCliBase
import importlib
from time import sleep
lfcli_base = importlib.import_module("py-json.LANforge.lfcli_base")
LFCliBase = lfcli_base.LFCliBase
# Probe data can change frequently. It is recommended to update
class ProbePort(LFCliBase):
def __init__(self,
@@ -19,8 +22,12 @@ class ProbePort(LFCliBase):
def refreshProbe(self):
self.json_post(self.probepath, {})
sleep(0.2)
response = self.json_get(self.probepath)
self.response = response
if self.debug:
print(self.probepath)
print(response)
text = self.response['probe-results'][0][self.eid_str]['probe results'].split('\n')
signals = [x.strip('\t').split('\t') for x in text if 'signal' in x]
keys = [x[0].strip(' ').strip(':') for x in signals]

View File

@@ -38,6 +38,9 @@ sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../")))
LFUtils = importlib.import_module("py-json.LANforge.LFUtils")
realm = importlib.import_module("py-json.realm")
Realm = realm.Realm
sys.path.append("../py-dashboard")
from InfluxRequest import RecordInflux
port_probe = importlib.import_module("py-json.port_probe")
class IPVariableTime(Realm):
@@ -63,6 +66,7 @@ class IPVariableTime(Realm):
report_file=None,
output_format=None,
layer3_cols=None,
port_mgr_cols=None,
monitor_interval='10s',
influx_host=None,
influx_port=None,
@@ -125,6 +129,7 @@ class IPVariableTime(Realm):
self.report_file = report_file
self.output_format = output_format
self.layer3_cols = layer3_cols
self.port_mgr_cols = port_mgr_cols
self.monitor_interval = monitor_interval
self.influx_host = influx_host
self.influx_port = influx_port
@@ -234,22 +239,22 @@ class IPVariableTime(Realm):
else:
layer3_cols = self.layer3_cols
# send col names here to file to reformat
#if type(self.port_mgr_cols) is not list:
#port_mgr_cols = list(self.port_mgr_cols.split(","))
if type(self.port_mgr_cols) is not list:
port_mgr_cols = list(self.port_mgr_cols.split(","))
# send col names here to file to reformat
#else:
#port_mgr_cols = self.port_mgr_cols
else:
port_mgr_cols = self.port_mgr_cols
# send col names here to file to reformat
if self.debug:
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
#print(port_mgr_cols)
print(port_mgr_cols)
print("Layer 3 Endp column names are...")
print(layer3_cols)
print("Port Manager column names are...")
#print(port_mgr_cols)
print(port_mgr_cols)
try:
monitor_interval = Realm.parse_time(self.monitor_interval).total_seconds()
@@ -266,13 +271,12 @@ class IPVariableTime(Realm):
# manager = self.influx_mgr
if self.influx_org is not None:
from InfluxRequest import RecordInflux
grapher = RecordInflux(_influx_host=self.influx_host,
_influx_port=self.influx_port,
_influx_org=self.influx_org,
_influx_token=self.influx_token,
_influx_bucket=self.influx_bucket)
devices = [station.split('.')[-1] for station in station_list]
devices = [station.split('.')[-1] for station in self.sta_list]
tags = dict()
tags['script'] = 'test_ip_variable_time'
try:
@@ -285,7 +289,6 @@ class IPVariableTime(Realm):
monitor_interval=Realm.parse_time(self.monitor_interval).total_seconds(),
tags=tags)
# Retrieve last data file
compared_rept = None
if self.compared_report:
@@ -299,7 +302,7 @@ class IPVariableTime(Realm):
self.cx_profile.monitor(layer3_cols=layer3_cols,
sta_list=self.sta_list,
# port_mgr_cols=port_mgr_cols,
port_mgr_cols=port_mgr_cols,
report_file=report_f,
systeminfopath=systeminfopath,
duration_sec=Realm.parse_time(self.test_duration).total_seconds(),
@@ -443,13 +446,91 @@ python3 ./test_ip_variable_time.py
Elapsed | 'elapsed'
Destination Addr | 'destination addr'
Source Addr | 'source addr'
Using the port_mgr_cols flag:
'4way time (us)'
'activity'
'alias'
'anqp time (us)'
'ap'
'beacon'
'bps rx'
'bps rx ll'
'bps tx'
'bps tx ll'
'bytes rx ll'
'bytes tx ll'
'channel'
'collisions'
'connections'
'crypt'
'cx ago'
'cx time (us)'
'device'
'dhcp (ms)'
'down'
'entity id'
'gateway ip'
'ip'
'ipv6 address'
'ipv6 gateway'
'key/phrase'
'login-fail'
'login-ok'
'logout-fail'
'logout-ok'
'mac'
'mask'
'misc'
'mode'
'mtu'
'no cx (us)'
'noise'
'parent dev'
'phantom'
'port'
'port type'
'pps rx'
'pps tx'
'qlen'
'reset'
'retry failed'
'rx bytes'
'rx crc'
'rx drop'
'rx errors'
'rx fifo'
'rx frame'
'rx length'
'rx miss'
'rx over'
'rx pkts'
'rx-rate'
'sec'
'signal'
'ssid'
'status'
'time-stamp'
'tx abort'
'tx bytes'
'tx crr'
'tx errors'
'tx fifo'
'tx hb'
'tx pkts'
'tx wind'
'tx-failed %'
'tx-rate'
'wifi retries'
Can't decide what columns to use? You can just use 'all' to select all available columns from both tables.
''')
parser.add_argument('--mode', help='Used to force mode of stations')
parser.add_argument('--ap', help='Used to force a connection to a particular AP')
parser.add_argument('--traffic_type', help='Select the Traffic Type [lf_udp, lf_tcp, udp, tcp], type will be '
'adjusted automatically between ipv4 and ipv6 based on use of --ipv6 flag'
, required=True)
'adjusted automatically between ipv4 and ipv6 based on use of --ipv6 flag',
required=True)
parser.add_argument('--output_format', help='choose either csv or xlsx')
parser.add_argument('--report_file', help='where you want to store results', default=None)
parser.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000)
@@ -458,7 +539,7 @@ python3 ./test_ip_variable_time.py
parser.add_argument('--layer3_cols', help='Columns wished to be monitored from layer 3 endpoint tab',
default=['name', 'tx bytes', 'rx bytes', 'tx rate', 'rx rate'])
parser.add_argument('--port_mgr_cols', help='Columns wished to be monitored from port manager tab',
default=['ap', 'ip', 'parent dev'])
default=['alias', 'ap', 'ip', 'parent dev', 'rx-rate', 'beacon'])
parser.add_argument('--compared_report', help='report path and file which is wished to be compared with new report',
default=None)
parser.add_argument('--monitor_interval',
@@ -534,6 +615,7 @@ python3 ./test_ip_variable_time.py
report_file=args.report_file,
output_format=args.output_format,
layer3_cols=args.layer3_cols,
port_mgr_cols=args.port_mgr_cols,
monitor_interval=args.monitor_interval,
influx_host=args.influx_host,
influx_port=args.influx_port,