Took me ages to find it as tek-tips forum search doesn't appear to be the best in the world; i found it eventually -
http://www.tek-tips.com/viewthread.cfm?qid=949271
I'll paste it here also, but not sure if the formatting will come across correctly.
Tape drive usage script (this runs 5pm thru 8am) -
# rrb 270104 - script to check tape drive usage overnight # - 15min intervals
echo >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
hostname >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
date >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo " ** Checking tape drives --> **" >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
/usr/openv/volmgr/bin/vmoprcmd|grep -v " Drive"|grep -v ADDIT|tail -9 >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo " ** Checking for any running backups --> **" >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
rm -rf /tmp/nfnfek /tmp/nfnfek1 /tmp/nfnfek2 /tmp/nfnfek1x
/usr/openv/netbackup/bin/admincmd/bpdbjobs -report|grep "CL"|grep -v Done|grep -v JobID|grep -v "DB Backup" |awk '{printf("%-6s %-6s %-25s %-12s %-1s %-1s %-1s\n", $1,$2,$3,$4,$6,$7,$8) ;}' >> /tmp/nfnfek
cat /tmp/nfnfek >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
cat /tmp/nfnfek|awk '{print $1}' | while read line ; do /usr/openv/netbackup/bin/admincmd/bperror -jobid $line | grep L1 | awk '{print $6,$23,$25,$26,$27}' | tail -1 ; done >> /tmp/nfnfek1
awk '{print $1," ",$2,$3,$4,$5}' /tmp/nfnfek1 > /tmp/nfnfek1x
echo "" >> /tmp/nfnfek2
echo "" >> /tmp/nfnfek2
echo " ** The JobID's above equate to the following tapes/drives --> **" >> /tmp/nfnfek2 echo "" >> /tmp/nfnfek2
cat /tmp/nfnfek2 /tmp/nfnfek1x >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
echo "------------------------------------------" >> /home/richardb/script-output/vmoprcmd-checks/vmoprcmd-check
rm -rf /tmp/nfnfek /tmp/nfnfek1 /tmp/nfnfek2 /tmp/nfnfek1x
Sample output from script (each 15mins that the script runs it appends to the below file) -
nthsunbackup
Tue Apr 19 17:15:00 BST 2005
** Checking tape drives --> **
Drv Type Control User Label RecMID ExtMID Ready Wr.Enbl. ReqId
0 hcart TLD root Yes 5951L1 5951L1 Yes Yes 1
1 hcart TLD root Yes 5946L1 5946L1 Yes Yes 2
2 hcart TLD root Yes 5754L1 5754L1 Yes Yes 3
3 hcart TLD root Yes 5804L1 5804L1 Yes Yes 4
4 hcart TLD root Yes 5919L1 5919L1 Yes Yes 5
5 hcart TLD root Yes 5807L1 5807L1 Yes Yes 0
** Checking for any running backups --> **
177705 Active CL_ATSI_genprod DailyFull 04/19/05 17:07:12 000:08:04
177707 Active CL_GENEVA_genprod DailyFull 04/19/05 17:07:12 000:08:04
177711 Active CL_ORACLEDB_dim_dimnsns DailyFull 04/19/05 17:07:12 000:08:04
177712 Active CL_ORACLEDB_dms DailyFull 04/19/05 17:07:12 000:08:04
177713 Active CL_UNIX_aros DailyFull 04/19/05 17:07:12 000:08:04
177714 Active CL_UNIX_crmprod DailyFull 04/19/05 17:07:12 000:08:04
177715 Active CL_UNIX_crmweb1 DailyFull 04/19/05 17:07:12 000:08:04
177716 Active CL_UNIX_crmweb2 DailyFull 04/19/05 17:07:12 000:08:04
177717 Active CL_UNIX_dim DailyFull 04/19/05 17:07:12 000:08:04
177718 Active CL_UNIX_dms DailyFull 04/19/05 17:07:12 000:08:04
177719 Active CL_UNIX_empow2 DailyFull 04/19/05 17:07:12 000:08:04
177720 Active CL_UNIX_emprod DailyFull 04/19/05 17:07:12 000:08:04
177721 Active CL_UNIX_genprod DailyFull 04/19/05 17:07:12 000:08:04
177722 Active CL_UNIX_swprod DailyFull 04/19/05 17:07:13 000:08:03
177725 Active CL_ORACLEDB_dms SCH_ORACLEDB 04/19/05 17:12:59 000:02:17
177726 Active CL_ORACLEDB_dms SCH_ORACLEDB 04/19/05 17:13:00 000:02:16
177727 Active CL_ORACLEDB_dms SCH_ORACLEDB 04/19/05 17:13:04 000:02:12
177728 Active CL_ORACLEDB_dim_dimnsns SCH_ORACLEDB 04/19/05 17:14:19 000:00:57
** The JobID's above equate to the following tapes/drives --> **
177705 5807L1 drive index 5
177707 5951L1 drive index 0
177713 5754L1 drive index 2
177714 5754L1 drive index 2
177715 5754L1 drive index 2
177716 5754L1 drive index 2
177717 5754L1 drive index 2
177718 5754L1 drive index 2
177719 5754L1 drive index 2
177720 5754L1 drive index 2
177721 5754L1 drive index 2
177722 5804L1 drive index 3
177725 5919L1 drive index 4
177726 5919L1 drive index 4
177727 5919L1 drive index 4
177728 5919L1 drive index 4
------------------------------------------
2nd script that runs next morning at 9, ie after first script has finished looping thru the night, then renames the output file to a uniquely dated file and gzip up all other output files -
#!/bin/ksh
export mydir=/home/richardb/script-output/vmoprcmd-checks
#gzip all except the newest logfile.
gzip $mydir/vmoprcmd-check_*
mv $mydir/vmoprcmd-check $mydir/vmoprcmd-check_`date '+%d%m%Y'`
rm -rf /tmp/nfnfek /tmp/nfnfek1 /tmp/nfnfek1x /tmp/nfnfek2
ls -l $mydir/vmoprcmd-check_`date '+%d%m%Y'` | /usr/ucb/mail -s "NetBackup - Previous night's tape drive stats complete - nthsunbackup @`date +%d/%m-%H:%M`" emailaddy@somewhere
Cron entries to drive the 2 scripts -(timing the rename of output file was a pain so it was easiest to just cron a simple script to do this at very end)
0,15,30,45 0,1,2,3,4,5,6,7,8,17,18,19,20,21,22,23 * * * /home/richardb/vmoprcmd-check.sh > /dev/null 2>&1
0 9 * * * /home/richardb/vmoprcmd-rename-logs.sh > /dev/null 2>&1
The above was the quickest way i could automate the tracking of drive usage and keeping a history. I tend to knock up this kind of (simplistic) script then find it's still working adequately without hardly any change for years at a time.
I also have separate scripts that run all the time, checking for down drives/no spare drives/drives in odd status etc (so i'll be alerted straight away), the above scripts are just for a history of drive usage that i refer to as and when..
Rich