cancel
Showing results for 
Search instead for 
Did you mean: 
Don_Wilder
Level 3

I am not the original author of this script, but have modified and maintained it over the years.

 

#!/usr/bin/ksh
#----------------------------------------------------------------------
# Keith G. Deems
# Check drives, bring drive up if down, email Staff
# If drives are up, do not create a report, runs from cron
#----------------------------------------------------------------------
#
#  Modified by DSK on 2/19/03 to only send out if drive is down.  Also major cleanup.
#  LG4 added code below to up the downed drive.
#  04 Jun 2006 -- Dwilder -- added external media server list.
#  16 Apr 2007 -- dwilder -- Added function to check for active ltid and log if not active.
#
# Add interested parties below:
someone_who_cares=someone@somewhere.com

# The report temp file goes here
DRIVELOG=/tmp/drivelog

# get the list of servers to test.
#   We manually create a file containing the mediaservers we want to monitor called "media_server_list"
#   and comment out a server when we have one offline for an extended time.
server_list=`grep -v '^#' /usr/openv/nbu_scripts/media_server_list`
# If you want to automatically select all your mediaservers comment out the above line and uncomment the below line:
#server_list=`/usr/openv/netbackup/bin/admincmd/nbemmcmd -listhosts | egrep "^(media |master )" | awk '{print $2}'`

# cleanup previous run file
rm -f ${DRIVELOG}

# begin loop of servers to check
for f in ${server_list};
do {
  # Test to see if the ltid process is active on the server
  test_server=`/usr/openv/volmgr/bin/vmoprcmd -h $f -d ds 2>&1 | grep "not active"`
  if [ ! -z $test_server ]
  then
        /usr/bin/date >> ${DRIVELOG}
        echo " " >> ${DRIVELOG}
        echo " " >> ${DRIVELOG}
        echo "The Media Manager device daemon (ltid) is not active on host ${f}" >> ${DRIVELOG}
  else
  {
    # Get the status of any down drives on the server
    status=`/usr/openv/volmgr/bin/vmoprcmd -h $f -d ds | grep "DOWN" 2>&1`
    if [ ! -z $status ]
    then
        /usr/bin/date >> ${DRIVELOG}
        echo " " >> ${DRIVELOG}
        echo " " >> ${DRIVELOG}
        echo "Please check drives on MASTER: ${f}" >> ${DRIVELOG}
        echo "Drv Type   Control  User      Label  RecMID  ExtMID  Ready   Wr.Enbl.  ReqId" >> ${DRIVELOG}
        echo "${status} " >> ${DRIVELOG}
        echo "Attempting to place drive(s) in UP status" >> ${DRIVELOG}
        echo "" >> ${DRIVELOG}
        for i in `/usr/openv/volmgr/bin/vmoprcmd -h $f -d ds | tail +5 | grep "DOWN"|awk '{print $1}'`
        do
           /usr/openv/volmgr/bin/vmoprcmd -h $f -up $i >> ${DRIVELOG} 2>&1
        done
        echo "" >> ${DRIVELOG}
        echo "Drive status (all drives should have UP status):" >> ${DRIVELOG}
        /usr/openv/volmgr/bin/vmoprcmd -h $f -d ds >> ${DRIVELOG}
    fi
    }
  fi # active ltid?
  }
done

##  send report if it has content
MDATE=`date +%d-%b-%Y`
if [ -s ${DRIVELOG} ]
then
        echo " " >> ${DRIVELOG}
        echo " " >> ${DRIVELOG}
        cat ${DRIVELOG} | /usr/bin/mailx -s "NBU Tape Drive Status Report - ${MDATE}" ${someone_who_cares}
fi

#  EOF

Comments
ontherocks
Level 6
Partner Accredited Certified

Good Script

Version history
Last update:
‎09-01-2011 06:09 AM
Updated by: