koder aka kdanilov | dda86d3 | 2015-03-16 11:20:04 +0200 | [diff] [blame] | 1 | import yaml |
| 2 | |
| 3 | from api import start_monitoring, Empty |
| 4 | from influx_exporter import connect, add_data |
| 5 | |
| 6 | monitor_config = yaml.load(open("config.yaml").read()) |
| 7 | |
| 8 | uri = "udp://192.168.0.104:12001" |
| 9 | infldb_url = "influxdb://perf:perf@192.168.152.42:8086/perf" |
| 10 | conn = connect(infldb_url) |
| 11 | |
koder aka kdanilov | a639e0a | 2015-03-17 15:30:36 +0200 | [diff] [blame^] | 12 | # 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 kdanilov | dda86d3 | 2015-03-16 11:20:04 +0200 | [diff] [blame] | 34 | |
| 35 | with start_monitoring(uri, monitor_config) as queue: |
| 36 | while True: |
| 37 | try: |
| 38 | (ip, port), data = queue.get(True, 1) |
koder aka kdanilov | dda86d3 | 2015-03-16 11:20:04 +0200 | [diff] [blame] | 39 | add_data(conn, ip, [data]) |
| 40 | except Empty: |
| 41 | pass |