Snmp Trap with nagios

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Thu Feb 27 22:19:50 CET 2003


Dear Gentlemen,

On Thu, Feb 27, 2003 at 06:57:04PM +0100, Verstege, Bernhard wrote:
> Hi,
> 
> just start nagios, nsca and snmptrapd on the same server.
> Use send_nsca with "localhost" as  the receiver.
> For me, it works well.
> 
> Bernhard
> 

or have your trap handler (the code invoked by snmptrapd running on the
Nag host) do soemthing like (/bin/sh used for illustrative purposes
only; don't this at home)

echocmd="/bin/echo"
CommandFile="/usr/local/nagios/var/rw/nagios.cmd"

 .. yada .. set all the variables to build the passive service check
            result from the trap

# 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

Easi peasi and more or less as documented in the 'other topics' of the
Nag docco - any process with sufficient priviledge can write to the
Nagios command queue.

The only problemo is that this approach doesn't scale: new trap --> new
handler.

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