SNMP-TRAP from Cisco Routers

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Wed Apr 30 12:14:14 CEST 2003


Dear Sir,

I m writing to thank you for your letter and say,

On Wed, Apr 30, 2003 at 02:40:01PM +0530, Atul Shrivastava wrote:
> Hello,
> 
> I want to implement SNMP-TRAP from Cisco Routers to my Nagios Box. Can I
> do it without NSCA because I can use the SNMPTRAP (from
> Net-SNMP) daemon on the Nagios
> Box itself to receive all the traps and this I can do right now.



> But I
> don't know how to process these traps into Nagios to generate alerts for
> that trap.

This is a well documented in the Nag docs.

All you have to do is 

1 define a trap handler to snmptrapd to process the
trap and generate a passive service check result

This involves you getting code that is run by snmptrapd to decode the
trap and generate the appropriate external command that is then appended
to the Nag command file (pipe).

Here's some /bin/sh I use for this purpose - illustrative only: only the
fragment that actually submits the result.

## yada decode the trap .... set output, state, service_desc, hostname

# get the current date/time in seconds since UNIX epoch
datetime=`date +%s`
 
# create the command line to add to the command file
cmdline="[$datetime]
PROCESS_SERVICE_CHECK_RESULT;$hostname;$service_desc;$state;$output"
 
# append the command to the end of the command file
`$echocmd $cmdline >> $CommandFile`

exit 0


It is all straight out of the snmptrapd docs (on the Net-SNMP web site,
among the how-tos) or the Nag docs.


2 Define passive service checks that will accept the 'passive service
check result' from the trap handler eg

define service{
        use                             generic-service

        host_name                       so-hob
        service_description             Frame relay PVC state change
        check_period                    none
        contact_groups                  network-admins
        max_check_attempts              1
        check_command                   check_ping2!50!100!1000.0!1500.0
}

> I want to make these services as Passive and not active. Can you
> help me in this regard.
> 
>

Yours sincerely. 

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

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list