feat(charts.d/apcupds): add load usage chart (Watts) (#12965)
Ilya Mashchenko committed
May 20, 2022 at 16:00 UTC
2104bf90c4be8d66a490f372d1ed7f3caf0b04b5
1 file changed
+22
-12
collectors/charts.d.plugin/apcupsd/apcupsd.chart.sh
+22
-12
@@ -74,41 +74,42 @@ apcupsd_check() {
74
}
75
76
apcupsd_create() {
77
- local host src
77
+ local host
78
for host in "${!apcupsd_sources[@]}"; do
79
- src=${apcupsd_sources[${host}]}
80
-
79
# create the charts
80
cat << EOF
83
-CHART apcupsd_${host}.charge '' "UPS Charge for ${host} on ${src}" "percentage" ups apcupsd.charge area $((apcupsd_priority + 1)) $apcupsd_update_every '' '' 'apcupsd'
81
+CHART apcupsd_${host}.charge '' "UPS Charge" "percentage" ups apcupsd.charge area $((apcupsd_priority + 2)) $apcupsd_update_every '' '' 'apcupsd'
82
DIMENSION battery_charge charge absolute 1 100
83
86
-CHART apcupsd_${host}.battery_voltage '' "UPS Battery Voltage for ${host} on ${src}" "Volts" ups apcupsd.battery.voltage line $((apcupsd_priority + 3)) $apcupsd_update_every '' '' 'apcupsd'
84
+CHART apcupsd_${host}.battery_voltage '' "UPS Battery Voltage" "Volts" ups apcupsd.battery.voltage line $((apcupsd_priority + 4)) $apcupsd_update_every '' '' 'apcupsd'
85
DIMENSION battery_voltage voltage absolute 1 100
86
DIMENSION battery_voltage_nominal nominal absolute 1 100
87
90
-CHART apcupsd_${host}.input_voltage '' "UPS Input Voltage for ${host} on ${src}" "Volts" input apcupsd.input.voltage line $((apcupsd_priority + 4)) $apcupsd_update_every '' '' 'apcupsd'
88
+CHART apcupsd_${host}.input_voltage '' "UPS Input Voltage" "Volts" input apcupsd.input.voltage line $((apcupsd_priority + 5)) $apcupsd_update_every '' '' 'apcupsd'
89
DIMENSION input_voltage voltage absolute 1 100
90
DIMENSION input_voltage_min min absolute 1 100
91
DIMENSION input_voltage_max max absolute 1 100
92
95
-CHART apcupsd_${host}.input_frequency '' "UPS Input Frequency for ${host} on ${src}" "Hz" input apcupsd.input.frequency line $((apcupsd_priority + 5)) $apcupsd_update_every '' '' 'apcupsd'
93
+CHART apcupsd_${host}.input_frequency '' "UPS Input Frequency" "Hz" input apcupsd.input.frequency line $((apcupsd_priority + 6)) $apcupsd_update_every '' '' 'apcupsd'
94
DIMENSION input_frequency frequency absolute 1 100
95
98
-CHART apcupsd_${host}.output_voltage '' "UPS Output Voltage for ${host} on ${src}" "Volts" output apcupsd.output.voltage line $((apcupsd_priority + 6)) $apcupsd_update_every '' '' 'apcupsd'
96
+CHART apcupsd_${host}.output_voltage '' "UPS Output Voltage" "Volts" output apcupsd.output.voltage line $((apcupsd_priority + 7)) $apcupsd_update_every '' '' 'apcupsd'
97
DIMENSION output_voltage voltage absolute 1 100
98
DIMENSION output_voltage_nominal nominal absolute 1 100
99
102
-CHART apcupsd_${host}.load '' "UPS Load for ${host} on ${src}" "percentage" ups apcupsd.load area $((apcupsd_priority)) $apcupsd_update_every '' '' 'apcupsd'
100
+CHART apcupsd_${host}.load '' "UPS Load" "percentage" ups apcupsd.load area $((apcupsd_priority)) $apcupsd_update_every '' '' 'apcupsd'
101
DIMENSION load load absolute 1 100
102
105
-CHART apcupsd_${host}.temp '' "UPS Temperature for ${host} on ${src}" "Celsius" ups apcupsd.temperature line $((apcupsd_priority + 7)) $apcupsd_update_every '' '' 'apcupsd'
103
+CHART apcupsd_${host}.load_usage '' "UPS Load Usage" "Watts" ups apcupsd.load_usage area $((apcupsd_priority + 1)) $apcupsd_update_every '' '' 'apcupsd'
104
+DIMENSION load_usage load absolute 1 100
105
+
106
+CHART apcupsd_${host}.temp '' "UPS Temperature" "Celsius" ups apcupsd.temperature line $((apcupsd_priority + 8)) $apcupsd_update_every '' '' 'apcupsd'
107
DIMENSION temp temp absolute 1 100
108
108
-CHART apcupsd_${host}.time '' "UPS Time Remaining for ${host} on ${src}" "Minutes" ups apcupsd.time area $((apcupsd_priority + 2)) $apcupsd_update_every '' '' 'apcupsd'
109
+CHART apcupsd_${host}.time '' "UPS Time Remaining" "Minutes" ups apcupsd.time area $((apcupsd_priority + 3)) $apcupsd_update_every '' '' 'apcupsd'
110
DIMENSION time time absolute 1 100
111
111
-CHART apcupsd_${host}.online '' "UPS ONLINE flag for ${host} on ${src}" "boolean" ups apcupsd.online line $((apcupsd_priority + 8)) $apcupsd_update_every '' '' 'apcupsd'
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
EOF
@@ -141,6 +142,8 @@ BEGIN {
142
load = 0;
143
temp = 0;
144
time = 0;
145
+ nompower = 0;
146
+ load_usage = 0;
147
}
148
/^BCHARGE.*/ { battery_charge = \$3 * 100 };
149
/^BATTV.*/ { battery_voltage = \$3 * 100 };
@@ -153,9 +156,12 @@ BEGIN {
156
/^NOMOUTV.*/ { output_voltage_nominal = \$3 * 100 };
157
/^LOADPCT.*/ { load = \$3 * 100 };
158
/^ITEMP.*/ { temp = \$3 * 100 };
159
+/^NOMPOWER.*/ { nompower = \$3 };
160
/^TIMELEFT.*/ { time = \$3 * 100 };
161
/^STATUS.*/ { online=(\$3 != \"COMMLOST\" && !(\$3 == \"SHUTTING\" && \$4 == \"DOWN\"))?1:0 };
162
END {
163
+ { load_usage = nompower * load / 100 };
164
+
165
print \"BEGIN apcupsd_${host}.online $1\";
166
print \"SET online = \" online;
167
print \"END\"
@@ -189,6 +195,10 @@ END {
195
print \"SET load = \" load;
196
print \"END\"
197
198
+ print \"BEGIN apcupsd_${host}.load_usage $1\";
199
+ print \"SET load_usage = \" load_usage;
200
+ print \"END\"
201
+
202
print \"BEGIN apcupsd_${host}.temp $1\";
203
print \"SET temp = \" temp;
204
print \"END\"