added chart for hours, avoid duplicate sensor definition and reading

This commit is contained in:
john30
2016-12-10 16:52:10 +01:00
parent 1f30d82ef3
commit 8c57b1f629
+18 -7
View File
@@ -12,21 +12,27 @@ if [ "$1" = "suggest" ]; then
echo "temp" echo "temp"
echo "press" echo "press"
echo "power" echo "power"
echo "hours"
exit 0 exit 0
fi fi
prefix=`basename "$0"` prefix=`basename "$0"`
type=${prefix##ebusd_} type=${prefix##ebusd_}
find=$type
skip= skip=
if [ "$type" = "temp" ]; then if [ "$type" = "temp" ]; then
match="Temp(Input|Output|Bottom|Top)?\$|outsidetemp" match="Temp(Input|Output|Bottom|Top)?\$|outsidetemp"
skip="Bivalent|Max|Min|Outside|mc5:|rcc.*:Flow|^ui" skip="Bivalent|Max|Min|Outside|mc.5:|rcc.*:Flow|^ui"
elif [ "$type" = "press" ]; then elif [ "$type" = "press" ]; then
match="Press(High|Low)?\$" match="Press(High|Low)?\$"
skip="KeyPress" skip="KeyPress"
else elif [ "$type" = "power" ]; then
find="Environment"
match="Environment(Energy|Power)\$" match="Environment(Energy|Power)\$"
else
find="hours"
skip="mc.4:|mc.5:"
fi fi
result=`echo "find"|nc localhost 8888 2>/dev/null` result=`echo "find $find"|nc localhost 8888 2>/dev/null`
if [ -z "$result" -o "x${result##ERR:*}" = "x" ]; then if [ -z "$result" -o "x${result##ERR:*}" = "x" ]; then
echo "error: $result" echo "error: $result"
exit 1 exit 1
@@ -35,6 +41,7 @@ sensors=`echo "$result"|sed -e 's# =.*$##' -e 's# #:#'|egrep "$match"`
if [ -n "$skip" ]; then if [ -n "$skip" ]; then
sensors=`echo "$sensors"|egrep -v "$skip"` sensors=`echo "$sensors"|egrep -v "$skip"`
fi fi
sensors=`echo "$sensors"|sort -u`
if [ "$1" = "config" ]; then if [ "$1" = "config" ]; then
if [ "$type" = "temp" ]; then if [ "$type" = "temp" ]; then
echo "graph_title ebus Temperaturen" echo "graph_title ebus Temperaturen"
@@ -42,10 +49,14 @@ if [ "$1" = "config" ]; then
elif [ "$type" = "press" ]; then elif [ "$type" = "press" ]; then
echo "graph_title ebus Drucksensoren" echo "graph_title ebus Drucksensoren"
echo "graph_vlabel Bar" echo "graph_vlabel Bar"
else elif [ "$type" = "power" ]; then
echo "graph_title ebus Leistung/Ertrag" echo "graph_title ebus Leistung/Ertrag"
echo "graph_vlabel kW" echo "graph_vlabel kW"
echo "graph_period hour" echo "graph_period hour"
else
echo "graph_title ebus Betriebsstunden"
echo "graph_vlabel h"
echo "graph_period hour"
fi fi
echo 'graph_category Heizung' echo 'graph_category Heizung'
for sensor in $sensors; do for sensor in $sensors; do
@@ -55,12 +66,12 @@ if [ "$1" = "config" ]; then
fi fi
name=${sensor/:/_} name=${sensor/:/_}
name=${name/./_} name=${name/./_}
if [ ! "${sensor%%Energy}" = "$sensor" ]; then if [ "${sensor%%Energy}" = "$sensor" -a ! "$type" = "hours" ]; then
echo ${prefix}_${name}.label ${sensor/:/ }
else
echo ${prefix}_${name}.label ${sensor/:/ } "[diff]" echo ${prefix}_${name}.label ${sensor/:/ } "[diff]"
echo ${prefix}_${name}.type COUNTER echo ${prefix}_${name}.type COUNTER
echo ${prefix}_${name}.draw AREA echo ${prefix}_${name}.draw AREA
else
echo ${prefix}_${name}.label ${sensor/:/ }
fi fi
# print_warning ${prefix}_${sensor/:/_} # print_warning ${prefix}_${sensor/:/_}
# print_critical ${prefix}_${sensor/:/_} # print_critical ${prefix}_${sensor/:/_}