Custom NetBackup Daily Report Script for Windows

I have created/modified some NetBackup scripts to be used for a Daily Status Report, which can be emailed to the NetBackup administrator every morning or whenever convenient (automatically running the script would need to be done through “Scheduled Tasks”). The below scripts will need to be copied exactly as text files to the same directory on the NetBackup Master server. Also, please name the scripts exactly what is in quotations, as other scripts may refer to that script by name.

“daily_err_report.cmd” Script


@echo off
:: daily_err_report    v1r1     Ed Gurski    07/10/02
:: Fixed bugs and Latest Updates, Converted by Dennis Laube, https://www.virtualdennis.com, 11/09
:: Added additional features and updates - Dennis Laube 1/10
::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * The purpose of this command is to report all errors that occured on * * * *
:: * * * * the previous evening's backup. This script will eliminate all successful * * * *
:: * * * * and partially successful backups. This command can be ran from a sched * * * *
:: * * * * task. A log (S<DATE>) of the output can be viewed in the directory * * * *
:: * * * * C:\netbackup_scripts * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * We will now set the system variables for the usage of the commands. * * * *
:: * * * * The initial settings for these variables will be set to their defaults * * * *
:: * * * * but can be changed during the command call... * * * *
:: * * * * All variables do not need to be reset since they are set as LOCAL to * * * *
:: * * * * command itself... * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
:R0000_Set
SETLOCAL ENABLEEXTENSIONS
set CONAME=My Company
set NBDIR=C:\progra~1\VERITAS\Netbackup\bin\admincmd
set BPDIR=C:\netbackup_scripts
set BPERROUT=%BPDIR%\stat.out
set BPTEMP=%BPDIR%\tmp.out
set BPWORK=%BPDIR%\dir.out
set NOERROR=%BPDIR%\noerr
set MSGHDR=%BPDIR%\hdr
set SPACING=%BPDIR%\spacing
:: You can additional email addresses separated by commas
set OPER1=netbackupadmin@mycompany.com
set OPER2=anotherperson@mycompany.com
SET Get_Date_Cmd=C:\netbackup_scripts\getdate.cmd
set HOURS=14
set Mail_Priority=0

:: *******************************************************************************************
::
:: We will now get the system date and from this will be be able to define the name of our
:: log file and email subject. The log file name has the format of Smmddyy.log..
::
:: *******************************************************************************************

:R0010_Set
cd %BPDIR%
Call %Get_Date_Cmd% %BPDIR%
set Err_Log=%BPDIR%\LOGS\S%Today%.log
set MAIL_SUBJECT=%CONAME% Daily Backup Error Report %Today%

:: *******************************************************************************************
:: * * * * * * * *
:: * * * * We will now check to see if any errors occurred in last night's * * * *
:: * * * * backups... * * * *
:: * * * * * * * *
:: *******************************************************************************************
:R0100_Error_Report
%NBDIR%\bperror -backstat -l -U -hoursago %HOURS% >%BPERROUT%

:: *******************************************************************************************
:: * * * * * * * *
:: * * * * We will now extract the header line for later use and eliminate all * * * *
:: * * * * successful and partially successful backups from the report. Then * * * *
:: * * * * we will eliminate all status codes of 0 and 1 from the report... * * * *
:: * * * * * * * *
:: *******************************************************************************************
:R0200_Hdr_Errors
findstr /v "STATUS partially" %BPERROUT%|findstr /vc:" 0 "|findstr /vc:" 1 " >%BPTEMP%
cat %BPTEMP%|findstr /v /b /c:" " >%BPWORK%

:: *******************************************************************************************
::
:: We will now check to see if any errors occurred and a message will be built with all the
:: errors that occurred.
::
:: *******************************************************************************************

:R0320_Errors
copy %MSGHDR% + %BPTEMP% %Err_Log%

:: *******************************************************************************************
::
:: The purpose of this section is to gather an overrall summary of jobs and list those in the
:: report that gets emailed. This summary shows how many jobs completed, failed and are active.
::
:: *******************************************************************************************

:R0350_Summary
type %SPACING% >>%Err_Log%
%NBDIR%\bpdbjobs -summary -L >>%Err_Log%
set Mail_Priority=1
pushd %BPDIR%
touch S%Today%.log
popd

:: *******************************************************************************************
::
:: Now we'll email this file using the blat utility to the specified operators.
::
:: *******************************************************************************************

:R0375_Mail
blat %Err_Log% -subject "%MAIL_SUBJECT%" -to %OPER1% -cc %OPER2% -priority %Mail_Priority%

:: If you want to only send the email to 1 person, comment out the above command and uncomment out the below
:: blat %Err_Log% -subject "%MAIL_SUBJECT%" -to %OPER1% -priority %Mail_Priority%

:: *******************************************************************************************
::
:: We will delete all work files used in this script...
::
:: *******************************************************************************************

:R9900_Clean_Up
del %BPDIR%\*.out

:EndMain

endlocal

“daily_success_report.cmd” Script

@echo off
::
:: daily_success_report    v1r1     Orig by Ed Gurski    07/10/02
:: Fixed bugs and Latest Updates, Converted by Dennis Laube, https://www.virtualdennis.com, 11/09
:: Added additional features and updates – Dennis Laube 1/10
::
:: *******************************************************************************************
:: The purpose of this script is to report on all successful backups that have ran during the
:: the past nights backup.
::
:: *******************************************************************************************
::
::
:: *******************************************************************************************
::
:: We will now set the system variables for the usage of the commands.
:: The initial settings for these variables will be set to their defaults
:: but can be changed during the command call…
:: All variables do not need to be reset since they are set as LOCAL to
:: command itself…
::
:: *******************************************************************************************
::

:R0000_Set
SETLOCAL ENABLEEXTENSIONS
set CONAME=My Company
set NBDIR=C:\progra~1\VERITAS\Netbackup\bin\admincmd
set BPDIR=C:\netbackup_scripts
set BPERROUT=%BPDIR%\stat.txt
set BPGOOD=%BPDIR%\good.txt
set BPWORK=%BPDIR%\dir.txt
set NOERROR=%BPDIR%\noerr
set MSGHDR=%BPDIR%\hdr
set SPACING=%BPDIR%\spacing
:: You can additional email addresses separated by commas
set OPER1=netbackupadmin@mycompany.com
set OPER2=someoneelse@mycompany.com
SET Get_Date_Cmd=C:\netbackup_scripts\getdate.cmd
set HOURS=14
set Mail_Priority=0

:: *******************************************************************************************
::
:: We will now get the system date and from this will be be able to define the name of our
:: log file and email subject. The log file name has the format of Gmmddyy.log..
::
:: *******************************************************************************************

:R0010_Set
cd %BPDIR%
Call %Get_Date_Cmd% %BPDIR%
set Good_Report=%BPDIR%\LOGS\G%Today%.log
set MAIL_SUBJECT=%CONAME% Daily Backup Success Report %Today%

:: *******************************************************************************************
:: * * * * * * * *
:: * * * * We will now check to see if any errors occurred in last night’s * * * *
:: * * * * backups… * * * *
:: * * * * * * * *
:: *******************************************************************************************

:R0100_Error_Report
%NBDIR%\bperror -backstat -l -U -hoursago %HOURS% >%BPERROUT%

 

:: *******************************************************************************************
::
:: We will now extract the header line for later use and eliminate all errored backups from
:: the report and only keep successful and partially successful backups.
::
:: *******************************************************************************************

:R0200_Hdr_Errors
findstr /c:” 0 ” %BPERROUT% >>%BPGOOD%
findstr /c:” 1 ” %BPERROUT% >>%BPGOOD%

:: *******************************************************************************************
::
:: We will now copy the header back into the report and take the successful and partial backups
:: and put them into a single file that will be emailed. Then we’ll also write this file to a
:: log file for later use.
::
:: *******************************************************************************************

:R0320_Good
copy %MSGHDR% + %BPGOOD% %Good_Report%

:: *******************************************************************************************
::
:: The purpose of this section is to gather an overrall summary of jobs and list those in the
:: report that gets emailed. This summary shows how many jobs completed, failed and are active.
::
:: *******************************************************************************************

:R0350_Summary
type %SPACING% >>%Good_Report%
%NBDIR%\bpdbjobs -summary -L >>%Good_Report%
set Mail_Priority=1
pushd %BPDIR%
touch G%Today%.log
popd

:: *******************************************************************************************
::
:: Now we’ll email this file using the blat utility to the specified operators.
::
:: *******************************************************************************************

:R0375_Mail
blat %Good_Report% -subject “%MAIL_SUBJECT%” -to %OPER1% -cc %OPER2% -priority %Mail_Priority%
:: blat %Good_Report% -subject “%MAIL_SUBJECT%” -to %OPER1% -priority %Mail_Priority%

:: *******************************************************************************************
::
:: We will delete all work files used in this script…
::
:: *******************************************************************************************

:R9900_Clean_Up
del %BPDIR%\*.txt

:EndMain

endlocal

“getdate.cmd” Script

@echo off
::
:: EBS_GETDATE v1r0     Ed Gurski    05/29/02
:: Updates by Dennis Laube, https://www.virtualdennis.com, 11/09
::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * The purpose of this command is to obtain the date and time that will * * * *
:: * * * * be used by all commands in the EBS to suffix their log files… * * * *
:: * * * * Additionally, this command will also obtain variables for day month and * * * *
:: * * * * whcih can be used by any of the calling commands…     * * * *
:: * * * * This is a called script and it will ensure that it is being * * * *
:: * * * * called with the appropriate parameters… * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * We will now set the system variables for the usage of the commands. * * * *
:: * * * * The initial settings for these variables will be set to their defaults * * * *
:: * * * * but can be changed during the command call… * * * *
:: * * * * All varaiables do not need to be reset since they are set as LOCAL to * * * *
:: * * * * command itself… * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
:R0000_Set
if    %1d==d goto R0110_Not_Called
goto R0099_Set

:R0110_Not_Called

echo ******* GETDATE cannot be started from a command line ********
goto R9999

:R0099_Set
SET GETDATE_DIR=%1
SET GETDATE=%GETDATE_DIR%\date.txt

::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * The purpose of this routine is to obtain the current date and day of * * * *
:: * * * * week from the system. The format of the date is “ddd mm/dd/yyyy”… * * * *
:: * * * * We will also set the global variables DOW (Day of Week), YEAR, * * * *
:: * * * * MONTH and DAY. We will also set the DATESTAMP and TODAY global variables * * * *
:: * * * * that are used for producing all log messages… * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
:R0100_GetDate

date /t >>%GETDATE%
for /F “tokens=1” %%i in (%GETDATE%) do set DOW=%%i
for /F “tokens=2 delims=/ ” %%i in (%GETDATE%) do set Month=%%i
for /F “tokens=3 delims=/ ” %%i in (%GETDATE%) do set Day=%%i
for /F “tokens=4 delims=/ ” %%i in (%GETDATE%) do set Year=%%i
del %GETDATE%
set Today=%Year%%Month%%Day%
set Datestamp=%DOW% %Month%/%Day%/%Year%

::
:: *******************************************************************************************
:: * * * * * * * *
:: * * * * The purpose of this routine is to obtain the current time of day * * * *
:: * * * * and then convert it to an HOUR and MINUTE variable… * * * *
:: * * * * We will need to ensure a zero-fill on the hour, so a check will be * * * *
:: * * * * be made to determine if we are a single digit hour and change it * * * *
:: * * * * accordingly… * * * *
:: * * * * * * * *
:: *******************************************************************************************
::
:R0200_GetTime

echo %TIME%>%GETDATE%

for /f “tokens=1 delims=:” %%i in (%GETDATE%) do set HOUR=%%i
if %HOUR% == 0 set HOUR=00
if %HOUR% == 1 set HOUR=01
if %HOUR% == 2 set HOUR=02
if %HOUR% == 3 set HOUR=03
if %HOUR% == 4 set HOUR=04
if %HOUR% == 5 set HOUR=05
if %HOUR% == 6 set HOUR=06
if %HOUR% == 7 set HOUR=07
if %HOUR% == 8 set HOUR=08
if %HOUR% == 9 set HOUR=09

for /f “tokens=2 delims=:” %%i in (%GETDATE%) do set MINUTE=%%i
del %GETDATE%

 

 

::
:: ********************************************************************************************
:: * * * * * * * *
:: * * * * The duplication process has now been completed and we will reset all * * * *
:: * * * * the variables used in this script and return control to the system… * * * *
:: * * * * * * * *
:: ********************************************************************************************
::
:R9900

:R9999

:EndMain
endlocal

“hdr” File

Netbackup Reporting automagically on the last 14 hours for all backups. Please do not reply
to this email. Thanks!

***************************************************************************

STATUS CLIENT POLICY SCHED SERVER TIME COMPLETED
—————————————————————————

 

“spacing” File

***************************************************************************

 

Custom NetBackup Daily Report Script for Unix/Linux

I have created/modified some NetBackup scripts to be used for a Daily Status Report, which can be emailed to the NetBackup administrator every morning or whenever convenient (automatically running the script would need to be done through “crond” or some other scheduler). The below scripts will need to be copied exactly as text files to the same directory on the NetBackup Master server. Also, please name the scripts exactly what is in quotations, as other scripts may refer to that script by name.

"Daily-Backup-Status-Report" Script

#!/bin/bash
#########################################################################
#
# Script to generate a Daily Backup Status Report
# Original Creation Date by David A. Chapa: 11/19/97
# Modification by Dennis L. & Roger Y.: 12/02/97
# 1/2010 & 9/2010 Major Update & Modification by Dennis Laube, https://www.virtualdennis.com
#
# This script generates a status report with the following info:
# -Status of all client backups within the specified timeframe
# -Per Policy Data amount for the last 7 days
# -Per Policy Data amount for the last 24 hours
# -Tape Library Status including number of tapes inside & outside the library
# -Mails the complete report to the "someone_who_cares" variable.
#
# Requires this script as well as "amountprclass", "amountprclass24" and # "tapestat" to be placed under the "WORKINGDIR" location.
#
# When running this script manually, you will see multiple "no entity found" messages. This is normal.
#
#########################################################################
#
#Change this value to email a group or individual
someone_who_cares=backupadmin@mycompany.com
COMPANY="My Company"

#Change this value to search further back into the error reports
HOURSAGO=18

#Specify the location of the required scripts, including this one
WORKINGDIR=/root/netbackup_scripts

#The remaining stuff below shouldn't need to be edited
COUNT=0
OUTPUT=/tmp/unixstats1
OUTPUT1=/tmp/goodunix
ADMCMD=/usr/openv/netbackup/bin/admincmd
FORM1=" Successful Backup Jobs"
FORM2=" *************************************************"
FORM7=" Code"
FORM3="Status Client Policy SCHED Server Time "
FORM4="==============================================================================="
FORM5=" Detailed Error Report"
FORM6="_______________________________________________________________________________"
#
# Get rid of any old output files if they are there.

if [ -s $OUTPUT ]
then
rm $OUTPUT
fi
if [ -s $OUTPUT1 ]
then
rm $OUTPUT1
fi

# Format Report with Title, etc.
echo "`date +%m/%d/%y` `date +%H:%M`" > $OUTPUT echo "Netbackup Reporting automagically on the last "$HOURSAGO" hours for all backups. Please do not reply to this email. Thanks! "Ran at: `date +%m/%d/%Y`" ("`date +%H:%M`")" > $OUTPUT echo >> $OUTPUT echo "$FORM6" >> $OUTPUT echo >> $OUTPUT echo "$FORM1" >> $OUTPUT echo "$FORM2" >> $OUTPUT echo "" >> $OUTPUT echo "$FORM4" >>$OUTPUT echo "$FORM3" >> $OUTPUT echo "$FORM7" >> $OUTPUT echo "$FORM4" >>$OUTPUT echo >> $OUTPUT

# Begin Main Script
for i in `$ADMCMD/bpplclients | grep -v "Hardware" | (tee) | cut -c35-68` do
    $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | fgrep " 0 ">> $OUTPUT
    $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | fgrep " 0 " | cut -c8-20 >> $OUTPUT1
    $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | fgrep " 1 ">> $OUTPUT
    $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | fgrep " 1 " | cut -c8-20 >> $OUTPUT1 done #
# Looking for Backups with Status code 1 too because those are
# partially successful and a backup image was created for them
############################################################################
############################################################################
# Now that the successful backups were reported,
# its time to log the errors
echo >> $OUTPUT
echo >> $OUTPUT
echo >> $OUTPUT
echo >> $OUTPUT
echo "$FORM5" >> $OUTPUT
echo "$FORM6" >> $OUTPUT
echo >> $OUTPUT

for i in `$ADMCMD/bpplclients | grep -v "Hardware" | (tee) | cut -c35-68` do
    fgrep "$i" "$OUTPUT1" > /dev/null 2>&1
    if [ $? = 0 ]
    then
        continue
    fi

    $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | egrep -v STATUS | egrep -v " 0 " > /dev/null
    if [ $? = 0 ]
    then
        echo >> $OUTPUT
        echo >> $OUTPUT
        echo "Error Log Report for Client $i" >> $OUTPUT
        echo >> $OUTPUT
        echo >> $OUTPUT
        $ADMCMD/bperror -U -backstat -hoursago $HOURSAGO -client $i | egrep -v STATUS | egrep -v " 0 " >> $OUTPUT
        echo $FORM6 >> $OUTPUT
        $ADMCMD/bperror -U -problems -hoursago $HOURSAGO -client $i >> $OUTPUT
        echo >> $OUTPUT
        echo $FORM4 >> $OUTPUT
        echo >> $OUTPUT
        COUNT=`echo "$COUNT+1" | bc`
    fi
done

# Run "amountprclass24" script and insert into report
echo "Amount of Data Backed Up for the last 24 hours" >> $OUTPUT
$WORKINGDIR/amountprclass24 >> $OUTPUT
echo >> $OUTPUT
echo >> $OUTPUT

# Run "amountprclass" script and insert into report
echo "Amount of Data Backed Up for the last 7 days" >> $OUTPUT $WORKINGDIR/amountprclass >> $OUTPUT echo >> $OUTPUT echo >> $OUTPUT

# Run "tapestat" script to show number of tapes in each pool and if either onsite/offsite
echo "Tape Status & Location" >> $OUTPUT $WORKINGDIR/tapestat >> $OUTPUT echo >> $OUTPUT echo >> $OUTPUT

# Now we can e-mail it to the right person
today=`date +%m/%d/%y`
#
# Uncomment if you want this to be sent to someone_who_cares
cat $OUTPUT | mail -s "$COMPANY Morning Backup Report ( $today $COUNT bad )" $someone_who_cares

 

"amountprclass" Script

#!/bin/ksh
#
################################################################################
# This script will list the amount of data that was backed up in the last 7 days
# listed per policy.
#
# Updates 2010 by Dennis Laube, https://www.virtualdennis.com
################################################################################
#
# Variables
BPPATH=/usr/openv/netbackup/bin/admincmd
DBPATH=/usr/openv/netbackup/db
sumtotkb=0

# list classes
$BPPATH/bppllist |
while read class
do

# calculating sum of the kilobytes
sumkb=0
$BPPATH/bpimagelist -A -L -class $class -hoursago 168 2>/dev/null | grep "^Kilobytes" |
while read txt kb
do
let sumkb=${sumkb}+${kb}
done # calculating sum of kilobytes

# Make the output more human readable
outtxt="$sumkb kb"
echo "$sumkb/1024" | bc -l | read sumMB
if [ $sumMB -gt 0 ]; then
printf "%7.2f %s" $sumMB "MB" | read outtxt
fi
echo "$sumMB/1024" | bc -l | read sumGB
if [ $sumGB -gt 0 ]; then
printf "%7.2f %s" $sumGB "GB" | read outtxt
fi
printf "%-40s %6s %2s\n" $class $outtxt
let sumtotkb=${sumtotkb}+${sumkb}
done # reading classes
outtxt="$sumtotkb kb"
echo "$sumtotkb/1024" | bc -l | read sumMB
if [ $sumMB -gt 0 ]; then
printf "%7.2f %s" $sumMB "MB" | read outtxt
fi
echo "$sumMB/1024" | bc -l | read sumGB
if [ $sumGB -gt 0 ]; then
printf "%7.2f %s" $sumGB "GB" | read outtxt
fi
echo "$sumGB/1024" | bc -l | read sumTB
if [ $sumTB -gt 0 ]; then
printf "%7.2f %s" $sumTB "TB" | read outtxt
fi
# Print results
printf "%-45s %6s %2s\n" "Total Amount" $outtxt

 

"amountprclass24" Script

#!/bin/ksh
#
################################################################################
# This script will list the amount of data that was backed up in the last 24 hrs
# listed per policy.
#
# Various Updates 2010 by Dennis Laube, https://www.virtualdennis.com
################################################################################
#
# Variables
BPPATH=/usr/openv/netbackup/bin/admincmd
DBPATH=/usr/openv/netbackup/db
sumtotkb=0

# list classes
$BPPATH/bppllist |
while read class
do

# calculating sum of the kilobytes
sumkb=0
$BPPATH/bpimagelist -A -L -class $class -hoursago 24 2>/dev/null | grep "^Kilobytes" |
while read txt kb
do
let sumkb=${sumkb}+${kb}
done # calculating sum of kilobytes

# Make the output more human readable
outtxt="$sumkb kb"
echo "$sumkb/1024" | bc -l | read sumMB
if [ $sumMB -gt 0 ]; then
printf "%7.2f %s" $sumMB "MB" | read outtxt
fi
echo "$sumMB/1024" | bc -l | read sumGB
if [ $sumGB -gt 0 ]; then
printf "%7.2f %s" $sumGB "GB" | read outtxt
fi
printf "%-40s %6s %2s\n" $class $outtxt
let sumtotkb=${sumtotkb}+${sumkb}
done # reading classes
outtxt="$sumtotkb kb"
echo "$sumtotkb/1024" | bc -l | read sumMB
if [ $sumMB -gt 0 ]; then
printf "%7.2f %s" $sumMB "MB" | read outtxt
fi
echo "$sumMB/1024" | bc -l | read sumGB
if [ $sumGB -gt 0 ]; then
printf "%7.2f %s" $sumGB "GB" | read outtxt
fi
echo "$sumGB/1024" | bc -l | read sumTB
if [ $sumTB -gt 0 ]; then
printf "%7.2f %s" $sumTB "TB" | read outtxt
fi
# Print results
printf "%-45s %6s %2s\n" "Total Amount" $outtxt

 

"tapestat" Script

#!/usr/bin/ksh
#
# This script shows the current tape status by pool. It will show how many tapes are in the
# robot versus how many tapes are outside the robot as well as the overall total of tapes
# per pool.
# Written by Dennis Laube, https://www.virtualdennis.com with initial help from Roger Yarrow.
# 1/10 - Updates to script performed, testing with NBU 6.5
# 10/10 - Updates for RedHat, Testing with NBU 7
#
#
# Variables
#
#Change the below variables to reflect the hostnames of your Master and Media Servers
MASTER=netbackup1.mycompany.com
MEDIA=NBU-media2.mycompany.com
VMQUERY=/tmp/vmquery.$$.out
VMPOOL=/tmp/vmpool.$$.out
VMHOST=`/usr/openv/volmgr/bin/tpconfig -d | grep "robot control host" | sed 's/^.*host = //'`
RTYPE=TLD
VOLMGR=/usr/openv/volmgr/bin

# Its sloppy but it works!, Leave commented out
#DL RTYPE=`/usr/openv/volmgr/bin/tpconfig -d | tail -2 | sed 's/(0).*$//' | awk '{print $1}' | head -n 1`
#typeset -l rt=$RTYPE

/bin/rm -f $VMQUERY $VMPOOL

# List out formating for data
echo "Poolname\t\t outside \t inside \t total"
echo " \t\t robot \t robot \t number"
echo "---------------------------------------------------------------"
$VOLMGR/vmcheckxxx -h $MASTER -list -rt $RTYPE -rn 0 -rh $MEDIA > /tmp/inrobot
$VOLMGR/vmpool -h $MASTER -listall -b | tail | sort > $VMPOOL
cat $VMPOOL |
while read POOLNAME line
do
if [ "$POOLNAME" = "DONTUSE" ]; then
continue
fi

#DL $VOLMGR/vmquery -h $MASTER -pn $POOLNAME -b | tail +4 > $VMQUERY
$VOLMGR/vmquery -h $MASTER -pn $POOLNAME -b > $VMQUERY
POOLNAME=`echo "$POOLNAME " | cut -c -20`
ntapestot=`cat $VMQUERY | wc -l`
echo $ntapestot | read tal1
let sumtot=${sumtot}+${tal1}
ntapesin=`cat $VMQUERY | grep $RTYPE | wc -l`
echo $ntapesin | read tal1
let sumin=${sumin}+${tal1}
ntapesin=${tal1}
ntapesout=`cat $VMQUERY | grep NONE | wc -l`
echo $ntapesout | read tal1
let sumout=${sumout}+${tal1}
ntapesout=${tal1}
inrobot=0
cat $VMQUERY | grep NONE |
while read mediaid line
do
INROBOT=`grep $mediaid /tmp/inrobot`
if [ -n "$INROBOT" ]; then
let inrobot=${inrobot}+1
fi
done

let ntapesout=${ntapesout}-${inrobot}
let ntapesin=${ntapesin}+${inrobot}
let sumout=${sumout}-${inrobot}
let sumin=${sumin}+${inrobot}
tapesin=`echo "${ntapesin}"`
#printf "%20s%10d%16d%16d\n" "$POOLNAME" ${ntapesout} ${ntapesin} ${ntapestot}
DISYES=`echo $POOLNAME | grep -i disaster`
if [ -n "$DISYES" ]; then
POOLNAME=`echo "$POOLNAME(scratch) " | cut -c -20`
count=0
cat $VMQUERY |
while read mediaid mediatype robottype robotnum robotslot side op vol mnts lmntdate lmnttime asgndate asgntime pool
do
if [ "${asgndate}" = "---" -a "${asgntime}" = "---" -a "${robottype}" != "NONE" ]; then
let count=${count}+1
fi
done
tapesin=`echo "${ntapesin}($count)"`
fi
printf "%20s%10d%16s%16d\n" "$POOLNAME" ${ntapesout} $tapesin ${ntapestot}
done
echo "---------------------------------------------------------------"
printf "%20s%8d%16d%16d\n" "Total number of tapes:" $sumout $sumin $sumtot
echo "==============================================================="

#Clean up after ourselves
/bin/rm -f $VMQUERY $VMPOOL