@cryptotaxi247 / netdata-1 / commits / 2c995d962

Apcupsd selftest metric (#16286)

* add the apcupsd selftest chart * add an alarm for selftest failing * add selftest chart with each possible value being reported as 0/1 (inactive/active) * add a warning for SELFTEST code being BT or NG * Update health/health.d/apcupsd.conf Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud> * add reference for SELFTEST codes * rename fields * escape quotation marks in awk command * fix template on

thomasbeaudry committed Oct 30, 2023 at 09:33 UTC 2c995d96255d443866a1e13302723c203a1ada48
2 files changed +36 -2
collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh
+24 -2
@@ -112,6 +112,12 @@ DIMENSION time time absolute 1 100
112 CHART apcupsd_${host}.online '' "UPS ONLINE flag" "boolean" ups apcupsd.online line $((apcupsd_priority + 9)) $apcupsd_update_every '' '' 'apcupsd'
113 DIMENSION online online absolute 0 1
114
115 +CHART apcupsd_${host}.selftest '' "UPS Self-Test status" "status" ups apcupsd.selftest line $((apcupsd_priority + 10)) $apcupsd_update_every '' '' 'apcupsd'
116 +DIMENSION selftest_OK 'OK' absolute 0 1
117 +DIMENSION selftest_NO 'NO' absolute 0 1
118 +DIMENSION selftest_BT 'BT' absolute 0 1
119 +DIMENSION selftest_NG 'NG' absolute 0 1
120 +
121 EOF
122 done
123 return 0
@@ -138,12 +144,16 @@ BEGIN {
144 input_voltage_max = 0;
145 input_frequency = 0;
146 output_voltage = 0;
141 - output_voltage_nominal = 0;
147 + output_voltage_nominal = 0;
148 load = 0;
149 temp = 0;
150 time = 0;
151 nompower = 0;
152 load_usage = 0;
153 + selftest_OK = 0;
154 + selftest_NO = 0;
155 + selftest_BT = 0;
156 + selftest_NG = 0;
157 }
158 /^BCHARGE.*/ { battery_charge = \$3 * 100 };
159 /^BATTV.*/ { battery_voltage = \$3 * 100 };
@@ -158,7 +168,12 @@ BEGIN {
168 /^ITEMP.*/ { temp = \$3 * 100 };
169 /^NOMPOWER.*/ { nompower = \$3 };
170 /^TIMELEFT.*/ { time = \$3 * 100 };
161 -/^STATUS.*/ { online=(\$3 != \"COMMLOST\" && !(\$3 == \"SHUTTING\" && \$4 == \"DOWN\"))?1:0 };
171 +/^STATUS.*/ { online=(\$3 != \"COMMLOST\" && !(\$3 == \"SHUTTING\" && \$4 == \"DOWN\"))?1:0; };
172 +/^SELFTEST.*/ { selftest_OK = (\$3 == \"OK\") ? 1 : 0;
173 + selftest_NO = (\$3 == \"NO\") ? 1 : 0;
174 + selftest_BT = (\$3 == \"BT\") ? 1 : 0;
175 + selftest_NG = (\$3 == \"NG\") ? 1 : 0;
176 + };
177 END {
178 { load_usage = nompower * load / 100 };
179
@@ -206,6 +221,13 @@ END {
221 print \"BEGIN apcupsd_${host}.time $1\";
222 print \"SET time = \" time;
223 print \"END\"
224 +
225 + print \"BEGIN apcupsd_${host}.selftest $1\";
226 + print \"SET selftest_OK = \" selftest_OK;
227 + print \"SET selftest_NO = \" selftest_NO;
228 + print \"SET selftest_BT = \" selftest_BT;
229 + print \"SET selftest_NG = \" selftest_NG;
230 + print \"END\"
231 }
232 }"
233 # shellcheck disable=SC2181
health/health.d/apcupsd.conf
+12
@@ -48,3 +48,15 @@ component: UPS device
48 summary: APC UPS last collection
49 info: APC UPS number of seconds since the last successful data collection
50 to: sitemgr
51 +
52 +#Send out a warning when SELFTEST code is BT or NG. Code descriptions can be found at:
53 +#http://www.apcupsd.org/manual/#:~:text=or%20N/A.-,SELFTEST,-The%20results%20of
54 + template: apcupsd_selftest_warning
55 + on: apcupsd.selftest
56 + lookup: max -1s unaligned match-names of BT,NG
57 + units: status
58 + every: 10s
59 + warn: $this == 1
60 + delay: up 0 down 15m multiplier 1.5 max 1h
61 + info: APC UPS self-test failed due to insufficient battery capacity or due to overload.
62 + to: sitemgr