]> arthur.barton.de Git - netdata.git/commitdiff
added NUT connected clients chart; fixes #1745
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 9 Feb 2017 21:33:51 +0000 (23:33 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 9 Feb 2017 21:33:51 +0000 (23:33 +0200)
charts.d/nut.chart.sh
conf.d/charts.d/nut.conf

index e0b1b4cf981bedbb6e0a8de8c59cecb414d1c77d..6137639f982621277caa6fe21fce46133ef400eb 100644 (file)
@@ -2,7 +2,7 @@
 
 # netdata
 # real-time performance and health monitoring, done right!
-# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
+# (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>
 # GPL v3+
 #
 
@@ -13,8 +13,13 @@ nut_ups=
 # how frequently to collect UPS data
 nut_update_every=2
 
+# how much time in seconds, to wait for nut to respond
 nut_timeout=2
 
+# set this to 1, to enable another chart showing the number
+# of UPS clients connected to upsd
+nut_clients_chart=0
+
 # the priority of nut related to other charts
 nut_priority=90000
 
@@ -26,6 +31,12 @@ nut_get_all() {
 
 nut_get() {
        run -t $nut_timeout upsc "$1"
+
+       if [ "${nut_clients_chart}" -eq "1" ]
+               then
+               printf "ups.connected_clients: "
+               run -t $nut_timeout upsc -c "$1" | wc -l
+       fi
 }
 
 nut_check() {
@@ -97,6 +108,15 @@ DIMENSION load load absolute 1 100
 CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 7)) $nut_update_every
 DIMENSION temp temp absolute 1 100
 EOF
+
+       if [ "${nut_clients_chart}" = "1" ]
+               then
+               cat <<EOF2
+CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 8)) $nut_update_every
+DIMENSION clients '' absolute 1 1
+EOF2
+       fi
+
        done
 
        return 0
@@ -131,6 +151,8 @@ BEGIN {
        output_voltage = 0;
        load = 0;
        temp = 0;
+       client = 0;
+       do_clients = ${nut_clients_chart};
 }
 /^battery.charge: .*/                  { battery_charge = \$2 * 100 };
 /^battery.voltage: .*/                 { battery_voltage = \$2 * 100 };
@@ -146,6 +168,7 @@ BEGIN {
 /^output.voltage: .*/                  { output_voltage = \$2 * 100 };
 /^ups.load: .*/                                        { load = \$2 * 100 };
 /^ups.temperature: .*/                 { temp = \$2 * 100 };
+/^ups.connected_clients: .*/   { clients = \$2 };
 END {
        print \"BEGIN nut_$x.charge $1\";
        print \"SET battery_charge = \" battery_charge;
@@ -184,6 +207,12 @@ END {
        print \"BEGIN nut_$x.temp $1\";
        print \"SET temp = \" temp;
        print \"END\"
+
+       if(do_clients) {
+               print \"BEGIN nut_$x.clients $1\";
+               print \"SET clients = \" clients;
+               print \"END\"
+       }
 }"
                [ $? -ne 0 ] && unset nut_ids[$i] && error "failed to get values for '$i', disabling it."
        done
index 2844849de0fbfc2622a3b11dd4b7c494ea30e04f..a836692d89cb134a0fabb68a18e59954233fbfb3 100644 (file)
@@ -2,7 +2,7 @@
 
 # netdata
 # real-time performance and health monitoring, done right!
-# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
+# (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>
 # GPL v3+
 
 # a space separated list of UPS names
 # how much time in seconds, to wait for nut to respond
 #nut_timeout=2
 
+# set this to 1, to enable another chart showing the number
+# of UPS clients connected to upsd
+#nut_clients_chart=1
+
 # the data collection frequency
 # if unset, will inherit the netdata update frequency
 #nut_update_every=2