Nagios Core 4.08 don't send traps in order.

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Core 4.08 don't send traps in order.

Post by tgriep »

The snmptrap command can only send one argument at a time.

If you need to send all of that information, you will have to create a custom script to send all of that information as one argument.

Code: Select all

/usr/bin/snmptrap -v 2c -c 1 MY_HOST '' NAGIOS-NOTIFY-MIB::nSvcEvent nSvcHostname s "All of the information needs to be here" 
Be sure to check out our Knowledgebase for helpful articles and solutions!
Nagios_Admin_M
Posts: 77
Joined: Fri Jul 22, 2016 4:39 am

Re: Nagios Core 4.08 don't send traps in order.

Post by Nagios_Admin_M »

Ok, what I try do now is to send this values:

define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$ | var2=$NOTIFICATIONTYPE$ var3=$HOSTNAME$ var4=$HOSTSTATEID$ var5=$HOSTADDRESS$ var6=$HOSTOUPUT$ var7=$LONGDATETIME$ /usr/bin/send-host-trap
}

There are the same values like in the e-mail notification. The e-mail is sent and all the values are received. Staring from | var2=.... I placed the same ones as in the e-mail but only 4 of them are stored in the log file. VAR6 AND VAR7 are not saved.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: Nagios Core 4.08 don't send traps in order.

Post by ssax »

Please try this:

Code: Select all

define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$; /usr/bin/send-host-trap $NOTIFICATIONTYPE$ '$HOSTNAME$' $HOSTSTATEID$ '$HOSTADDRESS$' '$HOSTOUPUT$' '$LONGDATETIME$'
}
Let us know the results.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Core 4.08 don't send traps in order.

Post by tgriep »

Another thing is that some service macros are only valid when service checks are run and also the service notification command has to match also.
Take a look at these links for more details on how that works.
https://assets.nagios.com/downloads/nag ... acros.html
https://assets.nagios.com/downloads/nag ... olist.html
Be sure to check out our Knowledgebase for helpful articles and solutions!
Nagios_Admin_M
Posts: 77
Joined: Fri Jul 22, 2016 4:39 am

Re: Nagios Core 4.08 don't send traps in order.

Post by Nagios_Admin_M »

Sorry, the solution doesn't work. I still do not know how to solve it.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Nagios Core 4.08 don't send traps in order.

Post by rkennedy »

tgriep wrote:Another thing is that some service macros are only valid when service checks are run and also the service notification command has to match also.
Take a look at these links for more details on how that works.
https://assets.nagios.com/downloads/nag ... acros.html
https://assets.nagios.com/downloads/nag ... olist.html
As @tgriep mentioned - the macros are NOT passed all the time. It depends on the type of check / notification is going out. Take a look at the links above to see which macros are populated when.
Former Nagios Employee
Nagios_Admin_M
Posts: 77
Joined: Fri Jul 22, 2016 4:39 am

Re: Nagios Core 4.08 don't send traps in order.

Post by Nagios_Admin_M »

I managed to populate the following values:
HOSTNAME$ $HOSTSTATEID$ $SERVICEDESC$ $SERVICESTATEID$$SERVICEATTEMPT$ $LASTSERVICESTATECHANGE$ $SERVICEDURATIONSEC$ $LASTSERVICECHECK$

Although I can not send neither $SERVICEOUTPUT$ nor $HOSTOUPUT$ vars.

Can you please tell me how to push those values into the sendtrapd ?
Nagios_Admin_M
Posts: 77
Joined: Fri Jul 22, 2016 4:39 am

Re: Nagios Core 4.08 don't send traps in order.

Post by Nagios_Admin_M »

I am also not capable to send traps after check_port service check. This is an output of my log file after an port issue had occurred :

[1470235656] wproc: NOTIFY job 545 from worker Core Worker 28031 is a non-check helper but exited with return code 127
[1470235656] wproc: host=...,...,...,...; service=...,...,...,...; contact=user1
[1470235656] wproc: early_timeout=0; exited_ok=1; wait_status=32512; error_code=0;
[1470235656] wproc: stderr line 01: /bin/sh: ...: command not found
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios Core 4.08 don't send traps in order.

Post by tgriep »

The $SERVICEOUTPUT$ is only valid with service checks and it will use the service notification handler.
The $HOSTOUTPUT$ is only valid with host checks and it will use the host notification handler.
So you will have to create 2 notification commands, one for host notifications and one for service notifications.

The error log output does not have enough information but it looks like one of your notification commands has an error and you would have to see which one it is and fix the error.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Nagios_Admin_M
Posts: 77
Joined: Fri Jul 22, 2016 4:39 am

Re: Nagios Core 4.08 don't send traps in order.

Post by Nagios_Admin_M »

I use the $SERVICEOUTPUT$ with service notification value, but I have an empty value in the log files.
Locked