On Jan 11, 2008, at 4:40p, Kurt A. Freiberger wrote:
Charley Kline wrote:
I'm beginning to adapt InterMapper for our RAYexpress gear.
anybody already doing this?
We use Intermapper to monitor our RAYexpress network. I wrote a
Perl proxy
to interrogate the alarm state of the NE via SNMP, and return the
result in
a form that InterMapper can use in a custom probe. It does rely on
the
third-party proxy, but it works very well and was easy to do.
Howdy! I'm starting back on this project again, until the next
spate of crises. Could you send me that Perl script, please?? I'm
afraid I'm going to have to learn Perl; I've been avoiding it, but
it's just too useful, it looks like. We're moving IM to the same
box as RAYtracer, but RT is hogging the Trap port 162. I think
there may be a way to forward traps, but I haven't found the
incantation yet.
Sure, here it is. It's a pretty simple script; the most difficult meat
is parsing out the result of the snmpbulkwalk which returns the alarm
states which essentially come back as a two-dimensional table. What I
did was let xinetd listen on a network port and launch this script
when it is connected to. The xinetd config clause for this on our
machine is:
service adva-intermapper
{
type = UNLISTED
socket_type = stream
protocol = tcp
port = 10100
wait = no
log_on_success =
user = nobody
server = /services/adva-monitor/adva-alarm.pl
disable = no
}
...and the adva-alarm.pl script follows. Good luck with it!
/cvk
#!/usr/bin/perl
#
# Proxy script for Intermapper's Custom TCP probe to monitor Adva
Optical
# alarm status via their private MIB.
#
# Charley Kline, Network Engineering
# University of Illinois at Urbana-Champaign
# 23 Jan 2007
#
use strict;
#
# Table in the Movaz private MIB which contains the currently active
alarms.
#
my $ALARMOBJ = 'enterprises.6908.1.9.6.1';
my @SEVERITY = (
'--',
'CR',
'MJ',
'MN',
);
my (@almbay,@almchas,@almcp,@almport,@almsev,@almtime,@almtext);
my ($dev, $comm);
my $worstsev = 100;
my $numcr = 0;
my $nummj = 0;
my $nummn = 0;
#
# Input is a single input line consisting of the device to interrogate,
# and its SNMP read community.
#
$_ = <>;
chomp;
($dev,$comm) = split(/\s/);
#
# Retrieve all alarms currently active.
#
open(SNMPWALK, "snmpbulkwalk -v2c -IR -Osq -c $comm $dev $ALARMOBJ|");
while (<SNMPWALK>) {
chomp;
last if /No Such Instance/o;
#
# Parse each line of output from the snmpbulkwalk.
#
my @x = /\.(\d+)\.(\d+)\s+(.+)$/;
#
# x[0] now contains the column (variable) in the alarm table:
# 2 = bay
# 3 = chassis
# 4 = circuit pack (slot)
# 5 = port
# 8 = timestamp of alarm
# 9 = alarm severity (1=crit 2=major 3=minor)
# 10 = text of alarm
# x[1] is the row in the alarm table. One row for each alarm.
# x[2] is the value of the variable denoted by the column number.
#
if ($x[0] == 2) { # Bay
$almbay[$x[1]] = $x[2];
}
elsif ($x[0] == 3) { # Chassis
$almchas[$x[1]] = $x[2];
}
elsif ($x[0] == 4) { # CP
$almcp[$x[1]] = $x[2];
}
elsif ($x[0] == 5) { # Port
$almport[$x[1]] = $x[2];
}
elsif ($x[0] == 9) { # Severity
$almsev[$x[1]] = $x[2];
$worstsev = $x[2] if $x[2] < $worstsev;
$numcr++ if $x[2] == 1;
$nummj++ if $x[2] == 2;
$nummn++ if $x[2] == 3;
}
elsif ($x[0] == 8) { # Time
$almtime[$x[1]] = $x[2];
}
elsif ($x[0] == 10) { # Text
$almtext[$x[1]] = $x[2];
}
}
close SNMPWALK;
#
# Capture the process return code from snmpbulkwalk; if it's nonzero
# (i.e. not successful) print an error such that InterMapper's probe
# reports the device as "down".
#
if ($? != 0) {
print "5 Error in SNMP communication with device.\n";
exit;
}
#
# Now print an output line with the first digit being an indicator of
the most
# severe of the current alarms. InterMapper's custom probe can then
key on this
# to determine the output state of the probe. Also print the number of
critical/
# major/minor alarms.
#
if ($#almbay < 0) {
print "1 No Alarms\n";
exit;
}
elsif ($worstsev == 1) {
print "4 $numcr/$nummj/$nummn; ";
}
elsif ($worstsev == 2) {
print "3 $numcr/$nummj/$nummn; ";
}
elsif ($worstsev == 3) {
print "2 $numcr/$nummj/$nummn; ";
}
#
# Now print out all the alarms. Unfortunately only the first of these
typically
# actually makes it into the InterMapper "status window" for the device.
#
my $i;
foreach $i (0 .. $#almbay) {
my $loc = "$almchas[$i]-$almcp[$i]-$almport[$i]"; # build the "C-
S-P" string
my $sev = $SEVERITY[$almsev[$i]];
my $tim = localtime($almtime[$i]);
my $text = $almtext[$i];
$text =~ s/"//go;
my $out = "$sev $loc $text\n";
print "$out\n";
}
exit;
____________________________________________________________________
List archives:
http://www.mail-archive.com/intermapper-talk%40list.dartware.com/
To unsubscribe: send email to: [EMAIL PROTECTED]