Networker

Re: [Networker] Percentage of successful backups

2004-08-15 17:20:11
Subject: Re: [Networker] Percentage of successful backups
From: Conrad Macina <conrad.macina AT PFIZER DOT COM>
To: NETWORKER AT LISTMAIL.TEMPLE DOT EDU
Date: Sun, 15 Aug 2004 17:20:11 -0400
Allow me to contribute another version of the "batting average" script.
This one works with NetWorker 6.1.3 and prior; it will have to change for
7.1.1's completion message format.

#!/bin/ksh

# Report the "Batting Average" for a given month

LOGDIR=/nsr/logs
LOGFIL=${LOGDIR}/messages*

set -A
LASTMON "X" "Dec" "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct
" "Nov"

# Use the month specified on the command line. Default to last month.
if [ $# = 0 ] ;then
   MON=${LASTMON[$(date +%m)]}
else
   MON=$1
fi

# Success message:
# Apr  5 08:34:48 mopcitlgtom1 root: [ID 702911 daemon.notice] NetWorker
Savegroup: (notice) 05:30_Start completed, 1 client(s) (All Succeeded)

# Failure message:
# Apr  5 06:59:38 mopcitlgtom1 root: [ID 702911 daemon.notice] NetWorker
Savegroup: (alert) 05:30_Start completed, 1 client(s) (badclient Failed)

TOTAL_AB=0
HITS=0

grep "^${MON} .*NetWorker Savegroup: " $LOGFIL | egrep 'compl|abort' |
grep -v 'already running' | while read LINE

do
  # echo "<$LINE>"
  # "At Bats" = Number of backups attempted
  AB=`echo "$LINE" | cut -d "," -f 2 | cut -d " " -f 2`
  TOTAL_AB=`expr $TOTAL_AB + $AB`
  # "Hits" = Number successful
  X=`echo "$LINE" | grep -c "(All Succeeded)"`
  if [ $X = 0 ] ;then
     # There were failures
     SO=`echo "$LINE" | cut -d "(" -f 3 | cut -d ")" -f 1 | nawk '{
         CT=1
         for (X = 1; X <= length($0); X++) {
             if (substr($0, X, 1) == ",") CT++
             }
         print CT
         }'`
     # echo "SO=<$SO>"
     H=`expr $AB - $SO`
  else
     # No failures
     H=$AB
  fi
  # echo "AB=<$AB>, H=<$H>"
  HITS=`expr $HITS + $H`
done

PCT=`expr $HITS \* 1000`
PCT=`expr $PCT / $TOTAL_AB`
echo "`hostname`\t$TOTAL_AB At bat\t$HITS Hits\tAvg=.$PCT"

--
Note: To sign off this list, send a "signoff networker" command via email
to listserv AT listmail.temple DOT edu or visit the list's Web site at
http://listmail.temple.edu/archives/networker.html where you can
also view and post messages to the list.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

<Prev in Thread] Current Thread [Next in Thread>