Skip to content
Snippets Groups Projects
Commit f45374fe authored by Riccardo Sellari's avatar Riccardo Sellari
Browse files

still not working

parent 4d29c535
No related branches found
No related tags found
No related merge requests found
import argparse import argparse
from influxdb import InfluxDBClient from influxdb import InfluxDBClient
from datetime import datetime
import sys import sys
from pymemcache.client import base from pymemcache.client import base
import os import os
...@@ -17,10 +18,30 @@ def findTheKey(path, clientMemcached): ...@@ -17,10 +18,30 @@ def findTheKey(path, clientMemcached):
parameter = re.sub(r',|"|( ←)',"",match.group(2)) parameter = re.sub(r',|"|( ←)',"",match.group(2))
data[match.group(1)] = parameter data[match.group(1)] = parameter
if(line.find('keybind') != -1): if(line.find('keybind') != -1):
line = re.sub(r',|( ←)',"",line)
pattern = r'"(.+)":"(.+)"'
match = re.search(pattern,line) match = re.search(pattern,line)
parameter = re.sub(r',|"|( ←)',"",match.group(2)) data[match.group(1)] = match.group(2)
data[match.group(1)] = parameter data['memcached'] = clientMemcached.get(data['keybind'])
#value if(data['type'] == 'json'):
data4influx = [{
"measurements" : "memcachedData",
"timestamp" : datetime.now(),
"tags": {
"type" : data["type"]
},
"fields" :{
data["keybind"] : data ['memcached']
}
}
]
print(data4influx)
print('\n')
clientInflux.write_points(data4influx)
data.clear
else:
pass
...@@ -37,12 +58,11 @@ args = parser.parse_args() ...@@ -37,12 +58,11 @@ args = parser.parse_args()
#log in the influx DB #log in the influx DB
#python memcached2Influx.py -s vldantemon003.lnf.infn.it -po 8086 -f '/home/riccardo/Random bs go/Test/cofnigurationFile.txt' #python memcached2Influx.py -s vldantemon003.lnf.infn.it -po 8086 -f '/home/riccardo/Random bs go/Test/cofnigurationFile.txt'
#dcsMemDb #try:
try: clientInflux = InfluxDBClient(host=args.server, port=args.port, username=args.username, password=args.password)
clientInflux = InfluxDBClient(host=args.server, port=args.port, username=args.username, password=args.password) print("succesfully logged in\n")
print("succesfully logged in") #except:
except: # sys.exit("Error: Invalid parameters, please try again")
sys.exit("Error: Invalid parameters, please try again")
#log in the memcached DB #log in the memcached DB
#memcached_server = "192.168.198.20" #memcached_server = "192.168.198.20"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment