@cryptotaxi247 / netdata-1 / commits / 3d544df92

added NUT connected clients chart; fixes #1745

Costa Tsaousis (ktsaou) committed Feb 9, 2017 at 23:33 UTC 3d544df92b9e6f091063aedc435b4d5309f65f61
2 files changed +35 -2
charts.d/nut.chart.sh
+30 -1
@@ -2,7 +2,7 @@
2
3 # netdata
4 # real-time performance and health monitoring, done right!
5 -# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
5 +# (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>
6 # GPL v3+
7 #
8
@@ -13,8 +13,13 @@ nut_ups=
13 # how frequently to collect UPS data
14 nut_update_every=2
15
16 +# how much time in seconds, to wait for nut to respond
17 nut_timeout=2
18
19 +# set this to 1, to enable another chart showing the number
20 +# of UPS clients connected to upsd
21 +nut_clients_chart=0
22 +
23 # the priority of nut related to other charts
24 nut_priority=90000
25
@@ -26,6 +31,12 @@ nut_get_all() {
31
32 nut_get() {
33 run -t $nut_timeout upsc "$1"
34 +
35 + if [ "${nut_clients_chart}" -eq "1" ]
36 + then
37 + printf "ups.connected_clients: "
38 + run -t $nut_timeout upsc -c "$1" | wc -l
39 + fi
40 }
41
42 nut_check() {
@@ -97,6 +108,15 @@ DIMENSION load load absolute 1 100
108 CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 7)) $nut_update_every
109 DIMENSION temp temp absolute 1 100
110 EOF
111 +
112 + if [ "${nut_clients_chart}" = "1" ]
113 + then
114 + cat <<EOF2
115 +CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 8)) $nut_update_every
116 +DIMENSION clients '' absolute 1 1
117 +EOF2
118 + fi
119 +
120 done
121
122 return 0
@@ -131,6 +151,8 @@ BEGIN {
151 output_voltage = 0;
152 load = 0;
153 temp = 0;
154 + client = 0;
155 + do_clients = ${nut_clients_chart};
156 }
157 /^battery.charge: .*/ { battery_charge = \$2 * 100 };
158 /^battery.voltage: .*/ { battery_voltage = \$2 * 100 };
@@ -146,6 +168,7 @@ BEGIN {
168 /^output.voltage: .*/ { output_voltage = \$2 * 100 };
169 /^ups.load: .*/ { load = \$2 * 100 };
170 /^ups.temperature: .*/ { temp = \$2 * 100 };
171 +/^ups.connected_clients: .*/ { clients = \$2 };
172 END {
173 print \"BEGIN nut_$x.charge $1\";
174 print \"SET battery_charge = \" battery_charge;
@@ -184,6 +207,12 @@ END {
207 print \"BEGIN nut_$x.temp $1\";
208 print \"SET temp = \" temp;
209 print \"END\"
210 +
211 + if(do_clients) {
212 + print \"BEGIN nut_$x.clients $1\";
213 + print \"SET clients = \" clients;
214 + print \"END\"
215 + }
216 }"
217 [ $? -ne 0 ] && unset nut_ids[$i] && error "failed to get values for '$i', disabling it."
218 done
conf.d/charts.d/nut.conf
+5 -1
@@ -2,7 +2,7 @@
2
3 # netdata
4 # real-time performance and health monitoring, done right!
5 -# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
5 +# (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>
6 # GPL v3+
7
8 # a space separated list of UPS names
@@ -12,6 +12,10 @@
12 # how much time in seconds, to wait for nut to respond
13 #nut_timeout=2
14
15 +# set this to 1, to enable another chart showing the number
16 +# of UPS clients connected to upsd
17 +#nut_clients_chart=1
18 +
19 # the data collection frequency
20 # if unset, will inherit the netdata update frequency
21 #nut_update_every=2