Veritas-bu

[Veritas-bu] Summary: relating files and images to tapes

2002-04-19 13:39:17
Subject: [Veritas-bu] Summary: relating files and images to tapes
From: Will.Enestvedt AT jwu DOT edu (William Enestvedt)
Date: Fri, 19 Apr 2002 13:39:17 -0400
>
> I should be able to script this up pretty neatly, and if 
> I finish before someone else does, I'll post the script.
> 
   My hurried, sloppy, effective-rnough script follows. Some of the lines
are too long, but I forgot to manually wrap them; knowing this may help make
the text below intelligible to you once Outlook munges it.
   I'm a lazy git, so I just have the script read two scratch file back and
forth onto each other instead of properly handling the data in a single
stream.
   Sample output looks like this
- - - - - - - - - - - - - - - - - - - -
3363 : dat-07 to app-04: status 0 at 20:30:25 on 04/18
3363 : tape SN1016
3364 : app-07 to app-09: status 0 at 20:26:22 on 04/18
3364 : tape SN1011
3365 : app-09 to app-09: status 0 at 20:27:09 on 04/18
3365 : tape SN1011
- - - - - - - - - - - - - - - - - - - -
Key:
- - - - -
JobID : "NBU client" to "media server": "exit status" at "time finished" on
"date finished"
JobID : tape "media ID"
- - - - -
   Is this of any use?
-wde
--
Will Enestvedt
UNIX System Administrator
Johnson & Wales University -- Providence, RI
------------------------------------------------------------------------
#!/bin/sh

#
# Declare some variables.
#
TEMPFILE=/tmp/nbu_temp.$$
SCRATCHFILE=/tmp/nbu_temp2.$$
USEFILE=/tmp/nbu_temp3.$$
SUBJ="abbreviated_bperror_output"
RECIPIENT="root"

#
# Gather the raw data and dump it into a scratch file,
# after flushing complketed jobs into the "done" directory
# with the "bpdbjobs -clean" command.
#
/opt/openv/netbackup/bin/admincmd/bpdbjobs -clean -keep_days 5;
/opt/openv/netbackup/bin/admincmd/bperror -backstat -hoursago 19 -L >
$TEMPFILE;
#
# The next few lines wil clean up the raw data, swapping back and 
# forth between two scratch files.
#
grep -v "^$" $TEMPFILE | grep -v "BackStat" | grep -v "[a-z])$" >> $USEFILE;

sed 's/ V1//g' $USEFILE >$SCRATCHFILE;
sed 's/ SCHED//g' $SCRATCHFILE >$USEFILE;
sed 's/ CLASS//g' $USEFILE >$SCRATCHFILE;
sed '/0)$/ { 
 N
 s/0)\n  CLIENT/0) Client/g
}' $SCRATCHFILE >$USEFILE;
sed 's/(client//g' $USEFILE >$SCRATCHFILE;
sed 's/.jwu.edu//g' $SCRATCHFILE >$USEFILE;
sed 's/J:/Job /g' $USEFILE >$SCRATCHFILE;
sed 's/EXIT STATUS/Exit status/g' $SCRATCHFILE | sort -o $USEFILE -k 6,6;
#
# Print the tidy data to a scratch file; each line begins 
# with a job id, to enable sorting later.
#
awk ' {print $6, ":", substr($9,5,6), "to", substr($3,7,6) ":", $13,
$14,"at", $
2, "on", substr($1,1,5)} ' $USEFILE >$SCRATCHFILE ;
#
# Now use each job id to search through the files in
# /opt/opemv/netbackup/db/jobs/done* to find out the tape 
# that was used (by looking for the string "MOUNTING" in 
# the file with a name that starts with the job id and 
# ends in ".t"). Also, clean up the data before writing 
# it to a scratch file; as above, each line begins with a 
# job id, to enable sorting later.
#
grep "MOUNTING" `awk ' { print "/opt/openv/netbackup/db/jobs/done/"$1"*t" }
' $S
CRATCHFILE` | \
sed 's/\/opt\/openv\/netbackup\/db\/jobs\/done\///g' | sed
's/.t:MOUNTING//g' | 
\
awk ' {print substr($1,1,4), ": tape", $3} ' >> $SCRATCHFILE;
#
# now sort the combined data by the first field on each 
#line, the job id, and dump it into a scratch file.
#
sort $SCRATCHFILE > $USEFILE;
#
# Append a line indicating the script's location.
#
echo "\n--\nScript: /export/home/wenestve/nbu_daily_status_and_tapes.sh" >>
$USE
FILE;
#
# Now generate the email.
#
cat $USEFILE | mailx -s $SUBJ $RECIPIENT;
#
# Clean-up of temporary file(s).
#
rm $TEMPFILE;
rm $SCRATCHFILE;
rm $USEFILE;
#
# And quit.
#
exit 0;
------------------------------------------------------------------------