Veritas-bu

[Veritas-bu] Notification of Pending Request for media

2002-03-29 12:10:57
Subject: [Veritas-bu] Notification of Pending Request for media
From: Mark.Donaldson AT experianems DOT com (Donaldson, Mark)
Date: Fri, 29 Mar 2002 10:10:57 -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_01C1D744.B1208150
Content-Type: text/plain

Yup - I ended up writing a cron script for monitoring pending tape requests.
It alerts when the PR comes in, and re-alerts when the tape usage is
complete (for removing from the external drive).  It's only ~40 lines so
I'll post it here - be sure to change the e-mail addr for your pager... Be
sure to clear the temp files on reboot if your system does not automatically
clear /tmp at boot.  I run it on a 10-min cycle.
-Mark

#!/bin/sh

PATH=$PATH:/usr/openv/volmgr/bin ; export PATH

PENDFILE=/tmp/`basename $0`.PEND
LIVEFILE=/tmp/`basename $0`.LIVE
HISTFILE=/tmp/`basename $0`.HIST
TMPFILE=/tmp/`basename $0`.TMP

MAILADDR="PAGERADDR AT SERVICE DOT COM"

>$TMPFILE
[ ! -f $HISTFILE ] && touch $HISTFILE
vmoprcmd -d pr | awk '$1~/[0-9]/ {print $3}' >$PENDFILE
vmoprcmd -d ds | awk '$8=="Yes"  {print $6}' >$LIVEFILE

#If PEND not in HIST then new tape req - send alert
for tape in `cat $PENDFILE`
do
  if [ `grep -c $tape $HISTFILE` -eq 0 ]
  then
    #New tape PENDING - Track it and send mail
    echo "Netbackup requests tape $tape." | mailx -s "NB_PEND: $tape"
$MAILADDR
    echo "$tape" >>$TMPFILE
  fi
done

#If HIST not in LIVE or PEND then tape done - else still in use
for tape in `cat $HISTFILE`
do
  if [ `grep -c $tape $LIVEFILE` -eq 0 -a `grep -c $tape $PENDFILE` -eq 0 ]
  then
    #Tape we were tracking is gone - must be done...
    echo "Netbackup is done with tape $tape." | mailx -s "NB_DONE: $tape"
$MAILADDR
  else
    #Tape we were tracking is mounted or still pending - continue to track
    echo "$tape" >>$TMPFILE
  fi
done
mv $TMPFILE $HISTFILE
rm $LIVEFILE $PENDFILE
exit

------_=_NextPart_001_01C1D744.B1208150
Content-Type: text/html
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=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Veritas-bu] Notification of Pending Request for =
media</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Yup - I ended up writing a cron script for monitoring =
pending tape requests.&nbsp; It alerts when the PR comes in, and =
re-alerts when the tape usage is complete (for removing from the =
external drive).&nbsp; It's only ~40 lines so I'll post it here - be =
sure to change the e-mail addr for your pager... Be sure to clear the =
temp files on reboot if your system does not automatically clear /tmp =
at boot.&nbsp; I run it on a 10-min cycle.</FONT></P>

<P><FONT SIZE=3D2>-Mark</FONT>
</P>

<P><FONT SIZE=3D2>#!/bin/sh</FONT>
</P>

<P><FONT SIZE=3D2>PATH=3D$PATH:/usr/openv/volmgr/bin ; export =
PATH</FONT>
</P>

<P><FONT SIZE=3D2>PENDFILE=3D/tmp/`basename $0`.PEND</FONT>
<BR><FONT SIZE=3D2>LIVEFILE=3D/tmp/`basename $0`.LIVE</FONT>
<BR><FONT SIZE=3D2>HISTFILE=3D/tmp/`basename $0`.HIST</FONT>
<BR><FONT SIZE=3D2>TMPFILE=3D/tmp/`basename $0`.TMP</FONT>
</P>

<P><FONT SIZE=3D2>MAILADDR=3D&quot;PAGERADDR AT SERVICE DOT COM&quot;</FONT>
</P>

<P><FONT SIZE=3D2>&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>[ ! -f $HISTFILE ] &amp;&amp; touch $HISTFILE</FONT>
<BR><FONT SIZE=3D2>vmoprcmd -d pr | awk '$1~/[0-9]/ {print $3}' =
&gt;$PENDFILE</FONT>
<BR><FONT SIZE=3D2>vmoprcmd -d ds | awk '$8=3D=3D&quot;Yes&quot;&nbsp; =
{print $6}' &gt;$LIVEFILE</FONT>
</P>

<P><FONT SIZE=3D2>#If PEND not in HIST then new tape req - send =
alert</FONT>
<BR><FONT SIZE=3D2>for tape in `cat $PENDFILE`</FONT>
<BR><FONT SIZE=3D2>do</FONT>
<BR><FONT SIZE=3D2>&nbsp; if [ `grep -c $tape $HISTFILE` -eq 0 ]</FONT>
<BR><FONT SIZE=3D2>&nbsp; then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; #New tape PENDING - Track it and =
send mail</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; echo &quot;Netbackup requests =
tape $tape.&quot; | mailx -s &quot;NB_PEND: $tape&quot; =
$MAILADDR</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; echo &quot;$tape&quot; =
&gt;&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>&nbsp; fi</FONT>
<BR><FONT SIZE=3D2>done</FONT>
</P>

<P><FONT SIZE=3D2>#If HIST not in LIVE or PEND then tape done - else =
still in use</FONT>
<BR><FONT SIZE=3D2>for tape in `cat $HISTFILE`</FONT>
<BR><FONT SIZE=3D2>do</FONT>
<BR><FONT SIZE=3D2>&nbsp; if [ `grep -c $tape $LIVEFILE` -eq 0 -a `grep =
-c $tape $PENDFILE` -eq 0 ]</FONT>
<BR><FONT SIZE=3D2>&nbsp; then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; #Tape we were tracking is gone - =
must be done...</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; echo &quot;Netbackup is done with =
tape $tape.&quot; | mailx -s &quot;NB_DONE: $tape&quot; =
$MAILADDR</FONT>
<BR><FONT SIZE=3D2>&nbsp; else</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; #Tape we were tracking is mounted =
or still pending - continue to track</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; echo &quot;$tape&quot; =
&gt;&gt;$TMPFILE</FONT>
<BR><FONT SIZE=3D2>&nbsp; fi</FONT>
<BR><FONT SIZE=3D2>done</FONT>
<BR><FONT SIZE=3D2>mv $TMPFILE $HISTFILE</FONT>
<BR><FONT SIZE=3D2>rm $LIVEFILE $PENDFILE</FONT>
<BR><FONT SIZE=3D2>exit</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C1D744.B1208150--

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