Files
ebusd/contrib/munin/plugins/ebusd_
T
2016-12-10 16:52:10 +01:00

74 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Munn plugin for ebusd.
#%# family=auto
#%# capabilities=autoconf
#%# capabilities=suggest
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo "yes"
exit 0
fi
if [ "$1" = "suggest" ]; then
echo "temp"
echo "press"
echo "power"
exit 0
fi
prefix=`basename "$0"`
type=${prefix##ebusd_}
skip=
if [ "$type" = "temp" ]; then
match="Temp(Input|Output|Bottom|Top)?\$|outsidetemp"
skip="Bivalent|Max|Min|Outside|mc5:"
elif [ "$type" = "press" ]; then
match="Press(High|Low)?\$"
skip="KeyPress"
else
match="Environment(Energy|Power)\$"
fi
result=`echo "find"|nc localhost 8888 2>/dev/null`
if [ -z "$result" -o "x${result##ERR:*}" = "x" ]; then
echo "error: $result"
exit 1
fi
sensors=`echo "$result"|sed -e 's# =.*$##' -e 's# #:#'|egrep "$match"`
if [ -n "$skip" ]; then
sensors=`echo "$sensors"|egrep -v "$skip"`
fi
if [ "$1" = "config" ]; then
if [ "$type" = "temp" ]; then
echo "graph_title ebus Temperaturen"
echo "graph_vlabel Grad"
elif [ "$type" = "press" ]; then
echo "graph_title ebus Drucksensoren"
echo "graph_vlabel Bar"
else
echo "graph_title ebus Leistung/Ertrag"
echo "graph_vlabel kW"
echo "graph_period hour"
fi
echo 'graph_category Heizung'
for sensor in $sensors; do
result=`echo "read -c ${sensor/:/ }"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
if [ "x$result" = "x-" -o "x${result##ERR:*}" = "x" ]; then
continue
fi
if [ ! "${sensor%%Energy}" = "$sensor" ]; then
echo ${prefix}_${sensor/:/_}.label ${sensor/:/ } "[diff]"
echo ${prefix}_${sensor/:/_}.type COUNTER
echo ${prefix}_${sensor/:/_}.draw AREA
else
echo ${prefix}_${sensor/:/_}.label ${sensor/:/ }
fi
# print_warning ${prefix}_${sensor/:/_}
# print_critical ${prefix}_${sensor/:/_}
done
exit 0
fi
for sensor in $sensors; do
result=`echo "read -c ${sensor/:/ }"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
if [ ! "x$result" = "x-" ]; then
echo ${prefix}_${sensor/:/_}.value $result
fi
done