Make collectd-hack script more robust
This commit is contained in:
parent
fcad69e86f
commit
c5382a1752
1 changed files with 10 additions and 0 deletions
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
is_empty () {
|
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)' -`
|
_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
|
if [ "$_o" == "0.0000000000e+00" ] ;then
|
||||||
echo "$1 is empty"
|
echo "$1 is empty"
|
||||||
return 1
|
return 1
|
||||||
|
@ -12,7 +16,13 @@ is_empty () {
|
||||||
cd /var/lib/collectd/rrd/$(hostname -f)
|
cd /var/lib/collectd/rrd/$(hostname -f)
|
||||||
rm -rf gauge-* derive-*
|
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
|
for f in statsd/* ; do #gauge-bts.0* statsd/*msc.0* statsd/*vlr.0*; do
|
||||||
|
echo "Checking $f"
|
||||||
is_empty $f
|
is_empty $f
|
||||||
if [ $? == 1 ] ; then continue ; fi
|
if [ $? == 1 ] ; then continue ; fi
|
||||||
mkdir $(basename $f .rrd)
|
mkdir $(basename $f .rrd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue