Veritas-bu

[Veritas-bu] Scripting with bperror

2002-12-29 12:02:20
Subject: [Veritas-bu] Scripting with bperror
From: Mark.Donaldson AT experianems DOT com (Donaldson, Mark)
Date: Sun, 29 Dec 2002 10:02:20 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2AF5C.0CFE7550
Content-Type: text/plain;
        charset="iso-8859-1"

One concern is that bperror is more of a historical reporting tool.  If you
want a message for when you fail on a per job basis, you'd be better looking
at a script written in /usr/openv/netbackup/bin/backup_exit_notify.  I also
have a script that produces daily reports run via cron.  I'll send that as a
separate message as I often bump into the 20K list limit.

Here my modified backup_exit_notify script:

$ cat backup_exit_notify
#!/bin/sh
# $Header: backup_notify,v 1.0 2002/01/22 1l:44:00 integ Exp $

# Modified by Mark Donaldson for Experian 10/2002
#
# backup_notify
#
# NOTE:  this script will always be run in "background" mode, meaning that
#        the NetBackup scheduler will NOT wait for it's completion.
#
# This script:
#       receives 5 parameters:
#         CLIENT           - the client hostname
#         CLASS            - the class label
#         SCHEDULE         - the schedule label
#         SCHEDULE_TYPE    - the type of schedule:  FULL INCR UBAK UARC
#         STATUS           - the backup status for this job
#         STREAM           - the backup stream number for this job
#       must be executable by the root user
#       should exit with 0 upon successful completion

LOGFILE=/usr/openv/netbackup/logs/history.log
MAILADDR=YOU AT YOURDOMAIN DOT COM

PATH=$PATH:/usr/openv/netbackup/bin/admincmd
export PATH

echo "`date +%D_%T` $*" | sed 's/  *$//' | tr -s ' ' ',' >>$LOGFILE

       CLIENT=$1
        CLASS=$2
     SCHEDULE=$3
SCHEDULE_TYPE=$4
       STATUS=$5
       STREAM=$6

shortclient=`echo $CLIENT| cut -f1-2 -d'.'`
shorthost=`hostname | cut -f1 -d.`
subjectline="NB $shorthost:$shortclient RC=$STATUS $CLASS:$SCHEDULE"

if [ $STATUS -gt 0 ]
then
  mailx -s "$subjectline" $MAILADDR <<-EOF
      Date=`date`
    Client=$CLIENT
     Class=$CLASS
  Schedule=$SCHEDULE
Sched type=$SCHEDULE_TYPE
    Status=$STATUS
    Stream=$STREAM

Error Description:
`bperror -S $STATUS -r`
EOF
fi

exit

-----Original Message-----
From: John.Kenny AT trw DOT com [mailto:John.Kenny AT trw DOT com]
Sent: Tuesday, December 24, 2002 10:39 AM
To: veritas-bu AT mailman.eng.auburn DOT edu
Subject: [Veritas-bu] Scripting with bperror


I am new to Netbackup. I am also new to Unix. This is a double whammy since
my Master Server is Unix based. Can anyone help me with a script to email
notification when a backup job ends with an error ?
 
I looked at adding an address to the global properties on the Master Server,
but that will send ALL status messages. I only want the jobs that end with
an error.
 
 

------_=_NextPart_001_01C2AF5C.0CFE7550
Content-Type: text/html;
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Veritas-bu] Scripting with bperror</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>One concern is that bperror is more of a historical =
reporting tool.&nbsp; If you want a message for when you fail on a per =
job basis, you'd be better looking at a script written in =
/usr/openv/netbackup/bin/backup_exit_notify.&nbsp; I also have a script =
that produces daily reports run via cron.&nbsp; I'll send that as a =
separate message as I often bump into the 20K list limit.</FONT></P>

<P><FONT SIZE=3D2>Here my modified backup_exit_notify script:</FONT>
</P>

<P><FONT SIZE=3D2>$ cat backup_exit_notify</FONT>
<BR><FONT SIZE=3D2>#!/bin/sh</FONT>
<BR><FONT SIZE=3D2># $Header: backup_notify,v 1.0 2002/01/22 1l:44:00 =
integ Exp $</FONT>
</P>

<P><FONT SIZE=3D2># Modified by Mark Donaldson for Experian =
10/2002</FONT>
<BR><FONT SIZE=3D2>#</FONT>
<BR><FONT SIZE=3D2># backup_notify</FONT>
<BR><FONT SIZE=3D2>#</FONT>
<BR><FONT SIZE=3D2># NOTE:&nbsp; this script will always be run in =
&quot;background&quot; mode, meaning that</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the =
NetBackup scheduler will NOT wait for it's completion.</FONT>
<BR><FONT SIZE=3D2>#</FONT>
<BR><FONT SIZE=3D2># This script:</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; receives 5 =
parameters:</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
CLIENT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - =
the client hostname</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
CLASS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
- the class label</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
SCHEDULE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - the schedule =
label</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
SCHEDULE_TYPE&nbsp;&nbsp;&nbsp; - the type of schedule:&nbsp; FULL INCR =
UBAK UARC</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
STATUS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - =
the backup status for this job</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - =
the backup stream number for this job</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; must be =
executable by the root user</FONT>
<BR><FONT SIZE=3D2>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; should exit =
with 0 upon successful completion</FONT>
</P>

<P><FONT =
SIZE=3D2>LOGFILE=3D/usr/openv/netbackup/logs/history.log</FONT>
<BR><FONT SIZE=3D2>MAILADDR=3DYOU AT YOURDOMAIN DOT COM</FONT>
</P>

<P><FONT SIZE=3D2>PATH=3D$PATH:/usr/openv/netbackup/bin/admincmd</FONT>
<BR><FONT SIZE=3D2>export PATH</FONT>
</P>

<P><FONT SIZE=3D2>echo &quot;`date +%D_%T` $*&quot; | sed 's/&nbsp; =
*$//' | tr -s ' ' ',' &gt;&gt;$LOGFILE</FONT>
</P>

<P><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
CLIENT=3D$1</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
CLASS=3D$2</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; SCHEDULE=3D$3</FONT>
<BR><FONT SIZE=3D2>SCHEDULE_TYPE=3D$4</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
STATUS=3D$5</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
STREAM=3D$6</FONT>
</P>

<P><FONT SIZE=3D2>shortclient=3D`echo $CLIENT| cut -f1-2 -d'.'`</FONT>
<BR><FONT SIZE=3D2>shorthost=3D`hostname | cut -f1 -d.`</FONT>
<BR><FONT SIZE=3D2>subjectline=3D&quot;NB $shorthost:$shortclient =
RC=3D$STATUS $CLASS:$SCHEDULE&quot;</FONT>
</P>

<P><FONT SIZE=3D2>if [ $STATUS -gt 0 ]</FONT>
<BR><FONT SIZE=3D2>then</FONT>
<BR><FONT SIZE=3D2>&nbsp; mailx -s &quot;$subjectline&quot; $MAILADDR =
&lt;&lt;-EOF</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date=3D`date`</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; Client=3D$CLIENT</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; Class=3D$CLASS</FONT>
<BR><FONT SIZE=3D2>&nbsp; Schedule=3D$SCHEDULE</FONT>
<BR><FONT SIZE=3D2>Sched type=3D$SCHEDULE_TYPE</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; Status=3D$STATUS</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; Stream=3D$STREAM</FONT>
</P>

<P><FONT SIZE=3D2>Error Description:</FONT>
<BR><FONT SIZE=3D2>`bperror -S $STATUS -r`</FONT>
<BR><FONT SIZE=3D2>EOF</FONT>
<BR><FONT SIZE=3D2>fi</FONT>
</P>

<P><FONT SIZE=3D2>exit</FONT>
</P>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: John.Kenny AT trw DOT com [<A =
HREF=3D"mailto:John.Kenny AT trw DOT com">mailto:John.Kenny AT trw DOT 
com</A>]</FONT>=

<BR><FONT SIZE=3D2>Sent: Tuesday, December 24, 2002 10:39 AM</FONT>
<BR><FONT SIZE=3D2>To: veritas-bu AT mailman.eng.auburn DOT edu</FONT>
<BR><FONT SIZE=3D2>Subject: [Veritas-bu] Scripting with bperror</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>I am new to Netbackup. I am also new to Unix. This is =
a double whammy since my Master Server is Unix based. Can anyone help =
me with a script to email notification when a backup job ends with an =
error ?</FONT></P>

<P><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>I looked at adding an address to the global =
properties on the Master Server, but that will send ALL status =
messages. I only want the jobs that end with an error.</FONT></P>

<P><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>&nbsp;</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C2AF5C.0CFE7550--

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