Keeping an eye on TSM volumes

I wrote a quick script which tells me when volumes in TSM (Tivoli Storage Manager) have access and/or media issues and shoots me off an email. The script does two things:

1) Checks for volumes which are NOT in the states READWRITE or OFFSITE.
2) Checks for volumes which have a read/write error count >0.

I’m sure that most people running TSM in their environment have some sort of daily reporting that gets sent out. If that’s the case, you can simply extract the SQL from the script and use it in your own reporting tools.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/ksh
 
USER=`grep USER /home/aixuser/tsm_creds | awk -F = '{ print $2 }'`
PASS=`grep PASS /home/aixuser/tsm_creds | awk -F = '{ print $2 }'`
 
DSMADMC="/usr/bin/dsmadmc -id=$USER -pass=$PASS -dataonly=yes"
DATE=`date +"%Y%m%d"`
DATE_SHORT=`date +"%a"`
TEMP_OLD="/tmp/tsm.temp.old"
TEMP_NEW="/tmp/tsm.temp.new"
MAILTO="email@host.com"
 
if [[ ! -f $TEMP_OLD ]]; then
  touch $TEMP_OLD
fi
 
MACRO1="select VOLUME_NAME,ACCESS from volumes where access !='READWRITE' and access !='OFFSITE'"
 
    echo "VOLUMES WITH STATUS ISSUES" >> $TEMP_NEW
    echo "\nVOLUME_NAME            ACCESS" >> $TEMP_NEW
    echo "------------------     ------------------" >> $TEMP_NEW
    $DSMADMC $MACRO1 >> $TEMP_NEW
 
MACRO2="SELECT volumes.volume_name, volumes.stgpool_name, volumes.pct_utilized, volumes.status, volumes.write_errors, volumes.read_errors FROM volumes, libvolumes WHERE volumes.volume_name=libvolumes.volume_name AND ( volumes.write_errors>0 OR volumes.read_errors>0 )"
 
    echo "\n\nVOLUMES WITH READ/WRITE ISSUES" >> $TEMP_NEW
    echo "\nVOLUME_NAME            STGPOOL_NAME           PCT_UTILIZED     STATUS                 WRITE_ERRORS     READ_ERRORS" >> $TEMP_NEW
    echo "------------------     ------------------     ------------     ------------------     ------------     -----------" >> $TEMP_NEW
    $DSMADMC $MACRO2 >> $TEMP_NEW
 
diff $TEMP_OLD $TEMP_NEW > /dev/null 2>&1
   if [[ $? == 1 ]]; then
    cat $TEMP_NEW | mail -s "Warning: TSM Media Issues" $MAILTO
    cp $TEMP_NEW $TEMP_OLD
   fi
 
rm $TEMP_NEW
 
exit
aixuser@TSM /home/aixuser > cat tsm_creds
USER=tsmuser
PASS=tsmpass
aixuser@TSM /home/aixuser > ls -l
-r--------   1 aixuser     system           27 May 17 14:42 tsm_creds
-rwxr-xr-x   1 aixuser     system         1605 Sep 21 10:55 tsm_tape_issues

Script breakdown
Line(s)
03-04:   I grab the TSM credentials out of a file which only has o+r access rights so we don’t have the TSM credentials in the script itself (see above output).
17:      SQL select statement to search for all volumes with access other than READWRITE and OFFSITE.
24:      SQL select statement to search for all volumes with read/write errors.
31-35:   diff new output with previously saved output and determine if email should be sent.

It’s pretty straight forward, nothing fancy. Just change the variables to cater for your environment and off you go. The result will be an email with output similiar to the below if any issues are found.

VOLUMES WITH STATUS ISSUES
 
VOLUME_NAME            ACCESS
------------------     ------------------
TAPE09L4               UNAVAILABLE       
 
 
VOLUMES WITH READ/WRITE ISSUES
 
VOLUME_NAME            STGPOOL_NAME           PCT_UTILIZED     STATUS                 WRITE_ERRORS     READ_ERRORS
------------------     ------------------     ------------     ------------------     ------------     -----------
TAPE09L4               PRI_TAPE_POOL                  13.7     FULL                              0               1

Post any questions to the comments box below.

1 thought on “Keeping an eye on TSM volumes

  1. Pingback: Bookmarks for 20 set 2010 through 23 set 2010 | jtheo

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.