Page 1 of 1

Send Generic Macros on SNMP TRAP

Posted: Tue Oct 11, 2016 5:44 pm
by ingenieria.itoc
Hi

Can you help me with my case?

I need send generic macros through of SNMP TRAP.

I will integrate two nagios core with HP OMi , and after that I apply correlation for events of two Nagios but i need to receive SNMP Traps with all macros generic and default of Nagios.

At moment only I have default macros of Nagios

Example default macros Nagios on SNMP TRAP:

Generic: 6; Specific: 7; Enterprise: .1.3.6.1.4.1.20006.1;
Variables:

Code: Select all

[1] .1.3.6.1.4.1.20006.1.3.1.2 (OctetString): http://www.naranya.com 
[2] .1.3.6.1.4.1.20006.1.3.1.10 (OctetString): COLOCADO QUERETARO 
[3] .1.3.6.1.4.1.20006.1.3.1.6 (OctetString): HTTP 
[4] .1.3.6.1.4.1.20006.1.3.1.7 (Integer): 2 
[5] .1.3.6.1.4.1.20006.1.3.1.17 (OctetString): CRITICAL 
[6] .1.3.6.1.4.1.20006.1.3.1.17 (OctetString): CRITICAL - Socket timeout after 20 seconds  
Example of the generic macros I need send on the SNMP TRAP

Code: Select all

define host{
        use                     triara-host
        host_name               http://www.clarovideo.com
        alias                   http://www.clarovideo.com
        address                 http://www.clarovideo.com
        _itoc_cliente           America Movil            #Generic Macro
        _itoc_plataforma        Akamai Techologies   #Generic Macro
        _itoc_grupo_whatsapp    Triara-Multimedia    #Generic Macro
        check_command           check_dummy
        flap_detection_enabled  1
        hostgroups              URLS_VIP
        contact_groups          soporten1
        notifications_enabled   0
        }

Code: Select all

define service{
        use                             local-service
        host_name                       http://www.clarovideo.com
        service_description             Check URL Desde Monterrey
        check_command                   check_url_itoc!www.clarovideo.com
        _itoc_seguimiento_ok          El servicio ha sido restablecido         #Generic Macro
        _itoc_seguimiento_alerta       Se presenta alerta en URL VIP, especialista favor de confirmar si se requiere notificar al cliente   #Generic Macro
        _itoc_solicitud_oper_ok         Actividad restablecida.      #Generic Macr
        _itoc_solicitud_oper_alerta     Favor de notificar a las areas correspondientes   #Generic Macro
        flap_detection_enabled          0
        check_interval                  1
        retry_interval                  1
        max_check_attempts              3
        contact_groups                  soporten1
        notifications_enabled           1
        }
Any idea

Regards

Re: Send Generic Macros on SNMP TRAP

Posted: Wed Oct 12, 2016 5:01 pm
by ssax
It should be doable, I have it about 90% done but I need to restore my VM so that it works and I can test it. I will let you know tomorrow the status and hopefully have a solution for you.

Thank you

Re: Send Generic Macros on SNMP TRAP

Posted: Wed Oct 19, 2016 12:23 pm
by ingenieria.itoc
ssax wrote:It should be doable, I have it about 90% done but I need to restore my VM so that it works and I can test it. I will let you know tomorrow the status and hopefully have a solution for you.

Thank you



Hi, exist a new status for this case ?

Kind Regards

Re: Send Generic Macros on SNMP TRAP

Posted: Wed Oct 19, 2016 12:48 pm
by ssax
Yes, you would need to edit the xi_host_event_handler and xi_service_event_handler commands and add them in:

*** Note: This will get reverted if you upgrade and will need to be reimplemented.
*** Make sure that you have known-good backups/vm snapshots before making any modifications

In Configure > Core Config Manager > Commands:

xi_host_event_handler

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=host --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --lasthoststate=$LASTHOSTSTATE$ --lasthoststateid=$LASTHOSTSTATEID$ --hoststatetype=$HOSTSTATETYPE$ --currentattempt=$HOSTATTEMPT$ --maxattempts=$MAXHOSTATTEMPTS$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --hostoutput="$HOSTOUTPUT$" --longhostoutput="$LONGHOSTOUTPUT$" --hostdowntime=$HOSTDOWNTIME$ --itoc_cliente='$_HOSTITOC_CLIENTE$' --itoc_plataforma='$_HOSTITOC_PLATAFORMA$' --itoc_grupo_whatsapp='$_HOSTITOC_GRUPO_WHATSAPP$'
xi_service_event_handler

Code: Select all

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_event.php --handler-type=service --host="$HOSTNAME$" --service="$SERVICEDESC$" --hostaddress="$HOSTADDRESS$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --hosteventid=$HOSTEVENTID$ --hostproblemid=$HOSTPROBLEMID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --servicedowntime=$SERVICEDOWNTIME$ --itoc_seguimiento_ok='$_SERVICEITOC_SEGUIMIENTO_OK$' --itoc_seguimiento_alerta='$_SERVICEITOC_SEGUIMIENTO_ALERTA$' --itoc_solicitud_oper_ok='$_SERVICEITOC_SOLICITUD_OPER_OK$' --itoc_solicitud_oper_alerta='$_SERVICEITOC_SOLICITUD_OPER_ALERTA$'
Then you edit this file:

Code: Select all

/usr/local/nagiosxi/html/includes/components/snmptrapsender/snmptrapsender.inc.php
Change line 380 to:

Code: Select all

$trap_command = "/usr/bin/snmptrap -v 2c -c $community $tcp$address$port '' NAGIOS-NOTIFY-MIB::nHostEvent nHostname s \"%host%\" nHostStateID i %hoststateid% nHostOutput s \"%hostoutput%\" 1.2.3.4.5.6 s '%itoc_cliente%' 1.2.3.4.5.7 s '%itoc_plataforma%' 1.2.3.4.5.8 s '%itoc_grupo_whatsapp%'";
Change line 434 to:

Code: Select all

$trap_command = "/usr/bin/snmptrap -v 2c -c $community $tcp$address$port '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s \"%host%\" nSvcDesc s \"%service%\" nSvcStateID i %servicestateid% nSvcOutput s \"%serviceoutput%\" 1.2.3.4.5.6 s '%itoc_seguimiento_ok%' 1.2.3.4.5.7 s '%itoc_seguimiento_alerta%' 1.2.3.4.5.8 s '%itoc_solicitud_oper_ok%' 1.2.3.4.5.9 s '%itoc_solicitud_oper_alerta%'";

That should do it, let me know if you have any questions.