[slbackup-commit] CVS update: slbackup/contrib munin-plugin
finnarne-guest at alioth.debian.org
finnarne-guest at alioth.debian.org
Wed Feb 1 20:36:49 UTC 2006
User: finnarne-guest
Date: 06/02/01 20:36:49
Modified: contrib munin-plugin
Log:
Added comments, and support for logrotation
Revision Changes Path
1.3 +26 -5 slbackup/contrib/munin-plugin
Index: munin-plugin
===================================================================
RCS file: /cvsroot/slbackup/slbackup/contrib/munin-plugin,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- munin-plugin 29 Jan 2006 12:04:23 -0000 1.2
+++ munin-plugin 1 Feb 2006 20:36:49 -0000 1.3
@@ -1,8 +1,12 @@
#/bin/sh
#
+# $Id$
+#
# Author: Finn-Arne Johansen
# Date: 2006-01-29
+PLUGINNAME=$(basename $0)
+LOGNAME=/var/log/slbackup/$PLUGINNAME.log
if [ "$1" = "config" ] ; then
echo "graph_title slbackup status"
@@ -20,22 +24,39 @@
exit 0
fi
-LAST=$(grep -n "Starting slbackup:" /var/log/slbackup/slbackup.log | tail -1 | cut -f1 -d:)
+# Fetch log that is not empty (prevent broken plugin when logfile
+# is rotated)
+if [ -s $LOGNAME ] ; then
+ CAT=cat
+elif [ -r $LOGNAME.1.gz ] ; then
+ CAT=zcat
+ LOGNAME=$LOGNAME.1.gz
+fi
+
+# Fetch were last backup was started
+LAST=$($CAT $LOGNAME | grep -n "Starting slbackup:" | tail -1 | cut -f1 -d:)
+
+# count failed and successfull backups during last backup
if [ "$LAST" ] ; then
echo -n "failed.value "
- tail +$LAST /var/log/slbackup/slbackup.log | grep "Failed backing up client" | wc -l
+ $CAT $LOGNAME | tail +$LAST | \
+ grep "Failed backing up client" | wc -l
echo -n "success.value "
- tail +$LAST /var/log/slbackup/slbackup.log | grep "Successfully finished backing up client" | wc -l
+ $CAT $LOGNAME | tail +$LAST | \
+ grep "Successfully finished backing up client" | wc -l
else
- echo "failed.value 0"
+ # or trigger an error if last backup is not found
+ echo "failed.value 1"
echo "success.value 0"
fi
-LASTRUN="$(sed -ne "s/- Finished slbackup.//p" /var/log/slbackup/slbackup.log | tail -1 )"
+# Find when last backup ended
+LASTRUN="$($CAT $LOGNAME | sed -ne "s/- Finished slbackup.//p" | tail -1 )"
if [ -z "$LASTRUN" ] ; then
echo lastrun.value 0
else
+ # report number of hours since last backup
echo -n "lastrun.value ";
cat << EOF | bc
scale=2
More information about the slbackup-commit
mailing list