[slbackup-commit] CVS update: slbackup/contrib munin-plugin

finnarne-guest at alioth.debian.org finnarne-guest at alioth.debian.org
Mon Feb 25 11:10:01 UTC 2008


  User: finnarne-guest
  Date: 08/02/25 11:10:01

  Modified:    contrib  munin-plugin
  Log:
  Rebuilt plugin to show status for every client.
  Also use days since last successfull run instead of hours, since it
  gives a nicer graph.
  
  Revision  Changes    Path
  1.6                  slbackup/contrib/munin-plugin
  
  Index: munin-plugin
  ===================================================================
  RCS file: /cvsroot/slbackup/slbackup/contrib/munin-plugin,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- munin-plugin	26 Jan 2007 07:26:01 -0000	1.5
  +++ munin-plugin	25 Feb 2008 11:10:00 -0000	1.6
  @@ -3,10 +3,15 @@
   # $Id$
   #
   # Author: Finn-Arne Johansen 
  -# Date:   2006-01-29
  +# Date:   2008-02-25
   
  -PLUGINNAME=$(basename $0)
  -LOGNAME=/var/log/slbackup/$PLUGINNAME.log
  +LOGNAME=/var/log/slbackup/slbackup.log
  +
  +CLIENTS="$(perl -e 'use SLBackup  ; 
  +           $config=slbackup_readconfig () ; 
  +           for $key (keys %{$config->{client}}) { 
  +               printf ("%s\n", $key) ; 
  +           } ')"
   
   if [ "$1" = "config" ] ; then 
     echo "graph_title slbackup status"
  @@ -14,13 +19,14 @@
     echo "graph_vlabel count"
     echo "graph_scale no"
     echo "graph_category disk"
  -  echo "success.label success"
  -  echo "failed.label failed"
  -  echo "failed.critical 1"
     echo "lastrun.label last run"
  -  echo "lastrun.warning 25"
  -  echo "lastrun.critical 30"
  -  echo "graph_info Show the number of failed and successfull backup set from the last run"
  +  echo "lastrun.warning 1.1"
  +  echo "lastrun.critical 1.25"
  +  for CLIENT in $CLIENTS ; do 
  +      echo "client_$CLIENT.label $CLIENT"
  +      echo "client_$CLIENT.critical 1:"
  +  done
  +  echo "graph_info Show the status of failed and successfull backup set from the last run"
     exit 0
   fi
   
  @@ -36,19 +42,21 @@
   # 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 "
  -  $CAT $LOGNAME | tail -n +$LAST | \
  -    grep "Failed backing up client" | wc -l
  -  echo -n "success.value "
  -  $CAT $LOGNAME | tail -n +$LAST | \
  -    grep "Successfully finished backing up client" | wc -l
  -else
  -  # or trigger an error if last backup is not found
  -  echo "failed.value 1"
  -  echo "success.value 0"
  -fi
  +for CLIENT in $CLIENTS ; do 
  +  # count failed and successfull backups during last backup
  +  if [ "$LAST" ] ; then 
  +    if $CAT $LOGNAME | tail -n +$LAST | \
  +      grep -q "Successfully finished backing up client ${CLIENT}$" ; then 
  +        echo "client_$CLIENT.value 1"
  +    else
  +        echo "client_$CLIENT.value 0"
  +    fi
  +  else
  +    # or trigger an error if last backup is not found
  +    echo "client_$CLIENT.value 0"
  +  fi
  +done
  +
   
   # Find when last backup ended
   LASTRUN="$($CAT $LOGNAME | sed -ne "s/- Finished slbackup.//p" | tail -1 )" 
  @@ -60,7 +68,7 @@
     echo -n "lastrun.value ";   
     cat << EOF | bc 
   scale=2
  -($(date +%s) - $(date -d "$LASTRUN" +%s)) / 3600
  +($(date +%s) - $(date -d "$LASTRUN" +%s)) / 86400
   EOF
   fi
   
  
  
  



More information about the slbackup-commit mailing list