summaryrefslogtreecommitdiffstats
path: root/collectors/charts.d.plugin/nut
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-02-07 11:45:55 +0000
commita8220ab2d293bb7f4b014b79d16b2fb05090fa93 (patch)
tree77f0a30f016c0925cf7ee9292e644bba183c2774 /collectors/charts.d.plugin/nut
parentAdding upstream version 1.19.0. (diff)
downloadnetdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.tar.xz
netdata-a8220ab2d293bb7f4b014b79d16b2fb05090fa93.zip
Adding upstream version 1.29.0.upstream/1.29.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/charts.d.plugin/nut')
-rw-r--r--collectors/charts.d.plugin/nut/README.md22
-rw-r--r--collectors/charts.d.plugin/nut/nut.chart.sh120
2 files changed, 78 insertions, 64 deletions
diff --git a/collectors/charts.d.plugin/nut/README.md b/collectors/charts.d.plugin/nut/README.md
index ea93318f..3f9c5f0a 100644
--- a/collectors/charts.d.plugin/nut/README.md
+++ b/collectors/charts.d.plugin/nut/README.md
@@ -1,6 +1,12 @@
-# nut
+<!--
+title: "UPS/PDU monitoring with Netdata"
+custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/charts.d.plugin/nut/README.md
+sidebar_label: "UPS/PDU"
+-->
-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 933d3561..60233361 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 <<EOF
+ for x in "${nut_ids[@]}"; do
+ cat << EOF
CHART nut_$x.charge '' "UPS Charge" "percentage" ups nut.charge area $((nut_priority + 1)) $nut_update_every
DIMENSION battery_charge charge absolute 1 100
@@ -115,30 +115,30 @@ CHART nut_$x.temp '' "UPS Temperature" "temperature" ups nut.temperature line $(
DIMENSION temp temp absolute 1 100
EOF
- if [ "${nut_clients_chart}" = "1" ]; then
- cat <<EOF2
+ if [ "${nut_clients_chart}" = "1" ]; then
+ cat << EOF2
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
+ fi
- done
+ done
- return 0
+ return 0
}
nut_update() {
- # the first argument to this function is the microseconds since last update
- # pass this parameter to the BEGIN statement (see bellow).
+ # the first argument to this function is the microseconds since last update
+ # pass this parameter to the BEGIN statement (see bellow).
- # do all the work to collect / calculate the values
- # for each dimension
- # remember: KEEP IT SIMPLE AND SHORT
+ # do all the work to collect / calculate the values
+ # for each dimension
+ # remember: KEEP IT SIMPLE AND SHORT
- local i x
- for i in "${!nut_ids[@]}"; do
- x="${nut_ids[$i]}"
- nut_get "$i" | awk "
+ local i x
+ for i in "${!nut_ids[@]}"; do
+ x="${nut_ids[$i]}"
+ nut_get "$i" | awk "
BEGIN {
battery_charge = 0;
battery_runtime = 0;
@@ -223,10 +223,10 @@ END {
print \"END\"
}
}"
- # shellcheck disable=2181
- [ $? -ne 0 ] && unset "nut_ids[$i]" && error "failed to get values for '$i', disabling it."
- done
+ # 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
- return 0
+ [ ${#nut_ids[@]} -eq 0 ] && error "no UPSes left active." && return 1
+ return 0
}