aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/munin-common/files/patch-plugins_node.d_nutups__.in
blob: c07217d13b7abaeb10acc88f6116b9c673a3be87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Allow overriding some variables.

--- plugins/node.d/nutups_.in.orig	2018-07-24 11:34:38 UTC
+++ plugins/node.d/nutups_.in
@@ -7,21 +7,25 @@
 #
 # usage: nutups_upsid_function
 #
+#   env.upsc    <command>   (default: "/bin/upsc")
+#   env.upsconf <filename>  (default: "/etc/nut/ups.conf")
+#
 #%# family=contrib
 #%# capabilities=autoconf suggest
 
 UPS=$(basename "$0" | cut -d_ -f2)
 FUNCTION=$(basename "$0" | cut -d_ -f3)
 UPSC=$(command -v upsc)
+UPSCONF=${upsconf:-/etc/nut/ups.conf}
 
 if [ "$1" = "autoconf" ]; then
-	[ -x "$UPSC" ] && [ -r /etc/nut/ups.conf ] && echo yes && exit 0
-	echo "no (upsc or /etc/nut/ups.conf not found)"
+	[ -x "$UPSC" ] && [ -r "$UPSCONF" ] && echo yes && exit 0
+	echo "no ($UPSC or $UPSCONF not found)"
 	exit 0
 fi
 
 if [ "$1" = "suggest" ]; then
-	grep '^\[[^]]*\]$' /etc/nut/ups.conf \
+	grep '^\[[^]]*\]$' "$UPSCONF" \
 		| tr -d '][' \
 		| while read -r ups; do
 			for i in voltages freq charge current; do