Re: Traps, Services, and Extensibility

Stanley Hopcroft <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Dear Sir,

I am writing with a greater appreciation of your letter and to say that,
yes, trap handlers are as hard - or harder - to maintain than service
checks.

I have spent too much of last night and this morning hacking a few lines
of shell to deal with Frame Relay traps; there must be a better way.

It seems that there are no standard or contributed Netsaint/Nagios 
trap event handlers (apart from the __very__ helpful examples in the 
standard documents) .

Is that the case ?

What seems to be required is that the trap handler be 

. aware of the traps of interest and how they should be responded to  

  ==> for frDLCIStatusChange, read the Dlci and the CircuitState OIDs 

. aware of how Netsaint should respond to the trap

  ==> Ok for active, Critical for inactive

so that its possible to escape from 

. adding cases to the trap handler/restarting trap daemon.

. writing new event handlers for these cases.

In other words, there is one traphandler object (OO) that handles 
__all__ traps and is equipped with a constructor that builds a new event 
handler object according to the trap (with a default action of logging 
or ignoring) and that the event handler 'handletrap' method gets called 
next.

It's still necessary to modify the trap handler, but the advantages of
an approach like this may be

. inheritance

. code reuse

. less stuff to touch (a new constructor maybe)

. implementing in a language that is more forgiving of dodos (for the 
benefit of people like me).

Nagios::Trap anyone ?

Would anyone care to share their experience ?

Yours sincerely.

-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

For info, here's some of the low lights of my traphandler and frame 
event handler.
 ...

traphandle FOUNDRY-SN-TRAP-MIB::snTrapL4GslbHealthCheckIpPortDown 
/usr/local/netsaint/libexec/eventhandlers/handle-foundry-traps 46

# Topology changes from Foundry ...
traphandle BRIDGE-MIB::newRoot 
/usr/local/netsaint/libexec/eventhandlers/handle-bridge-traps 1

# Frame relay PVC changes from State Office routers
traphandle RFC1315-MIB::frDLCIStatusChange 
/usr/local/netsaint/libexec/eventhandlers/handle-frame-traps 1

 ...

# Subsequent lines passed from snmptrapd contain the varbinds, one pair 
of OIDs and values perl line
# 
# 
transmission.frame-relay.frCircuitTable.frCircuitEntry.frCircuitIfIndex.15.21  
15
# 
transmission.frame-relay.frCircuitTable.frCircuitEntry.frCircuitDlci.15.21  
21
# 
transmission.frame-relay.frCircuitTable.frCircuitEntry.frCircuitState.15.21  
inactive(3)

Dlci=9999
CircuitState='unknown'

while read oid val
do
         if [ `expr "$oid" : '.*Dlci'` -gt 0 ]
         then
           Dlci=$val
         elif [ `expr "$oid" : '.*CircuitState'` -gt 0 ]
         then
           CircuitState=$val
         fi
done

# Given a FQDN, get the short name of the host as it is setup in 
NetSaint
hostname="unknown"
case $host in
        so-*)
            hostname=`expr "$host" : '\(so-...\)'`
            # traps could come from so-ade-isdn, so-ade-frame etc.
            ;;
esac

state=state_UNKNOWN
output="No output"

case $1 in

        # frDLCIStatusChange (a frame relay PVC has changed state)
        1)
            if [ `expr "$CircuitState" : 'active'` -gt 0 ]
            then
              output="Ok. Frame relay PVC $Dlci has changed state to 
$CircuitState."
              state=$state_OK
            elif [ `expr "$CircuitState" : 'inactive'` -gt 0 ]
            then
              output="Failed. Frame relay PVC $Dlci has changed state to 
$CircuitState."
              state=$state_CRITICAL
            else 
              output="Uknown. Frame relay PVC $Dlci has changed state to 
$CircuitState."
              state=$state_UNKNOWN
            fi
            ;;

esac




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.