Sign in to PrePAN

Dsmadmc IBM TSM Administrative Client perl wrapper

In Review


use Dsmadmc;
use strict;
use warnings;

my $stanza=shift;
die unless ($stanza);
my $obj = Dsmadmc->new(stanza => $stanza,
                       sep => '%',
                       validate => 0,
                       macro => "/var/tmp/$$.$$.$$")  #This will allow multiple statement in one connection
or die $!;

$obj->init; #do some initialization to verify connection
$obj->do_query; #will silently chosse between single/macro conn.
                #will flush statement buffer, perform queries, charge data into answers

print "Usage Example one...\n";
while(my $a=$obj->get_next_answer){
   my $tsm_rc=$obj->get_tsm_rc($a);
     while(my ($node,$dom)=$obj->get_next_row($a)){
        print "node: $node\n";
        print "domain: $dom\n";
     print STDERR "\n******************************\n";
     print STDERR $obj->get_error_string($a);
     print STDERR "\n******************************\n";

print "Usage Example two(inconsistent number of field within queries)...\n";
$obj->add_statement('SELECT NODE_NAME,DOMAIN_NAME FROM NODES'); #---> will be statement 0
$obj->add_statement('SELECT VOLUME_NAME,STGPOOL_NAME,PCT_RECLAIM FROM VOLUMES'); #--> will be statement 1 and so on..
$obj->do_query; #see above.

my $ans=$obj->get_next_answer; #get answer to statement 0
while(my ($node,$dom)=$obj->get_next_row($a)){
    print "node: $node\n";
    print "domain: $dom\n";
$ans=$obj->get_next_answer; #get ans. to statement 1..
while(my ($node,$stg,$pct)=$obj->get_next_row($a)){
    print "volume: $node\n";
    print "stgpool: $stg\n";
    print "pctrec:  $pct\n";

print "Usage Example threee(Answers format)\n";
$obj->add_statement('SELECT count(*) FROM NODES');
$obj->add_statement('SELECT count(*) FROM VOLHISTORY');
$obj->add_statement('TCELES count(*) FROM VOLHISTORY'); #-->ERROR

use Data::Dumper;
print Dumper \$obj->{answers};
#Will produce
#$VAR1 = \[
#            {
#              'rc' => 0,
#              'statement' => 'SELECT count(*) FROM NODES',
#              'rows' => [
#                          '145'
#                        ]
#            },
#            {
#              'rc' => 0,
#              'statement' => 'SELECT count(*) FROM VOLHISTORY',
#              'rows' => [
#                          '44'
#                        ]
#            },
#            {
#              'rc' => '2',
#              'statement' => 'TCELES count(*) FROM VOLHISTORY',
#              'error' => [
#                           'ANR2000E Unknown command - TCELES.'
#                         ],
#              'rows' => []
#            }
#          ];

print "Version was: ". $obj->get_tsm_version."\n";


Hello, just wrote a new module, and I think it could be intreresting also for other people. The module is very light and acts as a wrapper to the TSM administrative client. It fires command to TSM server and constucts answers data structures with relevant information in it. It provides methods to read answers without having to care about data structures or data parsing. There are two modules doing similar jobs on CPAN: they are:

The first one is a 2001 mod that seems not maintained anymore. The second one is a DBD driver for DBI. Mine implementation is more similar to first one, in fact I thought that subclassing DBD / DBI would not be worthwhile for such little piece of code, and also because this implementation isn't using a real DB2/TSM Database API but passing command through command line client (exactly like others mod. available). Main differences between above implementation: I provide a way to execute multiple statement in a single connection, to increase efficiency. AFAIK both implementation are doing a connection for each statement. I provide a method to get TSM server version: this could be extremely useful by end user prospective since tsm tables and answers may vary depending on server version. I would like to get it working also on Win32 platform. I also suffer from same known bug than others implementation, since we all charge TSM responses in memory, and in some edge cases we could end up with very big data set loaded into memory. I think I could try to mitigate this in some way.

The module aim is to allow quick reporting and monitoring scripts, efficiently acting as perl data bridge between TSM and user program. My question for you are: do you think it's worthwhile to publish the mod? If yes, which namespace I should choose (TSM seems the best but its already taken, and I want to respect)?

Comments 100 random queries (single connection mode)
real 0m20.545s
user 0m4.291s
sys 0m1.086s

DBI:TSM 100 random queries
real 0m20.675s
user 0m4.410s
sys 0m1.108s 100 random queries (Macro mode)
real 0m6.673s
user 0m0.069s
sys 0m0.018s

Please sign up to post a review.