Last active
March 23, 2020 01:46
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# what is this? poll your UPS using "upsc" and store values using InfluxDB for use with Grafana | |
# unRAID UPS plugin; https://forums.unraid.net/topic/60217-plugin-nut-v2-network-ups-tools/ | |
# unRAID CA User Scripts; plugin https://forums.unraid.net/topic/48286-plugin-ca-user-scripts/ | |
# unRAID User Scripts; add script, custom schedule = */1 * * * * | |
command="upsc ups" | |
influxdb="ups,host=Tower" | |
curlargs="-s --output /dev/null -i -XPOST --data-binary" | |
url="http://10.0.20.20:8086/write?db=telegraf" | |
array=( | |
battery.charge | |
battery.runtime | |
device.model | |
output.voltage | |
ups.load | |
ups.realpower.nominal | |
) | |
for i in "${array[@]}" | |
do | |
output=$($command $i) | |
data="$influxdb $i=$output" | |
# echo "curlcmd=(curl $curlargs "$data" "$url")" | |
curlcmd=$(curl $curlargs "$data" "$url") | |
if [[ $i = "ups.realpower.nominal" ]]; then | |
ups_realpower_nominal="$output" | |
fi | |
if [[ $i = "ups.load" ]]; then | |
ups_load="$output" | |
fi | |
done | |
ups_realpower=$(($ups_load * $ups_realpower_nominal / 100)) | |
data="$influxdb ups.realpower=$ups_realpower" | |
# echo "curlcmd=(curl $curlargs "$data" "$url")" | |
curlcmd=$(curl $curlargs "$data" "$url") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment