check payload for unifi
This commit is contained in:
parent
5bbf9d0f01
commit
c4c1ace54f
2 changed files with 83 additions and 25 deletions
54
varken.xml
Normal file
54
varken.xml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<Container version="2">
|
||||||
|
<Name>Varken</Name>
|
||||||
|
<Repository>boerderij/varken</Repository>
|
||||||
|
<Registry>https://hub.docker.com/r/boerderij/varken/~/dockerfile/</Registry>
|
||||||
|
<Network>bridge</Network>
|
||||||
|
<MyIP/>
|
||||||
|
<Shell>sh</Shell>
|
||||||
|
<Privileged>false</Privileged>
|
||||||
|
<Support>https://discord.gg/VjZ6qSM</Support>
|
||||||
|
<Project/>
|
||||||
|
<Overview>
|
||||||
|
Varken is a standalone command-line utility to aggregate data from the Plex ecosystem into InfluxDB. Examples use Grafana for a frontend
|
||||||
|
</Overview>
|
||||||
|
<Category/>
|
||||||
|
<WebUI/>
|
||||||
|
<TemplateURL/>
|
||||||
|
<Icon>Pig.png</Icon>
|
||||||
|
<ExtraParams/>
|
||||||
|
<PostArgs/>
|
||||||
|
<CPUset/>
|
||||||
|
<DonateText/>
|
||||||
|
<DonateLink/>
|
||||||
|
<Description>
|
||||||
|
Varken is a standalone command-line utility to aggregate data from the Plex ecosystem into InfluxDB. Examples use Grafana for a frontend
|
||||||
|
</Description>
|
||||||
|
<Networking>
|
||||||
|
<Mode>bridge</Mode>
|
||||||
|
<Publish/>
|
||||||
|
</Networking>
|
||||||
|
<Data>
|
||||||
|
<Volume>
|
||||||
|
<HostDir>/mnt/user/appdata/varken</HostDir>
|
||||||
|
<ContainerDir>/config</ContainerDir>
|
||||||
|
<Mode>rw</Mode>
|
||||||
|
</Volume>
|
||||||
|
</Data>
|
||||||
|
<Environment>
|
||||||
|
<Variable>
|
||||||
|
<Value>99</Value>
|
||||||
|
<Name>PGID</Name>
|
||||||
|
<Mode/>
|
||||||
|
</Variable>
|
||||||
|
<Variable>
|
||||||
|
<Value>100</Value>
|
||||||
|
<Name>PUID</Name>
|
||||||
|
<Mode/>
|
||||||
|
</Variable>
|
||||||
|
</Environment>
|
||||||
|
<Labels/>
|
||||||
|
<Config Name="PGID" Target="PGID" Default="" Mode="" Description="Container Variable: PGID" Type="Variable" Display="always" Required="true" Mask="false">99</Config>
|
||||||
|
<Config Name="PUID" Target="PUID" Default="" Mode="" Description="Container Variable: PUID" Type="Variable" Display="always" Required="true" Mask="false">100</Config>
|
||||||
|
<Config Name="Varken DataDir" Target="/config" Default="" Mode="rw" Description="Container Path: /config" Type="Path" Display="advanced-hide" Required="true" Mask="false">/mnt/user/appdata/varken</Config>
|
||||||
|
</Container>
|
|
@ -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)
|
self.logger.error("Could not find a USG named %s from your UniFi Controller", self.server.usg_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
influx_payload = [
|
try:
|
||||||
{
|
influx_payload = [
|
||||||
"measurement": "UniFi",
|
{
|
||||||
"tags": {
|
"measurement": "UniFi",
|
||||||
"model": device['model'],
|
"tags": {
|
||||||
"name": device['name']
|
"model": device['model'],
|
||||||
},
|
"name": device['name']
|
||||||
"time": now,
|
},
|
||||||
"fields": {
|
"time": now,
|
||||||
"bytes_current": device['wan1']['bytes-r'],
|
"fields": {
|
||||||
"rx_bytes_total": device['wan1']['rx_bytes'],
|
"bytes_current": device['wan1']['bytes-r'],
|
||||||
"rx_bytes_current": device['wan1']['rx_bytes-r'],
|
"rx_bytes_total": device['wan1']['rx_bytes'],
|
||||||
"tx_bytes_total": device['wan1']['tx_bytes'],
|
"rx_bytes_current": device['wan1']['rx_bytes-r'],
|
||||||
"tx_bytes_current": device['wan1']['tx_bytes-r'],
|
"tx_bytes_total": device['wan1']['tx_bytes'],
|
||||||
"speedtest_latency": device['speedtest-status']['latency'],
|
"tx_bytes_current": device['wan1']['tx_bytes-r'],
|
||||||
"speedtest_download": device['speedtest-status']['xput_download'],
|
# Commenting speedtest out until Unifi gets their shit together
|
||||||
"speedtest_upload": device['speedtest-status']['xput_upload'],
|
# "speedtest_latency": device['speedtest-status']['latency'],
|
||||||
"cpu_loadavg_1": device['sys_stats']['loadavg_1'],
|
# "speedtest_download": device['speedtest-status']['xput_download'],
|
||||||
"cpu_loadavg_5": device['sys_stats']['loadavg_5'],
|
# "speedtest_upload": device['speedtest-status']['xput_upload'],
|
||||||
"cpu_loadavg_15": device['sys_stats']['loadavg_15'],
|
"cpu_loadavg_1": device['sys_stats']['loadavg_1'],
|
||||||
"cpu_util": device['system-stats']['cpu'],
|
"cpu_loadavg_5": device['sys_stats']['loadavg_5'],
|
||||||
"mem_util": device['system-stats']['mem'],
|
"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)
|
||||||
|
|
Loading…
Reference in a new issue