blob: 8903f2437264c636863aaeb611c999532c2dbe68 [file] [log] [blame]
koder aka kdanilovdda86d32015-03-16 11:20:04 +02001import yaml
2
3from api import start_monitoring, Empty
4from influx_exporter import connect, add_data
5
6monitor_config = yaml.load(open("config.yaml").read())
7
8uri = "udp://192.168.0.104:12001"
9infldb_url = "influxdb://perf:perf@192.168.152.42:8086/perf"
10conn = connect(infldb_url)
11
koder aka kdanilova639e0a2015-03-17 15:30:36 +020012# sw_per_ip = {}
13# count = 4
14# expected = sorted(monitor_config.keys())
15
16# if 'sda1.sectors_written' in data:
17# val = data['sda1.sectors_written']
18# elif 'sdb.sectors_written' in data:
19# val = data['sdb.sectors_written']
20# else:
21# val = 0
22
23# sw_per_ip[ip] = sw_per_ip.get(ip, 0) + val
24# count -= 1
25
26# if 0 == count:
27# try:
28# vals = [sw_per_ip[ip] for ip in expected]
29# print ("{:>6}" * len(expected)).format(*vals)
30# sw_per_ip = {}
31# count = 4
32# except KeyError:
33# pass
koder aka kdanilovdda86d32015-03-16 11:20:04 +020034
35with start_monitoring(uri, monitor_config) as queue:
36 while True:
37 try:
38 (ip, port), data = queue.get(True, 1)
koder aka kdanilovdda86d32015-03-16 11:20:04 +020039 add_data(conn, ip, [data])
40 except Empty:
41 pass