summaryrefslogtreecommitdiff
path: root/munin
diff options
context:
space:
mode:
Diffstat (limited to 'munin')
-rwxr-xr-xmunin/ups_168
1 files changed, 168 insertions, 0 deletions
diff --git a/munin/ups_ b/munin/ups_
new file mode 100755
index 0000000..5b112c3
--- /dev/null
+++ b/munin/ups_
@@ -0,0 +1,168 @@
+#!/bin/sh
+#
+# Plugin to monitor various statistics exported by a UPS.
+#
+# Written by Andras Korn in 2005. Licensed under the GPL.
+#
+# (presumably also Copyright Andras Korn in 2005 -- Peter Palfrader, 2006-04-28)
+# Copyright 2006 Peter Palfrader <peter@palfrader.org>
+#
+# changes:
+# 2006-04-28 Peter Palfrader:
+# - add runtime and temperature graphs
+# - append @localhost to UPS variable
+#
+# usage: ups_upsid_function
+#
+#%# family=contrib
+#%# capabilities=autoconf suggest
+
+UPS=$(basename $0 | cut -d_ -f2)"@localhost"
+FUNCTION=$(basename $0 | cut -d_ -f3)
+
+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)"
+ exit 1
+fi
+
+if [ "$1" = "suggest" ]; then
+ grep '^\[[^]]*\]$' /etc/nut/ups.conf \
+ | tr -d '][' \
+ | while read ups; do
+ for i in voltages freq charge current runtime temperature; do
+ echo ${ups}_${i}
+ done
+ done
+fi
+
+function voltages() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS voltages"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel Volt"
+ for i in battery nominal input output; do
+ echo "${i}.label $i"
+ echo "${i}.type GAUGE"
+ echo "${i}.max 1000"
+ echo "${i}.min 0"
+ done
+ else
+ upsc $UPS | sed -n '/volt/{
+ s/://
+ /nominal/s/.* /nominal.value /
+ /voltage/s/\.[^ ]*/.value/
+ p
+ }'
+ fi
+}
+
+function charge() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS charge"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel %"
+ for i in charge low load; do
+ echo "${i}.label $i"
+ echo "${i}.type GAUGE"
+ echo "${i}.max 100"
+ echo "${i}.min 0"
+ done
+ else
+ upsc $UPS | sed -n '/charge/{
+ s/^[^:]*\.//g
+ s/:/.value/
+ p
+ }
+ /load/{
+ s/.*:/load.value/
+ p
+ }'
+ fi
+}
+
+function frequency() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS input AC frequency"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel frequency 1/s"
+ echo "acfreq.label AC frequency"
+ echo "acfreq.type GAUGE"
+ echo "acfreq.max 100"
+ echo "acfreq.min 5"
+ else
+ upsc $UPS | sed -n '/freq/{s/.*:/acfreq.value/;p}'
+ fi
+}
+
+function current() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS output current"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel Amper"
+ echo "current.label out-current"
+ echo "current.type GAUGE"
+ echo "current.max 100"
+ echo "current.min 0"
+ else
+ upsc $UPS | sed -n '/current/{s/.*:/current.value/;p}'
+ fi
+}
+
+function runtime() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS battery runtime"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel seconds"
+ echo "runtime.label runtime"
+ echo "runtime.type GAUGE"
+ echo "runtime.max 10000"
+ echo "runtime.min 0"
+ else
+ upsc $UPS | sed -n '/battery.runtime/{s/.*:/runtime.value/;p}'
+ fi
+}
+
+function temperature() {
+ if [ "$1" = "config" ]; then
+
+ echo "graph_title $UPS ambient temperature"
+ echo "graph_args --base 1000 -l 0"
+ echo "graph_vlabel degrees Celsius"
+ echo "temperature.label temperature"
+ echo "temperature.type GAUGE"
+ echo "temperature.max 100"
+ echo "temperature.min -20"
+ else
+ upsc $UPS | sed -n '/ambient.temperature/{s/.*:/temperature.value/;p}'
+ fi
+}
+
+[ "$1" = "config" ] && echo "graph_category sensors"
+
+case "$FUNCTION" in
+ voltages)
+ voltages $1
+ ;;
+ charge)
+ charge $1
+ ;;
+ freq)
+ frequency $1
+ ;;
+ current)
+ current $1
+ ;;
+ runtime)
+ runtime $1
+ ;;
+ temperature)
+ temperature $1
+ ;;
+esac
+