ADSM-L

Re: Occupancy comparison script

2002-07-23 11:40:12
Subject: Re: Occupancy comparison script
From: Terry Phelps <tgphelps AT IGLOU DOT COM>
Date: Tue, 23 Jul 2002 11:07:54 -0400
I'm new here, and planned to lurk for a while, but I can perhaps help a
bit. I am NOT a TSM guru, but I'm a serious student of the game.

I just did a DR exercise, and found that my DB backup didn't seem to
exactly match my COPYPOOL tapes. When I restored a server, I found that a
very few small and frequently changed files were not restored, apparently
because they were not on the COPYPOOL tapes, to judge from the TSM logs.
After the test, I checked my admin schedules to make sure all the backups
were getting done before the copy to the COPYPOOL tapes, and such, and
was unable to find anything wrong that needed fixing.

Yesterday, I wrote a Python script on my AIX TSM server that does a "q
occupancy" and does some simple analysis on the results. I have the
(probably) normal pools: BACKUPPOOL, TAPEPOOL, and COPYPOOL. My script
simply verifies that for every filesystem, the number of files in
COPYPOOL equals the sum of the number of files in BACKUPPOOL and TAPEPOOL.

It's a simple script that has had about 10 minutes of testing, so it's
not ready for prime time, but it does seem to do a quick sanity check,
like you were asking about. You may not know Python and/or have it
available, but you can probably divine what this is doing, and write a
Perl (or other) script to do the same thing. Here is it, for better or
worse. No, I'm not a Python guru either.

---------- start of script
#!/usr/local/bin/python
#!/usr/local/bin/python
import os
import string

# Global data


# One entry for each filesystem. Key is "node concatenated with
# filesystem". Value is an array of three integers, the number of
# files in backuppool, tapepool, and copypool, respectively.
info = {}


def do_line(f):
    global info
    # print f[0], f[2], f[4], f[5]
    key = f[0] + ' ' + f[2]
    if not info.has_key(key):
        info[key] = [0, 0, 0]
    a = info[key]
    count = string.atoi(string.replace(f[5], ',', ''))
    if f[4] == 'BACKUPPOOL':
        a[0] = count
    elif f[4] == 'TAPEPOOL':
        a[1] = count
    elif f[4] == 'COPYPOOL':
        a[2] = count


# For each filespace, it should be true that a[0] + a[1] = a[2]
# where a is the value of info[filespace]
def check_data():
    global info
    for key in info.keys():
        a = info[key]
        # print key, a
        if a[2] <> a[0] + a[1]:
            print 'ERROR:', key, a


# begin execution here

in_header = 1

#WARNING. My email client is probably wrapping the following line:
for line in os.popen('dsmadmc -id=admin -pa=admin -tabdelimited q occ
2>/dev/null').readlines():
    # print '/', line,
    if in_header:
        if line.find('ANS8000I') <> -1:
            in_header = 0
        continue
    line = string.replace(line, 'SYSTEM OBJECT', 'SYSTEM_OBJECT')
    f = line.split()
    if len(f) == 0 or f[0] == 'ANS8002I':
        continue
    do_line(f)

check_data()

---------- end of script
-----Original Message-----