Sending traps from Nagios - Macros

Varaillon Jean Cristophe vajc at altectelecoms.gr
Thu Dec 7 09:28:42 CET 2006


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:

>From service.cfg:
------------------------------------------------------------------------
--------------
define service{
        name                            generic-service ; The 'name' of
this service template
        active_checks_enabled           1       ; Active service checks
are enabled
        passive_checks_enabled          1       ; Passive service checks
are enabled/accepted
        parallelize_check               1       ; Active service checks
should be parallelized (disabling this can lead to major 
        obsess_over_service             1       ; We should obsess over
this service (if necessary)
        check_freshness                 0       ; Default is to NOT
check service 'freshness'
        notifications_enabled           0       ; Service notifications
are enabled
        event_handler_enabled           1       ; Service event handler
is enabled
        event_handler                   server-send-trap
        flap_detection_enabled          1       ; Flap detection is
enabled
        failure_prediction_enabled      1       ; Failure prediction is
enabled
        process_perf_data               1       ; Process performance
data
        retain_status_information       1       ; Retain status
information across program restarts
        retain_nonstatus_information    1       ; Retain non-status
information across program restarts
        contact_groups                  admins  
        register                        0       ; DONT REGISTER THIS
DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }


define service{
        use                             generic-service         ; Name
of service template to use
        host_name                       localhost,router1,router2
        service_description             PING
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              1
        normal_check_interval           1
        retry_check_interval            1
        notification_options            w,u,c,r
        notification_interval           1
        notification_period             24x7
        check_command                   check_ping!0.0,0%!0.0,0%
        }
------------------------------------------------------------------------
--------------
 
>From service.cfg:
------------------------------------------------------------------------
--------------
# 'check_ping' command definition
define command{
        command_name    check_ping
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w $ARG1$ -c
$ARG2$ -p 5
        }
------------------------------------------------------------------------
--------------

>From resource.cfg:
------------------------------------------------------------------------
--------------
# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/nagios/libexec
------------------------------------------------------------------------
--------------

>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$
        }
------------------------------------------------------------------------
--------------


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
------------------------------------------------------------------------
--------------


Test1: From /usr/local/nagios/etc/eventhandlers/server-send-trap
------------------------------------------------------------------------
--------------
#!/bin/sh

arg1=$SERVICEDESC
arg2=$SERVICESTATE

/usr/bin/printf "%b" "$arg1 $arg2" | 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
------------------------------------------------------------------------
--------------

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
------------------------------------------------------------------------
--------------


Output from Test1 appearing in my second NMS:
----------------
Nagios Server Alarm - [1] private.enterprises.nagios.2 (OctetString): **
**
----------------

Output from Test2 appearing in my second NMS:
----------------
Nagios Server Alarm - [1] private.enterprises.nagios.2 (OctetString): **
$ $ **
----------------

Thanks!!!

Christophe

Disclaimer
The information in this e-mail and any attachments is confidential. It is intended solely for the attention and use of the named addressee(s). If you are not the intended recipient, or person responsible for delivering this information to the intended recipient, please notify the sender immediately. Unless you are the intended recipient or his/her representative you are not authorized to, and must not, read, copy, distribute, use or retain this message or any part of it. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses.


-------------------------------------------------------------------------
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