trap scripting

Hugo van der Kooij hvdkooij at vanderkooij.org
Mon Dec 12 20:32:36 CET 2005


Right,

I think I will give a go at writing my own scripts to send out UP and DOWN
notifications based on the SNMP traps I get from my router.

If I understood the manual (nagios/docs/extcommands.html) correctly all I
have to do is that I just have to write a single line to the fifo like:

PROCESS_HOST_CHECK_RESULT <host>;<status>;<whatever details I would like to add about the trap>

So if I have a host definition like:

define host{
        use                     generic-host
        host_name               Internet
        alias                   Internet
        address                 192.168.1.254
        parents                 anfalas
        check_command           check_snmp_int!public!Virtual-Access2
        max_check_attempts      3
        check_interval          3s      ; Check every second on retries
        notification_interval   120
        notification_period     24x7
        notification_options    d,r
        contact_groups  admins
        }

Which uses SNMP to do active polling like:

define command{
        command_name    check_snmp_int
        command_line    $USER1$/check_snmp_int.pl -H $HOSTADDRESS$ -C $ARG1$ -n $ARG2$
        }

I could send a message like:

PROCESS_HOST_CHECK_RESULT Internet;DOWN;TRAP: PPP LCP Closed

And the host would be considered down as it will read this as a passive
check result.

Or did I misread anything?

Basically I want to stop polling as soon as I get the link down trap from
the router to all hosts not local on my network. At present the SNMP trap
is just send per email to me like:

Date: Mon, 12 Dec 2005 18:33:54 +0100
From: root at gandalf.hugo.vanderkooij.org
To: hugo at vanderkooij.org
Subject: trap received from 192.168.1.254:

Host: 192.168.1.254 (anfalas.hugo.vanderkooij.org)
                     IF-MIB::ifIndex.25  25
               IF-MIB::ifAdminStatus.25  up
                IF-MIB::ifOperStatus.25  down
                     IF-MIB::ifDescr.25  Virtual-Access2
                      IF-MIB::ifType.25  ppp
SNMPv2-SMI::enterprises.9.2.2.1.1.20.25  "PPP LCP Closed"

But I'm sure I can fetch this in a nice script instead and use it to
update Nagios once I know what to send to Nagios.


Hugo.

-- 
	I hate duplicates. Just reply to the relevant mailinglist.
	hvdkooij at vanderkooij.org		http://hvdkooij.xs4all.nl/
		Don't meddle in the affairs of magicians,
		for they are subtle and quick to anger.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
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