From c4c1ace54fdb3834083a472546ce114c1e9bbf25 Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Fri, 25 Jan 2019 13:53:44 -0600 Subject: [PATCH] check payload for unifi --- varken.xml | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ varken/unifi.py | 54 ++++++++++++++++++++++++++----------------------- 2 files changed, 83 insertions(+), 25 deletions(-) create mode 100644 varken.xml diff --git a/varken.xml b/varken.xml new file mode 100644 index 0000000..b7fbf3a --- /dev/null +++ b/varken.xml @@ -0,0 +1,54 @@ + + + Varken + boerderij/varken + https://hub.docker.com/r/boerderij/varken/~/dockerfile/ + bridge + + sh + false + https://discord.gg/VjZ6qSM + + + Varken is a standalone command-line utility to aggregate data from the Plex ecosystem into InfluxDB. Examples use Grafana for a frontend + + + + + Pig.png + + + + + + + Varken is a standalone command-line utility to aggregate data from the Plex ecosystem into InfluxDB. Examples use Grafana for a frontend + + + bridge + + + + + /mnt/user/appdata/varken + /config + rw + + + + + 99 + PGID + + + + 100 + PUID + + + + + 99 + 100 + /mnt/user/appdata/varken + \ No newline at end of file diff --git a/varken/unifi.py b/varken/unifi.py index 1cf3333..01f68ac 100644 --- a/varken/unifi.py +++ b/varken/unifi.py @@ -47,29 +47,33 @@ class UniFiAPI(object): self.logger.error("Could not find a USG named %s from your UniFi Controller", self.server.usg_name) return - influx_payload = [ - { - "measurement": "UniFi", - "tags": { - "model": device['model'], - "name": device['name'] - }, - "time": now, - "fields": { - "bytes_current": device['wan1']['bytes-r'], - "rx_bytes_total": device['wan1']['rx_bytes'], - "rx_bytes_current": device['wan1']['rx_bytes-r'], - "tx_bytes_total": device['wan1']['tx_bytes'], - "tx_bytes_current": device['wan1']['tx_bytes-r'], - "speedtest_latency": device['speedtest-status']['latency'], - "speedtest_download": device['speedtest-status']['xput_download'], - "speedtest_upload": device['speedtest-status']['xput_upload'], - "cpu_loadavg_1": device['sys_stats']['loadavg_1'], - "cpu_loadavg_5": device['sys_stats']['loadavg_5'], - "cpu_loadavg_15": device['sys_stats']['loadavg_15'], - "cpu_util": device['system-stats']['cpu'], - "mem_util": device['system-stats']['mem'], + try: + influx_payload = [ + { + "measurement": "UniFi", + "tags": { + "model": device['model'], + "name": device['name'] + }, + "time": now, + "fields": { + "bytes_current": device['wan1']['bytes-r'], + "rx_bytes_total": device['wan1']['rx_bytes'], + "rx_bytes_current": device['wan1']['rx_bytes-r'], + "tx_bytes_total": device['wan1']['tx_bytes'], + "tx_bytes_current": device['wan1']['tx_bytes-r'], + # Commenting speedtest out until Unifi gets their shit together + # "speedtest_latency": device['speedtest-status']['latency'], + # "speedtest_download": device['speedtest-status']['xput_download'], + # "speedtest_upload": device['speedtest-status']['xput_upload'], + "cpu_loadavg_1": device['sys_stats']['loadavg_1'], + "cpu_loadavg_5": device['sys_stats']['loadavg_5'], + "cpu_loadavg_15": device['sys_stats']['loadavg_15'], + "cpu_util": device['system-stats']['cpu'], + "mem_util": device['system-stats']['mem'], + } } - } - ] - self.dbmanager.write_points(influx_payload) + ] + self.dbmanager.write_points(influx_payload) + except KeyError as e: + self.logger.error('Error building payload for unifi. Discarding. Error: %s', e)