diff options
Diffstat (limited to '')
-rw-r--r-- | collectors/charts.d.plugin/nut/Makefile.inc | 13 | ||||
-rw-r--r-- | collectors/charts.d.plugin/nut/README.md | 59 | ||||
-rw-r--r-- | collectors/charts.d.plugin/nut/nut.chart.sh (renamed from charts.d/nut.chart.sh) | 41 | ||||
-rw-r--r-- | collectors/charts.d.plugin/nut/nut.conf (renamed from conf.d/charts.d/nut.conf) | 5 |
4 files changed, 107 insertions, 11 deletions
diff --git a/collectors/charts.d.plugin/nut/Makefile.inc b/collectors/charts.d.plugin/nut/Makefile.inc new file mode 100644 index 000000000..4fb47145d --- /dev/null +++ b/collectors/charts.d.plugin/nut/Makefile.inc @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-3.0-or-later + +# THIS IS NOT A COMPLETE Makefile +# IT IS INCLUDED BY ITS PARENT'S Makefile.am +# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT + +# install these files +dist_charts_DATA += nut/nut.chart.sh +dist_chartsconfig_DATA += nut/nut.conf + +# do not install these files, but include them in the distribution +dist_noinst_DATA += nut/README.md nut/Makefile.inc + diff --git a/collectors/charts.d.plugin/nut/README.md b/collectors/charts.d.plugin/nut/README.md new file mode 100644 index 000000000..71906f55a --- /dev/null +++ b/collectors/charts.d.plugin/nut/README.md @@ -0,0 +1,59 @@ +# nut + +The plugin will collect UPS data for all UPSes configured in the system. + +The following charts will be created: + +1. **UPS Charge** + + * percentage changed + +2. **UPS Battery Voltage** + + * current voltage + * high voltage + * low voltage + * nominal voltage + +3. **UPS Input Voltage** + + * current voltage + * fault voltage + * nominal voltage + +4. **UPS Input Current** + + * nominal current + +5. **UPS Input Frequency** + + * current frequency + * nominal frequency + +6. **UPS Output Voltage** + + * current voltage + +7. **UPS Load** + + * current load + +8. **UPS Temperature** + + * current temperature + + +### configuration + +This is the internal default for `/etc/netdata/nut.conf` + +```sh +# a space separated list of UPS names +# if empty, the list returned by 'upsc -l' will be used +nut_ups= + +# how frequently to collect UPS data +nut_update_every=2 +``` + +--- diff --git a/charts.d/nut.chart.sh b/collectors/charts.d.plugin/nut/nut.chart.sh index 6137639f9..7e252f325 100644 --- a/charts.d/nut.chart.sh +++ b/collectors/charts.d.plugin/nut/nut.chart.sh @@ -1,9 +1,10 @@ +# shellcheck shell=bash # no need for shebang - this file is loaded from charts.d.plugin +# SPDX-License-Identifier: GPL-3.0-or-later # netdata # real-time performance and health monitoring, done right! # (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr> -# GPL v3+ # # a space separated list of UPS names @@ -24,6 +25,7 @@ nut_clients_chart=0 nut_priority=90000 declare -A nut_ids=() +declare -A nut_names=() nut_get_all() { run -t $nut_timeout upsc -l @@ -54,16 +56,23 @@ nut_check() { for x in $nut_ups do nut_get "$x" >/dev/null + # shellcheck disable=SC2181 if [ $? -eq 0 ] + then + if [ ! -z "${nut_names[${x}]}" ] then - nut_ids[$x]="$( fixid "$x" )" + nut_ids[$x]="$( fixid "${nut_names[${x}]}" )" + else + nut_ids[$x]="$( fixid "$x" )" + fi continue fi error "cannot get information for NUT UPS '$x'." done if [ ${#nut_ids[@]} -eq 0 ] - then + then + # shellcheck disable=SC2154 error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf" return 1 fi @@ -81,38 +90,41 @@ nut_create() { CHART nut_$x.charge '' "UPS Charge" "percentage" ups nut.charge area $((nut_priority + 1)) $nut_update_every DIMENSION battery_charge charge absolute 1 100 -CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 2)) $nut_update_every +CHART nut_$x.runtime '' "UPS Runtime" "seconds" ups nut.runtime area $((nut_priority + 2)) $nut_update_every +DIMENSION battery_runtime runtime absolute 1 100 + +CHART nut_$x.battery_voltage '' "UPS Battery Voltage" "Volts" ups nut.battery.voltage line $((nut_priority + 3)) $nut_update_every DIMENSION battery_voltage voltage absolute 1 100 DIMENSION battery_voltage_high high absolute 1 100 DIMENSION battery_voltage_low low absolute 1 100 DIMENSION battery_voltage_nominal nominal absolute 1 100 -CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 3)) $nut_update_every +CHART nut_$x.input_voltage '' "UPS Input Voltage" "Volts" input nut.input.voltage line $((nut_priority + 4)) $nut_update_every DIMENSION input_voltage voltage absolute 1 100 DIMENSION input_voltage_fault fault absolute 1 100 DIMENSION input_voltage_nominal nominal absolute 1 100 -CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 4)) $nut_update_every +CHART nut_$x.input_current '' "UPS Input Current" "Ampere" input nut.input.current line $((nut_priority + 5)) $nut_update_every DIMENSION input_current_nominal nominal absolute 1 100 -CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 5)) $nut_update_every +CHART nut_$x.input_frequency '' "UPS Input Frequency" "Hz" input nut.input.frequency line $((nut_priority + 6)) $nut_update_every DIMENSION input_frequency frequency absolute 1 100 DIMENSION input_frequency_nominal nominal absolute 1 100 -CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 6)) $nut_update_every +CHART nut_$x.output_voltage '' "UPS Output Voltage" "Volts" output nut.output.voltage line $((nut_priority + 7)) $nut_update_every DIMENSION output_voltage voltage absolute 1 100 CHART nut_$x.load '' "UPS Load" "percentage" ups nut.load area $((nut_priority)) $nut_update_every DIMENSION load load absolute 1 100 -CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 7)) $nut_update_every +CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $((nut_priority + 8)) $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 +CHART nut_$x.clients '' "UPS Connected Clients" "clients" ups nut.clients area $((nut_priority + 9)) $nut_update_every DIMENSION clients '' absolute 1 1 EOF2 fi @@ -138,6 +150,7 @@ nut_update() { nut_get "$i" | awk " BEGIN { battery_charge = 0; + battery_runtime = 0; battery_voltage = 0; battery_voltage_high = 0; battery_voltage_low = 0; @@ -155,6 +168,7 @@ BEGIN { do_clients = ${nut_clients_chart}; } /^battery.charge: .*/ { battery_charge = \$2 * 100 }; +/^battery.runtime: .*/ { battery_runtime = \$2 * 100 }; /^battery.voltage: .*/ { battery_voltage = \$2 * 100 }; /^battery.voltage.high: .*/ { battery_voltage_high = \$2 * 100 }; /^battery.voltage.low: .*/ { battery_voltage_low = \$2 * 100 }; @@ -174,6 +188,10 @@ END { print \"SET battery_charge = \" battery_charge; print \"END\" + print \"BEGIN nut_$x.runtime $1\"; + print \"SET battery_runtime = \" battery_runtime; + print \"END\" + print \"BEGIN nut_$x.battery_voltage $1\"; print \"SET battery_voltage = \" battery_voltage; print \"SET battery_voltage_high = \" battery_voltage_high; @@ -214,7 +232,8 @@ END { print \"END\" } }" - [ $? -ne 0 ] && unset nut_ids[$i] && error "failed to get values for '$i', disabling it." + # shellcheck disable=2181 + [ $? -ne 0 ] && unset "nut_ids[$i]" && error "failed to get values for '$i', disabling it." done [ ${#nut_ids[@]} -eq 0 ] && error "no UPSes left active." && return 1 diff --git a/conf.d/charts.d/nut.conf b/collectors/charts.d.plugin/nut/nut.conf index d477ddd34..b95ad9048 100644 --- a/conf.d/charts.d/nut.conf +++ b/collectors/charts.d.plugin/nut/nut.conf @@ -9,6 +9,11 @@ # if empty, the list returned by 'upsc -l' will be used #nut_ups= +# each line represents an alias for one UPS +# if empty, the FQDN will be used +#nut_names["FQDN1"]="alias" +#nut_names["FQDN2"]="alias" + # how much time in seconds, to wait for nut to respond #nut_timeout=2 |