From a8220ab2d293bb7f4b014b79d16b2fb05090fa93 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Feb 2021 12:45:55 +0100 Subject: Adding upstream version 1.29.0. Signed-off-by: Daniel Baumann --- collectors/charts.d.plugin/nut/README.md | 22 ++++- collectors/charts.d.plugin/nut/nut.chart.sh | 120 ++++++++++++++-------------- 2 files changed, 78 insertions(+), 64 deletions(-) (limited to 'collectors/charts.d.plugin/nut') diff --git a/collectors/charts.d.plugin/nut/README.md b/collectors/charts.d.plugin/nut/README.md index ea93318f8..3f9c5f0a2 100644 --- a/collectors/charts.d.plugin/nut/README.md +++ b/collectors/charts.d.plugin/nut/README.md @@ -1,6 +1,12 @@ -# nut + -The plugin will collect UPS data for all UPSes configured in the system. +# UPS/PDU monitoring with Netdata + +Collects UPS data for all power devices configured in the system. The following charts will be created: @@ -42,9 +48,17 @@ The following charts will be created: - current temperature -## configuration +## Configuration + +Edit the `charts.d/nut.conf` configuration file using `edit-config` from the Netdata [config +directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`. + +```bash +cd /etc/netdata # Replace this path with your Netdata config directory, if different +sudo ./edit-config charts.d/nut.conf +``` -This is the internal default for `/etc/netdata/nut.conf` +This is the internal default for `charts.d/nut.conf` ```sh # a space separated list of UPS names diff --git a/collectors/charts.d.plugin/nut/nut.chart.sh b/collectors/charts.d.plugin/nut/nut.chart.sh index 933d3561d..60233361e 100644 --- a/collectors/charts.d.plugin/nut/nut.chart.sh +++ b/collectors/charts.d.plugin/nut/nut.chart.sh @@ -28,59 +28,59 @@ declare -A nut_ids=() declare -A nut_names=() nut_get_all() { - run -t $nut_timeout upsc -l + run -t $nut_timeout upsc -l } nut_get() { - run -t $nut_timeout upsc "$1" + 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 + if [ "${nut_clients_chart}" -eq "1" ]; then + printf "ups.connected_clients: " + run -t $nut_timeout upsc -c "$1" | wc -l + fi } nut_check() { - # this should return: - # - 0 to enable the chart - # - 1 to disable the chart - - local x - - require_cmd upsc || return 1 - - [ -z "$nut_ups" ] && nut_ups="$(nut_get_all)" - - 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 "${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 - # shellcheck disable=SC2154 - error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf" - return 1 - fi - - return 0 + # this should return: + # - 0 to enable the chart + # - 1 to disable the chart + + local x + + require_cmd upsc || return 1 + + [ -z "$nut_ups" ] && nut_ups="$(nut_get_all)" + + for x in $nut_ups; do + nut_get "$x" > /dev/null + # shellcheck disable=SC2181 + if [ $? -eq 0 ]; then + if [ -n "${nut_names[${x}]}" ]; then + 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 + # shellcheck disable=SC2154 + error "Cannot find UPSes - please set nut_ups='ups_name' in $confd/nut.conf" + return 1 + fi + + return 0 } nut_create() { - # create the charts - local x + # create the charts + local x - for x in "${nut_ids[@]}"; do - cat <