[Veritas-bu] Notification of Pending Request for media
2002-03-29 12:10:57
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. 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.</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"PAGERADDR AT SERVICE DOT COM"</FONT>
</P>
<P><FONT SIZE=3D2>>$TMPFILE</FONT>
<BR><FONT SIZE=3D2>[ ! -f $HISTFILE ] && touch $HISTFILE</FONT>
<BR><FONT SIZE=3D2>vmoprcmd -d pr | awk '$1~/[0-9]/ {print $3}' =
>$PENDFILE</FONT>
<BR><FONT SIZE=3D2>vmoprcmd -d ds | awk '$8=3D=3D"Yes" =
{print $6}' >$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> if [ `grep -c $tape $HISTFILE` -eq 0 ]</FONT>
<BR><FONT SIZE=3D2> then</FONT>
<BR><FONT SIZE=3D2> #New tape PENDING - Track it and =
send mail</FONT>
<BR><FONT SIZE=3D2> echo "Netbackup requests =
tape $tape." | mailx -s "NB_PEND: $tape" =
$MAILADDR</FONT>
<BR><FONT SIZE=3D2> echo "$tape" =
>>$TMPFILE</FONT>
<BR><FONT SIZE=3D2> 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> if [ `grep -c $tape $LIVEFILE` -eq 0 -a `grep =
-c $tape $PENDFILE` -eq 0 ]</FONT>
<BR><FONT SIZE=3D2> then</FONT>
<BR><FONT SIZE=3D2> #Tape we were tracking is gone - =
must be done...</FONT>
<BR><FONT SIZE=3D2> echo "Netbackup is done with =
tape $tape." | mailx -s "NB_DONE: $tape" =
$MAILADDR</FONT>
<BR><FONT SIZE=3D2> else</FONT>
<BR><FONT SIZE=3D2> #Tape we were tracking is mounted =
or still pending - continue to track</FONT>
<BR><FONT SIZE=3D2> echo "$tape" =
>>$TMPFILE</FONT>
<BR><FONT SIZE=3D2> 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--
|
|
|