See attached the script we use for this purpose.
starts from cron every 10 minutes.

R Jeroen


-----Original Message-----
From: ADSM: Dist Stor Manager [mailto:[EMAIL PROTECTED] Behalf Of
Sung Y Lee
Sent: woensdag 16 februari 2005 22:30
To: [email protected]
Subject: 3584 Tape Drive Usage Information


Howdy folks,

In 3584 Library with LTO drives, is there a way to find out tape drives
utilization information? How long the tape has been used(not idle state)
per drive?
Not from TSM, but more like from OS level.  This is for AIX.  But if you
have some sort of  select command  from TSM that would be wonderful also.
I am looking into creating kinda of report that displays Drive#, Used
Duration,  Period.  Thank you.

Sung Y. Lee
export ID=xxxxx
export PA=yyyyy

# Make an logfile per day of week
DOW=$(date +%w)
OUT=${0}.${DOW}.out

# Clear file if older than 2 days
if [ -f ${OUT} ]
then
   if [ $(find ${OUT} -mtime +2 | wc -l) -gt 0 ]
   then
      > ${OUT}
   fi
fi

# Set date time
DATETIME=$(date +%y/%m/%d-%H:%M:%S)

# detect tsm servername
dsmadmc -id=${ID} -pa=${PA} -comma "select SERVER_NAME from status > 
/tmp/servername${$}.tmp" > /dev/null
if [ ${?} -ne 0 ]
then
   # tsm not active
   echo "${DATETIME},TSM Not Active" >> ${OUT}
   exit
else
   SERERNAME=$(cat /tmp/servername${$}.tmp)
fi

# Collect information for drives mounts processes and sessions
dsmadmc -id=${ID} -pa=${PA} -comma "query mount > /tmp/mount${$}.tmp" > 
/dev/null
dsmadmc -id=${ID} -pa=${PA} -comma "select drive_name,drive_state,allocated_to 
from drives > /tmp/drives${$}.tmp" > /dev/null
dsmadmc -id=${ID} -pa=${PA} -comma "select process_num from processes > 
/tmp/process_list${$}.tmp" > /dev/null

# collect process information and remove linefeeds in processdescription
> /tmp/processes${$}.tmp
for PROCESS in $(cat /tmp/process_list${$}.tmp | grep -v ANR)
do
   dsmadmc -id=${ID} -pa=${PA} -comma "select process,status from processes 
where process_num = ${PROCESS} > /tmp/line${$}.tmp
" > /dev/null
   LINE=$(cat /tmp/line${$}.tmp)
   echo $LINE >> /tmp/processes${$}.tmp
done

# collect session information from server/storage agent with tapes mounted
> /tmp/sessions${$}.tmp
for DSMSTA in $(cat /tmp/drives${$}.tmp | awk -F, '{print $3}' | sort -u)
do
   if [ ${DSMSTA} = ${SERERNAME} ]
   then
      dsmadmc -id=${ID} -pa=${PA} -comma -num=4 "query ses f=d >> 
/tmp/sessions${$}.tmp" > /dev/null
   else
      dsmadmc -id=${ID} -pa=${PA} -comma -num=4 "${DSMSTA}: query ses f=d >> 
/tmp/sessions${$}.tmp" > /dev/null
   fi
done

# Generate output
echo "${DATETIME}\c" >> ${OUT}
for DRIVE in $(cat /tmp/drives${$}.tmp | awk -F, '{print $1}')
do
   export DRIVE
   # check for LOADED
   DRIVE_STATE=$(cat /tmp/drives${$}.tmp | awk -F, '$1==ENVIRON["DRIVE"] { 
print $2 }')
   if [ ${DRIVE_STATE} = LOADED ]
   then
      # print storage agent/server volume and usage
      ASSIGN=$(cat /tmp/drives${$}.tmp | awk -F, '$1==ENVIRON["DRIVE"] { print 
$3 }')
      VOLUME=$(cat /tmp/mount${$}.tmp | awk '$10==ENVIRON["DRIVE"] { print $4 
}')

      # check for tape loding
      if [ "${VOLUME}" != "" ]
      then
         TASK=$(cat /tmp/processes${$}.tmp | grep -w ${VOLUME} | awk -F, '{ 
print $1 }')
         if [ "${TASK}" != "" ]
         then
            # find storage pool where process is working on
            STGP=$(cat /tmp/processes${$}.tmp | grep -w ${VOLUME} | awk '{ 
print substr($6,1,length($6)-2) }')
            TASK="${TASK} ${STGP}"
         fi

         if [ "${TASK}" = "" ]
         then
            # if no process using the drive then look for an session
            TASK=$(cat /tmp/sessions${$}.tmp | grep -w ${VOLUME} | awk -F, '{ 
print $9 }')
         fi
         if [ "${TASK}" = "" ]
         then
            # if no process or session is using the drive then display status
            TASK=$(cat /tmp/mount${$}.tmp | awk '$10==ENVIRON["DRIVE"] { print 
substr($NF,1,length($NF)-1) }' )
            if [ ${TASK} = USE ]
            then
               TASK="IN USE"
            fi
         fi
      else
         TASK=LOADING
      fi

      STATE="${ASSIGN} ${TASK} ${VOLUME}"
   else
      # print drivestate when not loaded
      STATE=${DRIVE_STATE}
   fi
   echo ",${STATE}\c" >> ${OUT}
done
echo "" >> ${OUT}
rm /tmp/mount${$}.tmp /tmp/drives${$}.tmp /tmp/sessions${$}.tmp 
/tmp/process_list${$}.tmp
rm /tmp/line${$}.tmp /tmp/processes${$}.tmp 2> /dev/null /tmp/servername${$}.tmp

Reply via email to