Networker

Re: [Networker] Rather than re-invent the wheel - can some one he lp.

2005-04-22 07:38:27
Subject: Re: [Networker] Rather than re-invent the wheel - can some one he lp.
From: "Allan, Kevin" <KEVIN.ALLAN AT SAIC DOT COM>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Fri, 22 Apr 2005 04:29:37 -0700
Thanks
Kevin


-----Original Message-----
From: Legato NetWorker discussion [mailto:NETWORKER AT LISTSERV.TEMPLE DOT EDU] 
On
Behalf Of Conrad Macina
Sent: 22 April 2005 12:01
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Subject: Re: [Networker] Rather than re-invent the wheel - can some one
help.

This isn't quite what you want: It lists backup times per save set, but you
can readily infer the client times.

HTH,

Conrad Macina
Pfizer, Inc.

---------- <snip> ----------
#!/bin/ksh

# Generate an mminfo report for every client, or for the set of clients
# specified on the command line. Reports the following values for every
# save set backed up during the specified interval:
# Save set name; start date/time; level; bytes backed up; files backed up;
# completion date/time; Data transfer rate, Kb/sec

usage() {
   echo ""
   echo "`basename $0` generates an mminfo report for every client, or for
the"
   echo "set of clients specified on the command line."
   echo ""
   echo "Usage:    `basename $0` [-d <days>] [-g <group>] [-m <addr>]
[client [client [client...]]]"
   echo ""
   echo "Options:  -d <days> is the number of prior days to report on.
Defaults"
   echo "             to 2. Note that '-d 2' means '2 days ago' and
generates a"
   echo "             report covering three days, today and the two days
prior."
   echo "             To report on yesterday and today only, use '-d 1'".
   echo "          -g <group> causes the program to report on all clients
which"
   echo "             back up in the specified group. Note that all save
sets for"
   echo "             the client are reported, including those which are not
part"
   echo "             of the group. If a client in a listed group is also
included"
   echo "             as a client parameter, then that client will be
reported twice."
   echo "             Multiple -g parameters may be specified."
   echo "          -m <addr> specifies the e-mail address to which to send
the"
   echo "             report. If omitted, the report goes to stdout."
   echo ""
   echo "Examples: `basename $0`"
   echo "          `basename $0` myclient"
   echo "          `basename $0` -d 7 -m 'Joe.Bloe AT yahoo DOT com' myclient"
   echo "          `basename $0` -d 7 -g Default -m 'Joe.Bloe AT yahoo DOT com'
myclient myotherclient"
   echo ""
   exit 1
}

# Note that "2" means "2 days ago" and generates a report covering three
days,
# today and the two prior days. For a two-day report, use "1 day ago".

whosingroup() {
for GRP in $@
do
GRPP=`echo $GRP | sed 's!:!\\\:!''`     ;# Escape any colon chars in the
group
echo "show name\nprint type:nsr client;group:$GRPP" | nsradmin -i - | nawk '
  BEGIN { N=0 }
  /^ +name:/ {
     X=index($0, ":")
     NAM=substr($0, X+1, length($0)-X)
     N++
     print "     ",NAM
     }
  END { printf "%d clients identified.\n", N }
' | sort
done
}

DAYS=2    ;# Default: Report on 2 days
MAILADR="" ;MAILTMP=""  ;# Default: Report to stdout
GROUP=""   ;# Start with no groups specified
while getopts d:g:m: I
do
  # echo "I=<$I>, OPTARG=<$OPTARG>, OPTIND=<$OPTIND>"
  case $I in
    "d") # echo "d - CMDLIN=<$@>"
       DAYS=`expr $OPTARG + 0 2>/dev/null`
       if [ $? = 2 ]; then
          echo "Numeric argument required"
          exit 2
       fi
       ;;
    "g") # echo "g - CMDLIN=<$@>"
       GROUP="$GROUP $OPTARG"
       ;;
    "m") # echo "m - CMDLIN=<$@>"
       MAILADR=$OPTARG  ;# Address to send to
       MAILTMP=/tmp/`basename $0`.$$.mail ;# Temp file for mail
       # Start the mail file
       echo "mail $MAILADR << !!" > $MAILTMP
       echo "To: $MAILADR" >> $MAILTMP
       echo "Subject: `hostname` Legato NetWorker Save Set Report `date
+%m/%d/%y`" >> $MAILTMP
       echo "" >> $MAILTMP
       ;;

    \?) usage; exit 1 ;;

  esac
done
shift `expr $OPTIND - 1`

# echo "DAYS=<$DAYS>, MAILADR=<$MAILADR>, MAILTMP=<$MAILTMP>,
GROUP=<$GROUP>"
# echo "PARAMS=<$@>"

if [ -n "$GROUP" ] ;then
   echo "Getting group information, please wait ... \c"
   CLILIST=`whosingroup $GROUP`
   echo "Done"
fi

if [ $# = 0 ] ;then
   # No parameters. If there's a group specified, use it. Otherwise get a
list of all clients.
   if [ -z "$CLILIST" ] ;then
      CLILIST=`/usr/sbin/mminfo -r client | sort -u`
   fi
else
   # Report on the clients listed in the command line.
   CLILIST="$CLILIST $@"
fi

# echo "CLILIST=<$CLILIST>"

(
for C in $CLILIST
do
  C=`echo $C | tr '[A-Z]' '[a-z]'`
  CLI=`echo "show name\nprint type:nsr client" | /usr/sbin/nsradmin -i - |
grep $C | nawk '{print $NF}' | tr -d ';' | head -1`
  if [ -z "$CLI" ] ;then
     echo "$C is not a defined client on `hostname`"
     continue
  fi
  # Report header identifies the client
  echo "= = = = = = = = = = = = = = =   $CLI   = = = = = = = = = = = = = =
="

  # -ot = Order by time -r = report specs: name is save set name, sscreate
is
  # save set create time, level is "full" or "incr", totalsize is bytes
backed
  # up, nfiles is the number of files and sscomp is completion time.
  # echo /usr/sbin/mminfo -c $CLI -t \"${DAYS} days ago\" -ot -r
\'name\(15\),sscreate\(20\),level,totalsize\(12\),nfiles\(7\),sscomp\(20\)\'
  /usr/sbin/mminfo -c $CLI -t "${DAYS} days ago" -ot -r
'name(15),sscreate(20),level,totalsize(12),nfiles(7),sscomp(20)' |
/usr/bin/nawk '
{
  SSSM=0   ;# Start time, seconds since midnight
  STF=0    ;# Field # where we found the start time
  ESSM=0   ;# End time, seconds since midnight
  BYTFLD=0   ;# Field # for the byte count
  for (F=1; F<=NF ;F++) {
    # Search for time fields (hh:mm:ss). 1st is start time, 2nd end time.
    if ($F ~ "[0-2][0-9]:[0-5][0-9]:[0-5][0-9]") {
       HH=substr($F,1,2) ;# Hour
       MM=substr($F,4,2) ;# Minute
       SS=substr($F,7,2) ;# Second
       SSM=(((HH * 60) + MM) * 60) + SS ;# seconds since midnight
       # printf "F=%d, TIME=%s, HH=%d, MM=%d, SS=%d, SSM=%d\n", F, $F, HH,
MM, SS, SSM
       if (SSSM == 0) {SSSM = SSM ;STF = F} else {ESSM = SSM}
       }
    # 1st all-numeric field at least 2 past the start time is the byte count
    if ((BYTFLD == 0 ) && (SSSM != 0) && (F >= STF+2) && ($F ~ "^[0-9]+$"))
{ BYTFLD = F; }
  }

  if ((SSSM != 0) && (ESSM !=0) && (BYTFLD !=0)) {
     ELAPSED=ESSM-SSSM ;# Elapsed Seconds
     if (ELAPSED < 0) {
        if ($0 ~ " AM | PM ") {
           ELAPSED = ELAPSED + (60*60*12)
           } else {
           ELAPSED = ELAPSED + (60*60*24)
           }
        }
     BYTES=$BYTFLD  ;# Bytes
     # printf "SSSM=%d, ESSM=%d, ELAPSED=%d, BYTES=%d\n", SSSM, ESSM,
ELAPSED, BYTES
     if (ELAPSED != 0) {
        BPS=(BYTES / ELAPSED) ;# Bytes per Second
        KBPS=(BPS / 1024) ;# Kbytes per Second
        } else {BPS=0; KBPS=0}
     # printf "BYTES=%d, ELAPSED=%d, BPS=%f, KBPS=%f\n", BYTES, ELAPSED,
BPS, KBPS
     printf "%s %-4.1f\n", $0, KBPS
     }
  else {
     # Start time, end time and/or bytes missing. See if this is the header
     if ($0 ~ "^ name") {printf "%s      Kb/sec\n", $0} else {print}
     }
}'
  echo ""
  echo " \c"
done
) >> $MAILTMP

if [ -n "$MAILADR" ] ;then
   # Finish off the mail file and send mail
   echo "" >> $MAILTMP
   echo "!!" >> $MAILTMP
   chmod 777 $MAILTMP
   $MAILTMP
   rm $MAILTMP
fi
---------- <snip> ----------

On Thu, 21 Apr 2005 06:43:04 -0700, Allan, Kevin <KEVIN.ALLAN AT SAIC DOT COM>
wrote:

>I would like to report on the elapse backup times per client, does some one
>have a script that I can use on a Solaris server.
>
>Regards
>Kevin
>
>--
>Note: To sign off this list, send a "signoff networker" command via email
>to listserv AT listserv.temple DOT edu or visit the list's Web site at
>http://listserv.temple.edu/archives/networker.html where you can
>also view and post messages to the list. Questions regarding this list
>should be sent to stan AT temple DOT edu
>=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=

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

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

<Prev in Thread] Current Thread [Next in Thread>
  • Re: [Networker] Rather than re-invent the wheel - can some one he lp., Allan, Kevin <=