1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/bin/sh
#
# Periodically check if there are RRD files not updated by collector,
# and email the warning message.
# *.old.rrd files are ignored
# Stanislav Sinyagin <ssinyagin@yahoo.com>
#
# pull in configuration variables
test -f /etc/default/torrus-common && . /etc/default/torrus-common
if [ -z "$RRDUP_N_NOTIFY" ]; then
# nothing to do
exit 0
fi
# Where the RRD files are located. Separate multiple paths with space
RRDSTORAGE=${RRDUP_N_RRDSTORAGE:-/var/lib/torrus/collector_rrd}
# Maximum allowed age of an RRD file, in minutes.
MAXAGE=${RRDUP_N_MAXAGE:-60}
# Where to send complaints
NOTIFY=$RRDUP_N_NOTIFY
TMPFILE=/tmp/rrdup_notify.$$
cp /dev/null ${TMPFILE}
for d in ${RRDSTORAGE}; do
find ${d} -name '*.rrd' ! -name '*.old.rrd' \
-mmin +${MAXAGE} -print >>${TMPFILE}
done
nLines=`wc -l ${TMPFILE} | awk '{print $1}'`
if test ${nLines} -gt 0; then
cat ${TMPFILE} | \
mail -s "`printf \"Warning: %d aged RRD files\" ${nLines}`" ${NOTIFY}
fi
rm ${TMPFILE}
# Local Variables:
# mode: shell-script
# indent-tabs-mode: nil
# perl-indent-level: 4
# End:
|