From c5382a1752247e820d8389df12e664a547b9977b Mon Sep 17 00:00:00 2001 From: Keith Whyte Date: Tue, 14 Jun 2022 19:38:20 +0200 Subject: [PATCH] Make collectd-hack script more robust --- modules/rhizo_base/files/collectd-hack | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/rhizo_base/files/collectd-hack b/modules/rhizo_base/files/collectd-hack index 876b99b..a143b38 100644 --- a/modules/rhizo_base/files/collectd-hack +++ b/modules/rhizo_base/files/collectd-hack @@ -2,6 +2,10 @@ is_empty () { _o=`rrdtool xport DEF:A=/var/lib/collectd/rrd/$(hostname -f)/$1:value:AVERAGE XPORT:A -s -1day -m10 | xmllint --xpath 'string(xport/data/row)' -` + if [ $? != 0 ] ; then + echo "Error. exiting." + exit + fi if [ "$_o" == "0.0000000000e+00" ] ;then echo "$1 is empty" return 1 @@ -12,7 +16,13 @@ is_empty () { cd /var/lib/collectd/rrd/$(hostname -f) rm -rf gauge-* derive-* +if [ ! -d statsd ] ; then + echo "No statsd directory" + exit +fi + for f in statsd/* ; do #gauge-bts.0* statsd/*msc.0* statsd/*vlr.0*; do + echo "Checking $f" is_empty $f if [ $? == 1 ] ; then continue ; fi mkdir $(basename $f .rrd)