ports/sysutils/munin-common/files/patch-plugins_node.d_nutups__.in
Mathieu Arnold 2ff6de7ee9 Fix the bind9_rndc plugin wrt Perl 5.18+ hash randomzation.
While there, group all patches for the three ports in munin-common, and remove
an obsolete patch.

PR:		195689
Submitted by:	Vlad "Blackflow" K.
Sponsored by:	Absolight
2014-12-10 15:52:14 +00:00

67 lines
1.7 KiB
Text

--- plugins/node.d/nutups_.in.orig 2014-11-24 21:46:24 UTC
+++ plugins/node.d/nutups_.in
@@ -7,20 +7,25 @@
#
# usage: ups_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=${upsc:-/bin/upsc}
+UPSCONF=${upsconf:-/etc/nut/ups.conf}
if [ "$1" = "autoconf" ]; then
- [ -x /bin/upsc ] && [ -r /etc/nut/ups.conf ] && echo yes && exit 0
- echo "no (/bin/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 ups; do
for i in voltages freq charge current; do
@@ -42,7 +47,7 @@ voltages() {
echo "${i}.min 0"
done
else
- upsc $UPS | sed -n '/volt/{
+ $UPSC $UPS | sed -n '/volt/{
s/://
/nominal/s/.* /nominal.value /
/voltage/s/\.[^ ]*/.value/
@@ -64,7 +69,7 @@ charge() {
echo "${i}.min 0"
done
else
- upsc $UPS | sed -n '/charge/{
+ $UPSC $UPS | sed -n '/charge/{
s/^[^:]*\.//g
s/:/.value/
p
@@ -87,7 +92,7 @@ frequency() {
echo "acfreq.max 100"
echo "acfreq.min 5"
else
- upsc $UPS | sed -n '/freq/{s/.*:/acfreq.value/;p}'
+ $UPSC $UPS | sed -n '/freq/{s/.*:/acfreq.value/;p}'
fi
}
@@ -102,7 +107,7 @@ current() {
echo "current.max 100"
echo "current.min 0"
else
- upsc $UPS | sed -n '/current/{s/.*:/current.value/;p}'
+ $UPSC $UPS | sed -n '/current/{s/.*:/current.value/;p}'
fi
}