Tuesday, March 11, 2008

A simple Perl script to list running situations

Okay, you want to list the currently running situations and their managed systems. You can very easily do that using the Perl SOAP module for ITM.


# include the TEMS SOAP abstraction module
use TEMS;

# include GBS Wrapper module to TEMS
use GBSSoap;

use strict;

my ($tems, $gbssoap, $situation, @situations);

# initialize new TEMS object, localhost is the server name
# default port is 1920, default user id sysadmin, no password.
$tems = TEMS->new("localhost");

# Create a wrapper object around TEMS
$gbssoap = GBSSoap->new($tems);

# get all the situations and their status
@situations = $gbssoap->getSituationStatusHistory();

foreach $situation (@situations)
'??????????#?skip situations that are not associated with any managed system.
'?????????if (ref($situation->{'Managed_System'}) ne 'HASH')
'''????print "$situation->{'Situation_Name'}, $situation->{'Managed_System'}," .
''''?????????"$situation->{'Local_Timestamp'}, $situation->{'Status'}";

Hope you find this example useful.

No comments: