@cryptotaxi247 / netdata-1 / commits / caf18920a

feat(charts.d): add load usage (Watts) to nuts collector (#14407)

Fixes https://github.com/netdata/netdata/issues/14396

Ilya Mashchenko committed Feb 2, 2023 at 11:03 UTC caf18920aac38eed782647957e82c0ab7f64ec17
1 file changed +24 -12
collectors/charts.d.plugin/nut/nut.chart.sh
+24 -12
@@ -81,43 +81,46 @@ nut_create() {
81
82 for x in "${nut_ids[@]}"; do
83 cat << EOF
84 -CHART nut_$x.charge '' "UPS Charge" "percentage" ups nut.charge area $((nut_priority + 1)) $nut_update_every
84 +CHART nut_$x.charge '' "UPS Charge" "percentage" ups nut.charge area $((nut_priority + 2)) $nut_update_every
85 DIMENSION battery_charge charge absolute 1 100
86
87 -CHART nut_$x.runtime '' "UPS Runtime" "seconds" ups nut.runtime area $((nut_priority + 2)) $nut_update_every
87 +CHART nut_$x.runtime '' "UPS Runtime" "seconds" ups nut.runtime area $((nut_priority + 3)) $nut_update_every
88 DIMENSION battery_runtime runtime absolute 1 100
89
90 -CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 3)) $nut_update_every
90 +CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 4)) $nut_update_every
91 DIMENSION battery_voltage voltage absolute 1 100
92 DIMENSION battery_voltage_high high absolute 1 100
93 DIMENSION battery_voltage_low low absolute 1 100
94 DIMENSION battery_voltage_nominal nominal absolute 1 100
95
96 -CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 4)) $nut_update_every
96 +CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 5)) $nut_update_every
97 DIMENSION input_voltage voltage absolute 1 100
98 DIMENSION input_voltage_fault fault absolute 1 100
99 DIMENSION input_voltage_nominal nominal absolute 1 100
100
101 -CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 5)) $nut_update_every
101 +CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 6)) $nut_update_every
102 DIMENSION input_current_nominal nominal absolute 1 100
103
104 -CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 6)) $nut_update_every
104 +CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 7)) $nut_update_every
105 DIMENSION input_frequency frequency absolute 1 100
106 DIMENSION input_frequency_nominal nominal absolute 1 100
107
108 -CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 7)) $nut_update_every
108 +CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 8)) $nut_update_every
109 DIMENSION output_voltage voltage absolute 1 100
110
111 CHART nut_$x.load '' "UPS Load" "percentage" ups nut.load area $((nut_priority)) $nut_update_every
112 DIMENSION load load absolute 1 100
113
114 -CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 8)) $nut_update_every
114 +CHART nut_$x.load_usage '' "UPS Load Usage" "Watts" ups nut.load_usage area $((nut_priority + 1)) $nut_update_every
115 +DIMENSION load_usage load_usage absolute 1 100
116 +
117 +CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 9)) $nut_update_every
118 DIMENSION temp temp absolute 1 100
119 EOF
120
121 if [ "${nut_clients_chart}" = "1" ]; then
122 cat << EOF2
120 -CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 9)) $nut_update_every
123 +CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 10)) $nut_update_every
124 DIMENSION clients '' absolute 1 1
125 EOF2
126 fi
@@ -154,6 +157,8 @@ BEGIN {
157 input_frequency_nominal = 0;
158 output_voltage = 0;
159 load = 0;
160 + load_usage = 0;
161 + nompower = 0;
162 temp = 0;
163 client = 0;
164 do_clients = ${nut_clients_chart};
@@ -172,16 +177,19 @@ BEGIN {
177 /^input.frequency.nominal: .*/ { input_frequency_nominal = \$2 * 100 };
178 /^output.voltage: .*/ { output_voltage = \$2 * 100 };
179 /^ups.load: .*/ { load = \$2 * 100 };
180 +/^ups.realpower.nominal: .*/ { nompower = \$2 };
181 /^ups.temperature: .*/ { temp = \$2 * 100 };
182 /^ups.connected_clients: .*/ { clients = \$2 };
183 END {
184 + { load_usage = nompower * load / 100 };
185 +
186 print \"BEGIN nut_$x.charge $1\";
187 print \"SET battery_charge = \" battery_charge;
188 print \"END\"
189
182 - print \"BEGIN nut_$x.runtime $1\";
183 - print \"SET battery_runtime = \" battery_runtime;
184 - print \"END\"
190 + print \"BEGIN nut_$x.runtime $1\";
191 + print \"SET battery_runtime = \" battery_runtime;
192 + print \"END\"
193
194 print \"BEGIN nut_$x.battery_voltage $1\";
195 print \"SET battery_voltage = \" battery_voltage;
@@ -213,6 +221,10 @@ END {
221 print \"SET load = \" load;
222 print \"END\"
223
224 + print \"BEGIN nut_$x.load_usage $1\";
225 + print \"SET load_usage = \" load_usage;
226 + print \"END\"
227 +
228 print \"BEGIN nut_$x.temp $1\";
229 print \"SET temp = \" temp;
230 print \"END\"