Sending traps from Nagios - Macros

Marc Powell marc at ena.com
Thu Dec 7 14:39:00 CET 2006



> -----Original Message-----
> From: Varaillon Jean Cristophe [mailto:vajc at altectelecoms.gr]
> Sent: Thursday, December 07, 2006 2:29 AM
> To: Marc Powell; nagios-users at lists.sourceforge.net
> Subject: RE: [Nagios-users] Sending traps from Nagios - Macros
> 
> Hi,
> 
> Thanks for your reply!
> 
> Since the command line seems to be fine,
> I will past all what I've done concering that event_handler including
my
> latest un-successful test:

[chop]

> From misccommands.cfg:
>
------------------------------------------------------------------------
> --------------
> # 'server-send-trap' event handler definition
>         define command{
>                 command_name    server-send-trap
>                 command_line
> /usr/local/nagios/etc/eventhandlers/server-send-trap $SERVICEDESC$
> $SERVICESTATE$
>         }

This is correct.

> Test1: From /usr/local/nagios/etc/eventhandlers/server-send-trap
>
------------------------------------------------------------------------
> --------------
> #!/bin/sh
> 
> snmp_trapsend -h 172.31.10.15 -c sphynx -e 1.3.6.1.4.1.20006 -s 2 -a
> "1.3.6.1.4.1.20006.2 STRING (** $arg1 $arg2 **)"
> exit 0

This is not. This is a shell programming error. $arg1 should be $1 and
$arg2 should be $2 unless there is some obscure thing that happening
with your OS's version of sh.

> Test2: From /usr/local/nagios/etc/eventhandlers/server-send-trap
>
------------------------------------------------------------------------
> --------------
> #!/bin/sh
> 
> snmp_trapsend -h 172.31.10.15 -c sphynx -e 1.3.6.1.4.1.20006 -s 2 -a
> "1.3.6.1.4.1.20006.2 STRING (** $SERVICEDESC$ $SERVICESTATE$ **)"
> exit 0

This would never work since nagios doesn't parse the script that's
called to substitute the macros. That's why they're passed as command
line arguments. Since nagios must call the command it has an opportunity
to substitute. This _could_ work if you used the environment variable
version of the macros.


-
Marc

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
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