mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-29 09:52:35 +00:00
create CSV from realm monitor
This commit is contained in:
@@ -18,6 +18,7 @@ import os
|
||||
import datetime
|
||||
import base64
|
||||
import xlsxwriter
|
||||
import pandas as pd
|
||||
|
||||
def wpa_ent_list():
|
||||
return [
|
||||
@@ -1099,9 +1100,7 @@ class L3CXProfile(LFCliBase):
|
||||
|
||||
#Step 1, column names
|
||||
fields=",".join(col_names)
|
||||
#Step 2, create report file
|
||||
report_fh = open(report_file, "w+")
|
||||
#Step 3, monitor columns
|
||||
#Step 2, monitor columns
|
||||
start_time = datetime.datetime.now()
|
||||
end_time = start_time + datetime.timedelta(seconds=duration_sec)
|
||||
|
||||
@@ -1137,24 +1136,26 @@ class L3CXProfile(LFCliBase):
|
||||
|
||||
if passes == expected_passes:
|
||||
self._pass("PASS: All tests passed")
|
||||
#Step 4, close and save
|
||||
#step 3 organize data
|
||||
endpoints=list()
|
||||
for endpoint in value_map.values():
|
||||
endpoints.append(endpoint['endpoint'])
|
||||
endpoints2=[]
|
||||
for y in range(0, len(endpoints)):
|
||||
for x in range(0, len(endpoints[0])):
|
||||
endpoints2.append(list(list(endpoints[y][x].values())[0].values()))
|
||||
timestamps=[]
|
||||
for timestamp in [*value_map.keys()]:
|
||||
timestamps.extend([str(timestamp)]*2*len(created_cx))
|
||||
for point in range(0, len(endpoints2)):
|
||||
endpoints2[point].insert(0, timestamps[point])
|
||||
#step 4 save and close
|
||||
header_row=col_names
|
||||
header_row.insert(0,'Timestamp')
|
||||
if output_format.lower() == 'excel':
|
||||
endpoints=list()
|
||||
for endpoint in value_map.values():
|
||||
endpoints.append(endpoint['endpoint'])
|
||||
endpoints2=[]
|
||||
for y in range(0, len(endpoints)):
|
||||
for x in range(0, len(endpoints[0])):
|
||||
endpoints2.append(list(list(endpoints[y][x].values())[0].values()))
|
||||
timestamps=[]
|
||||
for timestamp in [*value_map.keys()]:
|
||||
timestamps.extend([str(timestamp)]*2*len(created_cx))
|
||||
for point in range(0, len(endpoints2)):
|
||||
endpoints2[point].insert(0, timestamps[point])
|
||||
report_fh = open(report_file, "w+")
|
||||
workbook = xlsxwriter.Workbook(report_file)
|
||||
worksheet = workbook.add_worksheet()
|
||||
header_row=col_names
|
||||
header_row.insert(0,'Timestamp')
|
||||
for col_num,data in enumerate(header_row):
|
||||
worksheet.write(0, col_num,data)
|
||||
row_num = 1
|
||||
@@ -1163,6 +1164,10 @@ class L3CXProfile(LFCliBase):
|
||||
worksheet.write(row_num, col_num, str(data))
|
||||
row_num+=1
|
||||
workbook.close()
|
||||
elif output_format.lower() == 'csv':
|
||||
df=pd.DataFrame(endpoints2)
|
||||
df.columns=header_row
|
||||
df.to_csv(report_file)
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ def main():
|
||||
optional_args.add_argument('--mode',help='Used to force mode of stations')
|
||||
optional_args.add_argument('--ap',help='Used to force a connection to a particular AP')
|
||||
optional_args.add_argument('--report_file',help='where you want to store results')
|
||||
optional_args.add_argument('--output_format', help='choose either csv or xlsx')
|
||||
args = parser.parse_args()
|
||||
|
||||
num_sta = 2
|
||||
@@ -227,15 +228,24 @@ def main():
|
||||
ip_var_test.start(False, False)
|
||||
|
||||
if args.report_file is None:
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx'
|
||||
if args.output_format == 'csv':
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.csv'
|
||||
output='csv'
|
||||
else:
|
||||
report_f='/home/lanforge/report-data/'+str(datetime.datetime.now()).replace(':','-')+'test_ipv4_variable_time.xlsx'
|
||||
output='excel'
|
||||
else:
|
||||
report_f=args.report_file
|
||||
if args.output_format == 'csv':
|
||||
output='csv'
|
||||
else:
|
||||
output='excel'
|
||||
layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']])
|
||||
ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'],
|
||||
report_file=report_f,
|
||||
duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).seconds,
|
||||
created_cx= layer3connections,
|
||||
output_format='excel')
|
||||
output_format=output)
|
||||
ip_var_test.stop()
|
||||
if not ip_var_test.passes():
|
||||
print(ip_var_test.get_fail_message())
|
||||
|
||||
Reference in New Issue
Block a user