Veritas-bu

[Veritas-bu] Scripting with bperror

2002-12-29 12:05:20
Subject: [Veritas-bu] Scripting with bperror
From: Mark.Donaldson AT experianems DOT com (Donaldson, Mark)
Date: Sun, 29 Dec 2002 10:05: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.780C28B0
Content-Type: text/plain;
        charset="iso-8859-1"

Here's my cron run, daily report script:

$ cat auto_reports
#!/bin/ksh

MAILADDR=YOU AT YOURDOMAIN DOT COM
PATH=$PATH:/usr/openv/netbackup/bin/admincmd
TMPFILE=/var/tmp/`basename $0`.tmp.$$

cols=92
hours=24

bperror -columns $cols -U -media -hoursago $hours | \
    awk 'BEGIN {set=0 }
    { if ( $0~/media id [A-Za-z0-9][A-Za-z0-9]* removed from media/ ) {
        set=1
        remline=$0 }
      else {
        if ( set==0 ) {
          print }
        else  {
          set=0
          if ( $0!~/expired/ ) {
            print remline
            print $0 }
        }
      }
    }' >$TMPFILE

shortname=`hostname | cut -f1 -d'.' | tr "[a-z]" "[A-Z]"`
if [ `wc -l $TMPFILE | awk '{print $1}'` -gt 1 ] ; then
     mailx -s "NB $shortname ${hours}hr Rpt:Media Report" $MAILADDR
<$TMPFILE
fi

echo "## Problem Summary..." >$TMPFILE
bperror -columns $cols -U -backstat -by_statcode -hoursago $hours | \
     awk 'BEGIN {switch=0}
          {if ( $1>0 && $1~/^[0-9][0-9]*$/ ) {switch=1}
           if ( switch==1 ) {
             if ( $1~/^[0-9][0-9]*$/ ) {print}
             else {
               count=0
               while ( ++count <= NF ) { print "\t\t" $count }
             }
           }
          }' >>$TMPFILE

svrlist=`bperror -columns $cols -U -backstat -by_statcode -hoursago $hours |
\
     awk 'BEGIN {switch=0}
          {if ( $1>0 && $1~/^[0-9][0-9]*$/ ) {switch=1}
           if ( switch==1 && $1!~/^[0-9][0-9]*$/) {
             count=0
             while ( ++count <= NF ) {print $count}}}' | sort -u`

echo "\n## Problem Detail by server..." >>$TMPFILE
for each in $svrlist
do
  echo "\n## Client: $each" >>$TMPFILE
  bperror -client $each -columns $cols -U -problems -hoursago $hours
>>$TMPFILE
done

if [ `egrep -vc "^ *$|^#" $TMPFILE` -gt 0 ] ; then
  mailx -s "NB $shortname ${hours}hr Rpt:Problems Report" $MAILADDR
<$TMPFILE
fi

[ -f $TMPFILE ] && rm -f $TMPFILE
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.780C28B0
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>Here's my cron run, daily report script:</FONT>
</P>

<P><FONT SIZE=3D2>$ cat auto_reports</FONT>
<BR><FONT SIZE=3D2>#!/bin/ksh</FONT>
</P>

<P><FONT SIZE=3D2>MAILADDR=3DYOU AT YOURDOMAIN DOT COM</FONT>
<BR><FONT =
SIZE=3D2>PATH=3D$PATH:/usr/openv/netbackup/bin/admincmd</FONT>
<BR><FONT SIZE=3D2>TMPFILE=3D/var/tmp/`basename $0`.tmp.$$</FONT>
</P>

<P><FONT SIZE=3D2>cols=3D92</FONT>
<BR><FONT SIZE=3D2>hours=3D24</FONT>
</P>

<P><FONT SIZE=3D2>bperror -columns $cols -U -media -hoursago $hours | =
\</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; awk 'BEGIN {set=3D0 }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; { if ( $0~/media id =
[A-Za-z0-9][A-Za-z0-9]* removed from media/ ) {</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
set=3D1</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
remline=3D$0 }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( =
set=3D=3D0 ) {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
}</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
else&nbsp; {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
set=3D0</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( =
$0!~/expired/ ) {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; print remline</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp; print $0 }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; }' &gt;$TMPFILE</FONT>
</P>

<P><FONT SIZE=3D2>shortname=3D`hostname | cut -f1 -d'.' | tr =
&quot;[a-z]&quot; &quot;[A-Z]&quot;`</FONT>
<BR><FONT SIZE=3D2>if [ `wc -l $TMPFILE | awk '{print $1}'` -gt 1 ] ; =
then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; mailx -s &quot;NB =
$shortname ${hours}hr Rpt:Media Report&quot; $MAILADDR =
&lt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>fi</FONT>
</P>

<P><FONT SIZE=3D2>echo &quot;## Problem Summary...&quot; =
&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>bperror -columns $cols -U -backstat -by_statcode =
-hoursago $hours | \</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; awk 'BEGIN =
{switch=3D0}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {if ( =
$1&gt;0 &amp;&amp; $1~/^[0-9][0-9]*$/ ) {switch=3D1}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
if ( switch=3D=3D1 ) {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; if ( $1~/^[0-9][0-9]*$/ ) {print}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; else {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp; count=3D0</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp; while ( ++count &lt;=3D NF ) { print =
&quot;\t\t&quot; $count }</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; }</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }' =
&gt;&gt;$TMPFILE</FONT>
</P>

<P><FONT SIZE=3D2>svrlist=3D`bperror -columns $cols -U -backstat =
-by_statcode -hoursago $hours | \</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp; awk 'BEGIN =
{switch=3D0}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {if ( =
$1&gt;0 &amp;&amp; $1~/^[0-9][0-9]*$/ ) {switch=3D1}</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
if ( switch=3D=3D1 &amp;&amp; $1!~/^[0-9][0-9]*$/) {</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; count=3D0</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; while ( ++count &lt;=3D NF ) {print $count}}}' | sort =
-u`</FONT>
</P>

<P><FONT SIZE=3D2>echo &quot;\n## Problem Detail by server...&quot; =
&gt;&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>for each in $svrlist</FONT>
<BR><FONT SIZE=3D2>do</FONT>
<BR><FONT SIZE=3D2>&nbsp; echo &quot;\n## Client: $each&quot; =
&gt;&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>&nbsp; bperror -client $each -columns $cols -U =
-problems -hoursago $hours &gt;&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>done</FONT>
</P>

<P><FONT SIZE=3D2>if [ `egrep -vc &quot;^ *$|^#&quot; $TMPFILE` -gt 0 ] =
; then</FONT>
<BR><FONT SIZE=3D2>&nbsp; mailx -s &quot;NB $shortname ${hours}hr =
Rpt:Problems Report&quot; $MAILADDR &lt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>fi</FONT>
</P>

<P><FONT SIZE=3D2>[ -f $TMPFILE ] &amp;&amp; rm -f $TMPFILE</FONT>
<BR><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.780C28B0--

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