apcupsd - Treat ONBATT status the same as ONLINE (#5435)
Chris Akritidis committed
Feb 20, 2019 at 20:15 UTC
459ab9d138f647530d922e2fce368022505d0e49
1 file changed
+8
-5
collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh
+8
-5
@@ -46,11 +46,14 @@ apcupsd_check() {
46
if [ $? -ne 0 ]; then
47
error "cannot get information for apcupsd server ${host} on ${apcupsd_sources[${host}]}."
48
failed=$((failed + 1))
49
- elif [ "$(apcupsd_get "${apcupsd_sources[${host}]}" | awk '/^STATUS.*/{ print $3 }')" != "ONLINE" ]; then
50
- error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online."
51
- failed=$((failed + 1))
49
else
53
- working=$((working + 1))
50
+ apcupsd_status = "$(apcupsd_get ${apcupsd_sources[${host}]} | awk '/^STATUS.*/{ print $3 }')"
51
+ if [ ${apcupsd_status} != "ONLINE" ] && [ ${apcupsd_status} != "ONBATT" ]; then
52
+ error "APC UPS ${host} on ${apcupsd_sources[${host}]} is not online."
53
+ failed=$((failed + 1))
54
+ else
55
+ working=$((working + 1))
56
+ fi
57
fi
58
done
59
@@ -143,7 +146,7 @@ BEGIN {
146
/^LOADPCT.*/ { load = \$3 * 100 };
147
/^ITEMP.*/ { temp = \$3 * 100 };
148
/^TIMELEFT.*/ { time = \$3 * 100 };
146
-/^STATUS.*/ { online=(\$3 == \"ONLINE\")?1:0 };
149
+/^STATUS.*/ { online=(\$3 == \"ONLINE\" || \$3 == \"ONBATT\")?1:0 };
150
END {
151
print \"BEGIN apcupsd_${host}.online $1\";
152
print \"SET online = \" online;