In ITM, after you have created a new situation, you must do two things to it:
- You must distribute it to one or more agents. This will determine where a situation runs. i.e you can limit it to specific servers or run it on all of them.
- Associate it with some node in a tree in the TEP Portal. This is so that when the situation activates (fires, become true) you will see it in the portal console.
The problem then starts when you want to be sure that all your situations have been distributed and associated properly. The first problem is simpler - you can use a SOAP call on the TEMS to fish out the list of situations and their distributions. The second problem is slightly more complex. The TEPS database hold the list of all situations and associations - but a list of unassociated situations - which are the ones which will not show up even if they become true.
Recently I was at a customer and needed to verify that all situations were indeed associated. I remember seeing something that showed this, but my searching skills betrayed me and I wrote this out quickly. If anyone does have a link- feel free to send it.
Being a quick-and-dirty job (and being rusty with my Perl), this script will only work on the environment it was written for - Windows/SQLServer, but it should be easy to convert
Also, I committed the crime of using system calls in Perl, instead of SOAP and SQL calls embedded in the code - so sue me :)
#!/user/local/bin/perl
# This script will list situations which exist but are not associated with any portal navigator item.
# It is limited to Windows systems running SQLServer, but can easily be modified for any OS/DB combination. :)
# Part 1 - list all situations from TEMS
# Part 2 - list all situation associations from TEPS
# Part 3 - Find which situations exist in part 1 but not part 2
#
# Robert Barron Feb-2009my $sSitListFile = "SitList.txt";
my $sSitAssocFile = "SitAssocList.txt";
my $sTEMSHOST = "x.x.x.x";
my $sTEMSUser = "xxxxxx"
my $sTEMSPassword = "xxxxxx";
my $sTEPSHOST = "x.x.x.x";
my $sTEPSUser = "xxxxxx"
my $sTEPSPassword = "xxxxxx";# Part 1
# login to TEMS and pull out a list of situationssystem ("tacmd login -s " . $sTEMSHOST . " -u " . $sTEMSUser . " -p " . $sTEMSPassword);
if (-e $sSitListFile) {
unlink ($sSitListFile);
}
#Run tacmd listsit and extract the first string from each line.
# NOTE: This line must be modified if you are using situation names with spaces in the middle (ITM 6.2.1+)
system ("for /f %i in ('tacmd listsit') do \@echo %i >> " . $sSitListFile);
open (File, $sSitListFile ) || die "Could not open " . $sSitListFile ."\n";while (<File>) { #Strip any \n or spaces from the situation string
chop;
$tmp = $_;
$tmp =~ s/^\s+//;
$tmp =~ s/\s+$//;
push(@arrAllSits, $tmp );
}
close (File);# Part 2
# login to TEPS database and pull out the situation associations.
if (-e $sSitAssocFile) {
unlink ($sSitAssocFile);
}
system ("sqlcmd -S " . $sTEPSHOST . " -U " . $sTEPSUser . " -P " . $sTEPSPassword . " -d teps -Q\"select distinct(name) from teps.KFWTMPLSIT\" > " . $sSitAssocFile );
open (File, $sSitAssocFile) || die "Could not open " . $sSitAssocFile . "\n";
while (<File>) { #Strip any \n or spaces from the situation string
chop;
$tmp = $_;
$tmp =~ s/^\s+//;
$tmp =~ s/\s+$//;
push(@arrAssocedSits, $tmp);
}
close (File);#Part3
%found=();
@arrNotAssoced =();#build lookup table
foreach $item (@arrAssocedSits) {$found {$item} = 1}# find elements which are in @arrAllSits and not in @arrAssocedSits
foreach $item (@arrAllSits) {
unless ($found{$item}) {
#it's not in %found, so print
print ($item ."\n");
}
}
This script will print out the list of situations which exist but are not associated with any navigator item.
-- Robert
No comments:
Post a Comment