#! /bin/sh
# $Header: cleanstats.sh,v 1.2.24.1 2004/01/15 15:39:09 $
#
#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2004 VERITAS Software Corporation, All Rights Reserved $
#***************************************************************************
#
# cleanstats
#
# This script can be used by an administrator as a convenient way to check 
# the status of the cleaning tape(s) and the # of hours drives have been used
# since last cleaning.  It may be used in a crontab entry to get the cleaning
# status mailed to you once per day.
#
# Refer to the tpclean(1M) man page for information on how to set
# cleaning frequency and to enable automatic cleaning of robotic drives.
# Note that cleaning media must be defined in the Media Manager volume database
# for automatic cleaning to occur.

/usr/openv/netbackup/bin/admincmd/bpauthorize -test_admin >/dev/null
status=$?
if [ ${status} -ne 0 ] ; then
	echo ""
	echo "You do not have the proper authorization to perform"
	echo "this task.  Please resolve and try again."
	exit ${status}
fi


if [ -x /etc/tpclean ]
then
        TPCLEAN=/etc/tpclean
else
        if [ -x /usr/openv/volmgr/bin/tpclean ]
        then
                TPCLEAN=/usr/openv/volmgr/bin/tpclean
        else
                echo " "
                echo "  tpclean:  command not found"
                echo " "
                exit 1
        fi
fi


echo " "
echo "DRIVE INFO:"
echo "----------"
echo " "
$TPCLEAN -l

echo " "
echo "MEDIA INFO:"
echo "----------"
echo " "
# display headers with first query; omit headers for the other queries
/usr/openv/volmgr/bin/vmquery -mt 8mm_clean -b 2> /dev/null
/usr/openv/volmgr/bin/vmquery -mt 8mm2_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt 4mm_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt dlt_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt dlt2_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt hcart_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt hcart2_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt d2_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt dtf_clean -b 2> /dev/null | tail +4
/usr/openv/volmgr/bin/vmquery -mt site2_clean -b 2> /dev/null | tail +4
