mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 04:07:52 +00:00
fix monitor df to blank function
This commit is contained in:
@@ -15,7 +15,7 @@ from LANforge.lfcli_base import LFCliBase
|
|||||||
from LANforge import add_monitor
|
from LANforge import add_monitor
|
||||||
from LANforge.add_monitor import *
|
from LANforge.add_monitor import *
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import base64
|
import base64
|
||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
@@ -1143,6 +1143,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def monitor(self,
|
def monitor(self,
|
||||||
duration_sec=60,
|
duration_sec=60,
|
||||||
monitor_interval=1,
|
monitor_interval=1,
|
||||||
@@ -1183,7 +1184,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
#previous_data_df= read_csv()
|
#previous_data_df= read_csv()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#Step 1, column names
|
#Step 1, column names
|
||||||
fields=None
|
fields=None
|
||||||
if col_names is not None and len(col_names) > 0:
|
if col_names is not None and len(col_names) > 0:
|
||||||
fields = ",".join(col_names)
|
fields = ",".join(col_names)
|
||||||
@@ -1233,7 +1234,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
print("Printing value map...")
|
print("Printing value map...")
|
||||||
print(value_map)
|
print(value_map)
|
||||||
|
|
||||||
#organize data
|
#organize data
|
||||||
full_test_data_list = []
|
full_test_data_list = []
|
||||||
for test_timestamp, data in value_map.items():
|
for test_timestamp, data in value_map.items():
|
||||||
#reduce the endpoint data to single dictionary of dictionaries
|
#reduce the endpoint data to single dictionary of dictionaries
|
||||||
@@ -1243,19 +1244,19 @@ class L3CXProfile(BaseProfile):
|
|||||||
print(endpoint_data)
|
print(endpoint_data)
|
||||||
endpoint_data["Timestamp"] = test_timestamp
|
endpoint_data["Timestamp"] = test_timestamp
|
||||||
full_test_data_list.append(endpoint_data)
|
full_test_data_list.append(endpoint_data)
|
||||||
|
|
||||||
|
|
||||||
header_row.append("Timestamp")
|
header_row.append("Timestamp")
|
||||||
header_row.append('Timestamp milliseconds')
|
header_row.append('Timestamp milliseconds')
|
||||||
df = pd.DataFrame(full_test_data_list)
|
df = pd.DataFrame(full_test_data_list)
|
||||||
|
|
||||||
df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000
|
df["Timestamp milliseconds"] = (df["Timestamp"] - datetime.datetime(1970,1,1)).dt.total_seconds()*1000
|
||||||
#round entire column
|
#round entire column
|
||||||
df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int)
|
df["Timestamp milliseconds"]=df["Timestamp milliseconds"].astype(int)
|
||||||
df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S"))
|
df["Timestamp"]=df["Timestamp"].apply(lambda x:x.strftime("%m/%d/%Y %I:%M:%S"))
|
||||||
df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]]
|
df=df[["Timestamp","Timestamp milliseconds", *header_row[:-2]]]
|
||||||
#compare previous data to current data
|
#compare previous data to current data
|
||||||
|
|
||||||
try:
|
try:
|
||||||
systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text)
|
systeminfo = ast.literal_eval(requests.get('http://'+str(self.lfclient_host)+':'+str(self.lfclient_port)).text)
|
||||||
except:
|
except:
|
||||||
@@ -1281,7 +1282,7 @@ class L3CXProfile(BaseProfile):
|
|||||||
supported_formats = ['csv', 'json', 'stata', 'pickle','html']
|
supported_formats = ['csv', 'json', 'stata', 'pickle','html']
|
||||||
for x in supported_formats:
|
for x in supported_formats:
|
||||||
if output_format.lower() == x or report_file.split('.')[-1] == x:
|
if output_format.lower() == x or report_file.split('.')[-1] == x:
|
||||||
exec('df.to_' + x + '("' + report_file + '",index=False' + ')')
|
exec('df.to_' + x + '("'+report_file+'")')
|
||||||
|
|
||||||
|
|
||||||
def refresh_cx(self):
|
def refresh_cx(self):
|
||||||
@@ -1743,20 +1744,20 @@ class L4CXProfile(LFCliBase):
|
|||||||
response = self.json_get("/layer4/%s?fields=%s" % (created_cx, fields))
|
response = self.json_get("/layer4/%s?fields=%s" % (created_cx, fields))
|
||||||
if debug:
|
if debug:
|
||||||
print(response)
|
print(response)
|
||||||
if response is None:
|
if response is None:
|
||||||
print(response)
|
print(response)
|
||||||
raise ValueError("Cannot find any endpoints")
|
raise ValueError("Cannot find any endpoints")
|
||||||
if monitor:
|
if monitor:
|
||||||
if debug:
|
if debug:
|
||||||
print(response)
|
print(response)
|
||||||
|
|
||||||
time.sleep(sleep_interval)
|
time.sleep(sleep_interval)
|
||||||
t = datetime.datetime.now()
|
t = datetime.datetime.now()
|
||||||
timestamps.append(t)
|
timestamps.append(t)
|
||||||
value_map[t] = response
|
value_map[t] = response
|
||||||
expected_passes += 1
|
expected_passes += 1
|
||||||
if self.check_errors(debug):
|
if self.check_errors(debug):
|
||||||
if self.check_request_rate():
|
if self.check_request_rate():
|
||||||
passes += 1
|
passes += 1
|
||||||
else:
|
else:
|
||||||
self._fail("FAIL: Request rate did not exceed 90% target rate")
|
self._fail("FAIL: Request rate did not exceed 90% target rate")
|
||||||
|
|||||||
Reference in New Issue
Block a user