mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-12-24 22:37:03 +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:
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()
|
||||
Reference in New Issue
Block a user