mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-01 03:07:56 +00:00
Refactoring code so that it refers to the new RecordInflux script
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
@@ -14,7 +14,7 @@ if 'py-json' not in sys.path:
|
||||
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
import json
|
||||
from influx2 import RecordInflux
|
||||
from InfluxRequest import RecordInflux
|
||||
from csv_to_influx import CSVtoInflux, influx_add_parser_args
|
||||
from grafana_profile import UseGrafana
|
||||
import random
|
||||
|
||||
59
py-scripts/csv_to_influx.py
Executable file
59
py-scripts/csv_to_influx.py
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
if 'py-dashboard' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
|
||||
|
||||
from InfluxRequest import *
|
||||
from cv_test_manager import *
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
|
||||
|
||||
class CSVtoInflux:
|
||||
def __init__(self,
|
||||
influx_host,
|
||||
influx_port,
|
||||
influx_org,
|
||||
influx_token,
|
||||
influx_bucket,
|
||||
path):
|
||||
self.path = path
|
||||
self.influxdb = RecordInflux(_influx_host=influx_host,
|
||||
_influx_port=influx_port,
|
||||
_influx_org=influx_org,
|
||||
_influx_token=influx_token,
|
||||
_influx_bucket=influx_bucket)
|
||||
|
||||
def glob(self):
|
||||
path = Path(self.path)
|
||||
self.kpi_list = list(path.glob('**/kpi.csv'))
|
||||
for kpi in self.kpi_list:
|
||||
self.influxdb.RecordInflux.csv_to_influx(kpi)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
cv_add_base_parser(parser)
|
||||
|
||||
parser.add_argument('--path', append=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
cv_base_adjust_parser(args)
|
||||
|
||||
csvtoinflux = CSVtoInflux(args.influx_host,
|
||||
args.influx_port,
|
||||
args.influx_org,
|
||||
args.influx_token,
|
||||
args.influx_bucket,
|
||||
args.path)
|
||||
|
||||
csvtoinflux.glob()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -20,6 +20,9 @@ if sys.version_info[0] != 3:
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||
|
||||
if 'py-dashboard' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
|
||||
|
||||
from LANforge.lfcli_base import LFCliBase
|
||||
import argparse
|
||||
|
||||
@@ -58,7 +61,7 @@ def main():
|
||||
tags = dict()
|
||||
tags['script'] = 'recordinflux'
|
||||
if args.influx_user is None:
|
||||
from influx2 import RecordInflux
|
||||
from InfluxRequest import RecordInflux
|
||||
grapher = RecordInflux(_influx_host=args.mgr,
|
||||
_influx_port=args.influx_port,
|
||||
_influx_bucket=args.influx_db,
|
||||
|
||||
@@ -35,10 +35,12 @@ if sys.version_info[0] != 3:
|
||||
if 'py-json' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-json'))
|
||||
|
||||
if 'py-dashboard' not in sys.path:
|
||||
sys.path.append(os.path.join(os.path.abspath('..'), 'py-dashboard'))
|
||||
|
||||
import argparse
|
||||
from LANforge import LFUtils
|
||||
from realm import Realm
|
||||
import time
|
||||
import datetime
|
||||
|
||||
|
||||
@@ -471,7 +473,7 @@ python3 ./test_ip_variable_time.py
|
||||
# manager = args.influx_mgr
|
||||
|
||||
if args.influx_org is not None:
|
||||
from influx2 import RecordInflux
|
||||
from InfluxRequest import RecordInflux
|
||||
grapher = RecordInflux(_influx_host=args.influx_host,
|
||||
_influx_port=args.influx_port,
|
||||
_influx_org=args.influx_org,
|
||||
|
||||
@@ -1366,7 +1366,7 @@ python3 .\\test_l3_longevity.py --test_duration 4m --endp_type \"lf_tcp lf_udp m
|
||||
|
||||
influxdb = None
|
||||
if args.influx_bucket is not None:
|
||||
from influx2 import RecordInflux
|
||||
from InfluxRequest import RecordInflux
|
||||
influxdb = RecordInflux(_influx_host=args.influx_host,
|
||||
_influx_port=args.influx_port,
|
||||
_influx_org=args.influx_org,
|
||||
|
||||
Reference in New Issue
Block a user