nv-l

RE: [nv-l] linkDown Trap with locIfReason Up

2004-02-26 10:59:24
Subject: RE: [nv-l] linkDown Trap with locIfReason Up
From: "Barr, Scott" <Scott_Barr AT csgsystems DOT com>
To: <nv-l AT lists.us.ibm DOT com>, <nv-l AT lists.tivoli DOT com>
Date: Thu, 26 Feb 2004 09:50:10 -0600
Ah - I can help you :) I hope you have more fun with them than I did.

Cisco provides several different trap formats. I suggest you make sure you are 
using this statement in your routers:

snmp-server trap link ietf

Note - not all Cisco IOS supports this.

Here is my script for parsing link traps from Cisco. It contains most of the 
documentation you need. Note that there is no way to fix up trapd.conf to 
handle this, you will see messages in trapd.log like this:

1077353069 3  Sat Feb 21 01:44:29 2004 xxx-xxx-sw2.csgsystems.com A 
Cisco_Link_Up trap received from enterprise cisco-workgroup w
ith 4 arguments:  ifIndex=30;  ifDescr=1;  ifType=1;  locIfReason=2/22; 
Temp1=FMT ERROR: accessing element #5, only 4 available; Tem
p2=FMT ERROR: accessing element #6, only 4 available

I get this message because I had to add a 5th and 6th variable into trapd.conf 
so the event viewer would show all the fields. Also notice that the fields 
don't match up (locIfReason actually provided on some traps and on this one, 
the 4th variable is the port number).

Here is the code (with some minor editing)

#!/usr/bin/perl
# ********************************************************************
# *** Interface Trap processor                                     ***
# ***                                                              ***
# *** 11/03/2003 - Added code to support TEC integration           ***
# ***              Added $isUp to support open/close process       ***
# ***              Added -r C - All events are critical            ***
# ***              Changed default $isUp to 9 to catch any         ***
# ***              mis-guided exceptions                           ***
# *** 12/11/2003 - CERTIFIED Testing for TEC Integration           ***
# ******************************************************************** 
#
$TRAP_NOTIFY = '<trap notification script name here>';
$NOTIFY = '<notification group goes here>';
$TimeStamp = localtime(time);               

$Origin = $ENV{'NVA'};
$Arguments = $ENV{'NVATTR_COUNT'};
$isUp = 9 ;

if ($Arguments == 6 )
{                         
        # *************************************************
        # *** Cisco Link Up/Link Down 3 variable format ***
        # *************************************************
        # Variable #1 is ifIndex
        # Variable #2 is ifDescription
        # Variable #3 is ifType

        $ifDesc =       $ENV{'NVATTR_2'};
        $Severity =     $ENV{'NVATTR_6'};
        $ifReason =     "As Reported by Router";

        if ($Severity == 0)
        {
                $ifStatus = "Interface Active"; 
                $isUp = 1 ;
        }
        if ($Severity == 3)
        {
                $ifStatus = "Interface Down";
                $isUp = 0 ;
        }
}

if ($Arguments == 7 )
{                         
        # *************************************************
        # *** Cisco Link Up/Link Down 4 variable format ***
        # *************************************************
        # Variable #1 is ifIndex
        # Variable #2 is ifDescription
        # Variable #3 is ifType
        # Variable #4 is ifReason

        $ifDesc =       $ENV{'NVATTR_2'};
        $ifReason =     join(" ","Reason:",$ENV{'NVATTR_4'});
        $Severity =     $ENV{'NVATTR_7'};

        if ($Severity == 0)
        {
                $ifStatus = "Interface Active"; 
                $isUp = 1 ;
        }
        if ($Severity == 3)
        {
                $ifStatus = "Interface Down";
                $isUp = 0 ;
        }
}

if ($Arguments == 8 )
{                         
        # *************************************************
        # *** Cisco Link Up/Link Down 5 variable format ***
        # *************************************************
        # 5 variable format
        #
        # Variable #1 is ifIndex
        # Variable #2 is AdminStatus
        # Variable #3 is OperStatus
        # Variable #4 is ifDescription
        # Variable #5 is ifType

        $ifDesc =       $ENV{'NVATTR_4'};
        $Status =       $ENV{'NVATTR_3'};
        $ifReason =     "As Reported by Router";

        if ($Status == 1) 
        { 
                $ifStatus = "Interface Active";
                $isUp = 1 ;
        }

        if ($Status == 2) 
        {
                $ifStatus = "Interface Down";
                $isUp = 0 ;
        }
}

if ($Arguments == 9 )
{                         
        # *************************************************
        # *** Cisco Link Up/Link Down 6 variable format ***
        # *************************************************
        # 6 variable format
        #
        # Variable #1 is ifIndex
        # Variable #2 is AdminStatus
        # Variable #3 is OperStatus
        # Variable #4 is ifDescription
        # Variable #5 is ifType
        # Variable #6 is ifReason
                                                
        $ifDesc =       $ENV{'NVATTR_4'};       
        $Status =       $ENV{'NVATTR_3'};       
        $ifReason =     $ENV{'NVATTR_6'};       
                                                
        if ($Status == 1)                       
        {                                       
                $ifStatus = "Interface Active"; 
                $isUp = 1 ;
        }                                       
                                                
        if ($Status == 2)                       
        {                                       
                $ifStatus = "Interface Down";   
                $isUp = 0 ;
        }                                       
}

@Origin = split('\.',$Origin);
$Origin = @Origin[0];

$MsgText = "$ifDesc is $ifStatus $ifReason at \@ $TimeStamp";                   
                                          
                                                                                
                    
system "$TRAP_NOTIFY -h $Origin -s \" $MsgText\" -m \"$Origin $MsgText\" -k 
ROUTERS -n \"$NOTIFY\" -z $isUp -c \"$ifDesc\" -r C";



-----Original Message-----
From: owner-nv-l AT lists.us.ibm DOT com [mailto:owner-nv-l AT lists.us.ibm DOT 
com]On
Behalf Of Chris Coulson
Sent: Thursday, February 26, 2004 9:28 AM
To: nv-l AT lists.tivoli DOT com
Subject: [nv-l] linkDown Trap with locIfReason Up






I am receiving some strange events on my NetView and wondered if anyone
else is seeing the same.

I am running NetView V7.1.3 on AIX 5.1.

NetView receives the following event went an interface goes down:

Sat Feb 21 20:39:00 2004 hostname  A Cisco Agent Interface Down (linkDown
Trap) on interface: FastEthernet0/24 locIfReason: down

My NetView pages on this event - on the linkDown Trap.

The strange event is this one:

Sat Feb 21 20:39:00 2004 hostname   A Cisco Agent Interface Down (linkDown
Trap) on interface: FastEthernet0/24 locIfReason: up

You will notice in the above event, the locIfReason says up.  NetView pages
because it is a linkDown Trap.  But, the locIfReason shows up.  So, is this
the interface coming up, but the Trap is a linkDown trap?  And when we
receive this event (and page) we check the interface and it is actually up.

Can anyone shed any light on this?

Thanks,
Chris Coulson
ccoulson AT ca.ibm DOT com



<Prev in Thread] Current Thread [Next in Thread>