autoconf by using find command
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Munn plugin for ebusd.
|
||||||
#%# family=auto
|
#%# family=auto
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
#%# capabilities=suggest
|
#%# capabilities=suggest
|
||||||
@@ -14,44 +15,59 @@ if [ "$1" = "suggest" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
prefix=`basename "$0"`
|
prefix=`basename "$0"`
|
||||||
if [ "$prefix" = "ebusd_temp" ]; then
|
type=${prefix##ebusd_}
|
||||||
sensors="outsidetemp BrineTempInput BrineTempOutput FlowTemp mcFlowTempSensor hwTankTemp RoomTemp rc4:RoomTemp"
|
skip=
|
||||||
elif [ "$prefix" = "ebusd_press" ]; then
|
if [ "$type" = "temp" ]; then
|
||||||
sensors="BrinePress HeatSystemPress VaporPressHigh VaporPressLow"
|
match="Temp(Input|Output|Bottom|Top)?\$|outsidetemp"
|
||||||
|
skip="Bivalent|Max|Min|Outside|mc5:"
|
||||||
|
elif [ "$type" = "press" ]; then
|
||||||
|
match="Press(High|Low)?\$"
|
||||||
|
skip="KeyPress"
|
||||||
else
|
else
|
||||||
sensors="YieldEnvironmentEnergy ActualEnvironmentPower"
|
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
|
fi
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
if [ "$prefix" = "ebusd_temp" ]; then
|
if [ "$type" = "temp" ]; then
|
||||||
echo "graph_title ebusd Temperaturen"
|
echo "graph_title ebus Temperaturen"
|
||||||
echo "graph_vlabel Grad"
|
echo "graph_vlabel Grad"
|
||||||
elif [ "$prefix" = "ebusd_press" ]; then
|
elif [ "$type" = "press" ]; then
|
||||||
echo "graph_title ebusd Drucksensoren"
|
echo "graph_title ebus Drucksensoren"
|
||||||
echo "graph_vlabel Bar"
|
echo "graph_vlabel Bar"
|
||||||
else
|
else
|
||||||
echo "graph_title ebusd Leistung/Ertrag"
|
echo "graph_title ebus Leistung/Ertrag"
|
||||||
echo "graph_vlabel kW"
|
echo "graph_vlabel kW"
|
||||||
echo "graph_period hour"
|
echo "graph_period hour"
|
||||||
fi
|
fi
|
||||||
echo 'graph_category Heizung'
|
echo 'graph_category Heizung'
|
||||||
for sensor in $sensors; do
|
for sensor in $sensors; do
|
||||||
if [ ! "${sensor/nergy/}" = "$sensor" ]; then
|
result=`echo "read -c ${sensor/:/ }"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
|
||||||
echo ${prefix}_${sensor/:/_}.label "$sensor [diff]"
|
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/:/_}.type COUNTER
|
||||||
echo ${prefix}_${sensor/:/_}.draw AREA
|
echo ${prefix}_${sensor/:/_}.draw AREA
|
||||||
else
|
else
|
||||||
echo ${prefix}_${sensor/:/_}.label $sensor
|
echo ${prefix}_${sensor/:/_}.label ${sensor/:/ }
|
||||||
fi
|
fi
|
||||||
print_warning ${prefix}_${sensor/:/_}
|
# print_warning ${prefix}_${sensor/:/_}
|
||||||
print_critical ${prefix}_${sensor/:/_}
|
# print_critical ${prefix}_${sensor/:/_}
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
for sensor in $sensors; do
|
for sensor in $sensors; do
|
||||||
if [ "${sensor/:/_}" = "$sensor" ]; then
|
result=`echo "read -c ${sensor/:/ }"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
|
||||||
RESULT=`echo "r $sensor"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
|
if [ ! "x$result" = "x-" ]; then
|
||||||
else
|
echo ${prefix}_${sensor/:/_}.value $result
|
||||||
RESULT=`echo "r -c ${sensor/:/ }"|nc localhost 8888 2>/dev/null|head -n 1|sed -e 's#;.*$##'`
|
|
||||||
fi
|
fi
|
||||||
echo ${prefix}_${sensor/:/_}.value $RESULT
|
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user