Using kdstsns to delete multiple OFFLINE TEMAs from TEP

The attached script will allow you to work out which TEMAs are OFFLINE in your ITM environment. It will create a file called offline.sql which can then be run interactively using the supplied utility kdstsns to remove OFFLINE agents.

The script works out which systems are offline using an embedded SOAP call.

,

     sysadmin
     
     ManagedSystem
     ManagedSystemName
     Status
     Name
     Managing_System

,

Run checkoffline.pl script.

,

# ./checkoffline.pl
  Please do the following:
     Change directory to /opt/IBM/ITM/tables/cicatrsq/SQLLIB
     Ensure offline.sql file exists
     Run /opt/IBM/ITM/aix513/ms/bin/kdstsns

,

It then writes the relevant information out to an sql file in the following format:

,

INSERT INTO O4SRV.TNODESTS
     ( O4ONLINE, LSTUSRPRF, NODE, THRUNODE )
       VALUES(
              "D",
              "sysadmin",
              "$systemname",
              "$thrunode);

,

Run /opt/IBM/ITM/aix513/ms/bin/kdstsns command from within the /opt/IBM/ITM/tables/cicatrsq/SQLLIB directory where the offline.sql file that has been created resides.

,

# /opt/IBM/ITM/aix513/ms/bin/kdstsns
To terminate the program at any time, enter "end"
Enter NCS Address Family or "Node" (default: *HUB):ip.pipe
Enter host name/address : systemname
Enter NCS Server Port Number (eg. 1024, ....):1918
Path Specification:
NCS:{SOCKET=ip.pipe:systemname[1918]} CT/DS:{SERVER=SRVR01 USER=DSTSNS}
Socket Specifcation:
ip.pipe:systemname[1918]
Server Version: 400 Build: 07288 Host Type: 5 Host Level: 3 Feature: NLS=Y
Requester Version: 400 Build: 07288 Host Type: 5 Host Level: 3 Feature: NLS=Y
Server Options: Case Matching = 1
Enter SQL member name (or "end" to quit) ... offline.sql
 
< ..... lots of deletion goes on now ..... >
INSERT INTO O4SRV.TNODESTS
 ( O4ONLINE, LSTUSRPRF, NODE, THRUNODE )
 VALUES(
 "D",
 "sysadmin",
 "MBOS.ITUBN255",
 "RKCPXM00:MBOS:CPIRA");
/*********************************************/
/********** Create Request Was Done **********/
/*********************************************/
 
INSERT INTO O4SRV.TNODESTS
 ( O4ONLINE, LSTUSRPRF, NODE, THRUNODE )
 VALUES(
 "D",
 "sysadmin",
 "MBOS.ITUBN253",
 "RKCPXM00:MBOS:CPIRA");
/*********************************************/
/********** Create Request Was Done **********/
/*********************************************/
< ..... lots of deletion have happened ..... >
Total Libraries Processed: 1
Total Members Processed: 1
Total SQLs Processed: 1989
Total Errors Encountered: 0
Enter SQL member name (or "end" to quit) ... end

,

Here is the code for checkoffline.pl

,

#!/bin/perl
# Set environment variables
$candlehome="/opt/IBM/ITM";
$hostname=`hostname`;
chop($hostname);
&write_statustxt;
&write_urlstxt;
chdir("/opt/IBM/ITM/aix513/ms/bin");
@lines=`./kshsoap status.txt urls.txt`;
chomp(@lines);
foreach (@lines) {
        push(@newlist,$_) if $_=~/^outfile");
foreach (@newlist) {
        s/<(w+)>//;
        s///;
        print OUT "
" if $_=~/^*/;
        print OUT "$_ ";
}
close(OUT);
open(IN, "outfile");
open(OUT, ">offline.sql");
while () {
        chomp;
        next if /^s*$/;        # Ignore blank lines
        next if /^*ONLINE/;    # Ignore *ONLINE entries
        next if /CMS/;          # Ignore offline CMS entries
        ($status, $systemname, $thrunode)=split(/ /);
        print OUT "INSERT INTO O4SRV.TNODESTS
";
        print OUT " ( O4ONLINE, LSTUSRPRF, NODE, THRUNODE )
";
        print OUT " VALUES(
";
        print OUT "   "D",
";
        print OUT "   "sysadmin",
";
        print OUT "   "$systemname",
";
        print OUT "   "$thrunode");
";
        print OUT "
";
}
close(OUT);
close(IN);
print "
	Please do the following:
";
print "		Change directory to $candlehome/tables/cicatrsq/SQLLIB
";
print "		Ensure offline.sql file exists
";
print "		Run $candlehome/aix513/ms/bin/kdstsns
";
exit(0);
sub write_statustxt {
        open(STATUS, ">/opt/IBM/ITM/aix513/ms/bin/urls.txt");
        print STATUS "sysadminManagedSystemManagedSystemNameStatusNameManaging_System";
        close(STATUS);
}
sub write_urlstxt {
        open(URL, ">/opt/IBM/ITM/aix513/ms/bin/urls.txt");
        print URL "http://$hostname:1920///cms/soap";
        close(URL);
}