Initial commit
This commit is contained in:
commit
33882d5455
13 files changed
+543
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
|
||||
IFS=':'
|
||||
|
||||
while read -a line; do
|
||||
# Clear out extra spaces
|
||||
key=$(tr -d ' ' <<< ${line[0]})
|
||||
val=${line[1]## }
|
||||
val_num=$(grep -Eo '[0-9.]+' <<< $val)
|
||||
|
||||
case $key in
|
||||
MODEL)
|
||||
gmetric --name="ups_model" --value="$val" --type=string --group=ups --title="UPS model"
|
||||
;;
|
||||
LINEV)
|
||||
gmetric --name="ups_line_voltage" --value="$val_num" --units="V" --type=float --group=ups --title="UPS line voltage"
|
||||
;;
|
||||
LOADPCT)
|
||||
gmetric --name="ups_load_percent" --value="$val_num" --units="%" --type=float --group=ups --title="UPS load"
|
||||
loadpct=$(tr -d '.' <<< $val_num) # Strip out decimals for bash's integer math (should now be in thousandths, for accuracy in case there is a decimal)
|
||||
;;
|
||||
BCHARGE)
|
||||
gmetric --name="ups_battery_charge" --value="$val_num" --units="%" --type=float --group=ups --title="UPS battery charge"
|
||||
;;
|
||||
TIMELEFT)
|
||||
gmetric --name="ups_time_left" --value="$val_num" --units="min" --type=float --group=ups --title="UPS time left"
|
||||
;;
|
||||
BATTV)
|
||||
gmetric --name="ups_battery_voltage" --value="$val_num" --units="V" --type=float --group=ups --title="UPS battery voltage"
|
||||
;;
|
||||
TONBATT)
|
||||
gmetric --name="ups_time_on_battery" --value="$val_num" --units="s" --type=uint32 --group=ups --title="UPS time on battery"
|
||||
;;
|
||||
BATTDATE)
|
||||
gmetric --name="ups_battery_date" --value="$val" --type=string --group=ups --title="UPS battery date"
|
||||
;;
|
||||
NOMPOWER)
|
||||
nompower=$val_num
|
||||
;;
|
||||
esac
|
||||
done <<< $(/usr/sbin/apcaccess)
|
||||
|
||||
# Calculate load in watts
|
||||
load_watts=$(( ($loadpct * $nompower) / 1000 ))
|
||||
gmetric --name="ups_load" --value="$load_watts" --units="W" --type=float --group=ups --title="UPS load"
|
||||
Reference in new issue
Block a user