Skip to content

Commit

Permalink
Merge pull request #2 from dbsqp/dev
Browse files Browse the repository at this point in the history
Dev > Master
  • Loading branch information
dbsqp authored Apr 24, 2021
2 parents c1b205b + 42dbb18 commit a3717db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is a docker container that pulls data from a NUT server and pushed to InfluxDB. Based on work of mihai-cindea [https://github.com/mihai-cindea/nut-influxdb-exporter)

## Changes
Updated for InfluxDBv2. Changed outputted values. Poll multiple NUT servers.
Updated for InfluxDBv2. Changed outputted values. Poll multiple NUT servers. Poll internal batteries on MacOS using the NUT macosx-ups driver.

## Roadmap

Expand Down
17 changes: 14 additions & 3 deletions nut-influxdbv2-exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@

# Other vars
debug_str = os.getenv('DEBUG', 'false')
remove_keys = ['battery.type','device.serial','ups.realpower.nominal','ups.vendorid','ups.serial','ups.productid','ups.model','ups.mfr','driver.version.data','driver.version','device.type','device.mfr', 'driver.version.internal', 'driver.version.usb', 'ups.beeper.status', 'driver.name', 'battery.mfr.date','ups.firmware', 'ups.firmware.aux','ups.mfr.date', 'battery.date', 'battery.charge.low', 'battery.charge.warning', 'battery.runtime.low','driver.parameter.pollfreq','driver.parameter.pollinterval','driver.parameter.port','input.sensitivity','input.transfer.high','input.transfer.low','ups.delay.shutdown','ups.test.result','ups.timer.reboot','ups.timer.shutdown']
remove_keys = ['battery.type','device.serial','ups.realpower.nominal','ups.vendorid','ups.serial','ups.productid',
'ups.model','ups.mfr','driver.version.data','driver.version','device.type','device.mfr',
'driver.version.internal', 'driver.version.usb', 'ups.beeper.status', 'driver.name', 'battery.mfr.date',
'ups.firmware', 'ups.firmware.aux','ups.mfr.date', 'battery.date', 'battery.charge.low',
'battery.charge.warning', 'battery.runtime.low','driver.parameter.pollfreq','driver.parameter.pollinterval',
'driver.parameter.port','input.sensitivity','input.transfer.high','input.transfer.low','ups.delay.shutdown',
'ups.test.result','ups.timer.reboot','ups.timer.shutdown','driver.parameter.synchronous']

# InfluxDBv2 variables
influxdb2_host=os.getenv('INFLUXDB2_HOST', "localhost")
Expand Down Expand Up @@ -93,9 +99,14 @@ def construct_object(data, remove_keys, host):

for k, v in data.items():
if k == "ups.serial":
tags["hardware"]=':'.join(v[i:i+2] for i in range(0,12,2))
if v:
tags["hardware"]=':'.join(v[i:i+2] for i in range(0,12,2))
elif k == "device.model":
tags["model"]=v.strip()
w = v.split("FW:", 2)
if v == "InternalBattery-0":
tags["model"]="InternalBattery"
else:
tags["model"]=w[0].strip()
else:
if k in remove_keys:
continue
Expand Down

0 comments on commit a3717db

Please sign in to comment.