improve check for empty rrd

This commit is contained in:
Keith Whyte 2023-03-28 08:40:38 +02:00
parent e1713bbc3a
commit a0464a329f

View file

@ -13,8 +13,15 @@ is_empty () {
exit exit
fi fi
if [ "$_o" == "" -o "$_o" == "0.0000000000e+00" -o "$_o" == "NaN" ] ;then if [ "$_o" == "" -o "$_o" == "0.0000000000e+00" -o "$_o" == "NaN" ] ;then
debug $1 "$2 is empty" _o=`rrdtool xport DEF:A=/var/lib/collectd/rrd/$(hostname -f)/$2:value:LAST XPORT:A -s -1min -m10 | xmllint --xpath 'string(xport/data/row[v>0]/v)' -`
return 1 if [ $? != 0 ] ; then
echo "Error. exiting."
exit
fi
if [ "$_o" == "" -o "$_o" == "0.0000000000e+00" -o "$_o" == "NaN" ] ;then
debug $1 "$2 is empty"
return 1
fi
fi fi
if [ "$1" == "ne" ] ; then if [ "$1" == "ne" ] ; then
echo "$2 has data" echo "$2 has data"