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