By using the spectrum CLI tool, you can show a list of alarms and process those
any way you like. Here's a perl script I used to pull the data out and send it
along to another organization.
The main commands to work with are the "connect" command and the "show alarms"
command.
Hope this gets you going.
-----Original Message-----
From: david klein [mailto:[email protected]]
Sent: Friday, October 08, 2010 1:26 AM
To: spectrum
Subject: [spectrum] Externalizing alarms list
Is there a way to access the list of unacknowledged alarms, such as
through a database call or a webservice or an RSS feed? We would like
to be able to pull the active alarms in to a web-based dashboard, to
put fault information alongside performance and configuration
information that we are getting from other sources. We are running
Spectrum in a distributed/Fault-tolerant cluster in RedHat Enterprise
Linux with two pairs of VNM/SpectroServer servers and one pair of
OneClick/SRM servers.
Thank you in advance,
-DTK
--
david t. klein
Cisco Certified Network Associate (CSCO11281885)
Linux Professional Institute Certification (LPI000165615)
Redhat Certified Engineer (805009745938860)
Quis custodiet ipsos custodes?
---
To unsubscribe from spectrum, send email to [email protected] with the body:
unsubscribe spectrum [email protected]
---
To unsubscribe from spectrum, send email to [email protected] with the body:
unsubscribe spectrum [email protected]
#!/usr/local/bin/perl -w
use Time::Local;
############################################################################################
# This script reads in the alarms for the local landscape, checks to see if the
alarms
# are older than 5 minutes, and if they are, it places them in a table to be
sent every
# ten minutes. This is assuming that this script is scheduled in the crontab
# every ten minutes.
#
# I am hard setting the environment variables here, but it may be necessary to
set them
# differently if something doesn't work for you.
############################################################################################
$ENV{"SPECROOT"} = "/apps1/spectrum";
$vnmshroot = $ENV{"SPECROOT"}."/vnmsh";
$ENV{"CLIMNAMEWIDTH"} = 32;
$ENV{"CLISESSID"} = $$;
############################################################################################
# Initialize and define the arrays we are going to use.
############################################################################################
@LINKNAMELIST = (); # The list of links of interest for which we send alarms
to INMS
@DEVICENAMELIST = (); # The list of routers of interest for which we send
alarms to INMS
@ALARMTYPESLIST = (); # The alarm types we filter on to send to INMS
@ALARMLIST1 = (); # The raw list of alarms without any filters applied
@ALARMLIST2 = (); # The list of alarms for devices or links we care about
@ALARMLIST3 = (); # The list of alarms we need to send to INMS in raw format
@ALARMLIST4 = (); # The list of alarms in INMS format, but not ready to send
@ALARMLIST5 = (); # The list of alarms in INMS format, sorted by epoch and
ready to go!
############################################################################################
# These are the files with the important elements to be filtered on. Each is
read into
# an array while lines with whitespace and comment lines (hash mark - #) are
filtered out.
# I also do specific checking for styles of names allowed. Ex. only names with
A-Z and 0-9
# as well as dashes. On the lines in alarm types, I only accept 0x* where * is
a-f or 0-9
############################################################################################
open ( LINKNAMES, "$vnmshroot/INMS-items-of-interest-links.lst");
while ( <LINKNAMES> )
{
chomp;
if ( $_ =~ /^#/ ) {next}
if ( $_ =~ /\s/ ) {next}
if ( $_ =~ /[^A-Z0-9\-]/ ) {next}
if ( $_ eq "" ) {next}
push (@LINKNAMELIST, $_);
}
close ( LINKNAMES );
open ( DEVICENAMES, "$vnmshroot/INMS-items-of-interest-devices.lst");
while ( <DEVICENAMES> )
{
chomp;
if ( $_ =~ /^#/ ) {next}
if ( $_ =~ /\s/ ) {next}
if ( $_ =~ /[^A-Z0-9\-]/ ) {next}
if ( $_ eq "" ) {next}
push (@DEVICENAMELIST, $_);
}
close ( DEVICENAMES );
open ( ALARMTYPES, "$vnmshroot/INMS-items-of-interest-devices.lst");
while ( <ALARMTYPES> )
{
chomp;
if ( $_ =~ /^#/ ) {next}
if ( $_ =~ /\s/ ) {next}
if (!( $_ =~ /0x[a-f0-9]/ )) {next}
if ( $_ eq "" ) {next}
push (@ALARMTYPESLIST, $_);
}
close ( ALARMTYPES );
############################################################################################
# Open a connection to the spectroserver
############################################################################################
open (CONNECT, "$vnmshroot/connect 2>&1 |");
$connected = 0;
while (<CONNECT>)
{
if (/connect: successful/) {$connected = 1}
if (/connect: already connected/) {$connected = 1}
}
if ($connected !=1) {die "*** Cannot connect to server! ***\n"}
############################################################################################
# Get all alarms from the landscape and exclude the title line
############################################################################################
open (ALARMLIST, "show alarms |grep -v PCauseId 2>&1 |");
while (<ALARMLIST>) { chomp; push ( @ALARMLIST1, $_ );}
############################################################################################
# Test - write output to a file
############################################################################################
#open ( ALARMLISTOUT, ">$vnmshroot/INMS-test-alarmlist1.txt" );
#foreach $element ( @ALARMLIST1 ) { print ALARMLISTOUT "$element\n";}
#close ALARMLISTOUT;
############################################################################################
# Now that we have a list of the alarms we begin filtering on our items of
interest. Each
# array of interesting items is searched for within our alarms and placed in a
new alarm
# list. After all three lists are evaluated, we check to see if the alarm is
older than
# 5 minutes, these are then sent to INMS using Message Hopper (external setup)
############################################################################################
foreach $itemofinterest ( @LINKNAMELIST )
{
foreach $alarmentry ( @ALARMLIST1 )
{
chomp ( $alarmentry );
@alarmentryarray = split (/ /, $alarmentry );
if ( $alarmentryarray[5] =~ /$itemofinterest/ )
{ push ( @ALARMLIST2, $alarmentry ) }
}
}
foreach $itemofinterest ( @DEVICENAMELIST )
{
foreach $alarmentry ( @ALARMLIST1 )
{
chomp ( $alarmentry );
@alarmentryarray = split (/ /, $alarmentry );
if ( $alarmentryarray[5] =~ /$itemofinterest/ )
{ push ( @ALARMLIST2, $alarmentry ) }
}
}
foreach $alarmtypeofinterest ( @ALARMTYPESLIST )
{
foreach $alarmentry ( @ALARMLIST2 )
{
chomp ( $alarmentry );
@alarmentryarray = split (/ /, $alarmentry );
if ( $alarmentryarray[3] =~ /$alarmtypeofinterest/ )
{ push ( @ALARMLIST3, $alarmentry ) }
}
}
foreach $alarmentry ( @ALARMLIST3 )
{
@alarmentryarray = split (/ /, $alarmentry );
@timedata = split ( /:/, $alarmentryarray[2] );
@datedata = split ( /\//, $alarmentryarray[1] );
$numelements = @alarmentryarray;
if ($numelements > 10)
{
$field1 = `hostname` ; chomp ($field1);
$field2 = timelocal ($timedata[2], $timedata[1], $timedata[0],
$datedata[1], $datedata[0], $datedata[2]);
$field3 = "nul";
$field4 = $alarmentryarray[0];
$field5 = $alarmentryarray[7];
$field6 =
exit 0;