add ability to alias nut UPS names
Kyle Lucy committed
Jun 25, 2018 at 23:34 UTC
ec0d897da8e8a25457156fe8a855f20d142bddfc
2 files changed
+12
-1
charts.d/nut.chart.sh
+7
-1
@@ -24,6 +24,7 @@ nut_clients_chart=0
24
nut_priority=90000
25
26
declare -A nut_ids=()
27
+declare -A nut_names=()
28
29
nut_get_all() {
30
run -t $nut_timeout upsc -l
@@ -56,7 +57,12 @@ nut_check() {
57
nut_get "$x" >/dev/null
58
if [ $? -eq 0 ]
59
then
59
- nut_ids[$x]="$( fixid "$x" )"
60
+ if [ ! -z "${nut_names[${x}]}" ]
61
+ then
62
+ nut_ids[$x]="$( fixid "${nut_names[${x}]}" )"
63
+ else
64
+ nut_ids[$x]="$( fixid "$x" )"
65
+ fi
66
continue
67
fi
68
error "cannot get information for NUT UPS '$x'."
conf.d/charts.d/nut.conf
+5
@@ -9,6 +9,11 @@
9
# if empty, the list returned by 'upsc -l' will be used
10
#nut_ups=
11
12
+# each line represents an alias for one UPS
13
+# if empty, the FQDN will be used
14
+#nut_names["FQDN1"]="alias"
15
+#nut_names["FQDN2"]="alias"
16
+
17
# how much time in seconds, to wait for nut to respond
18
#nut_timeout=2
19