Page 2 of 4
Re: Nagios Core 4.08 don't send traps in order.
Posted: Wed Jul 27, 2016 11:47 am
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"
Re: Nagios Core 4.08 don't send traps in order.
Posted: Thu Jul 28, 2016 10:45 am
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.
Re: Nagios Core 4.08 don't send traps in order.
Posted: Thu Jul 28, 2016 1:58 pm
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.
Re: Nagios Core 4.08 don't send traps in order.
Posted: Thu Jul 28, 2016 2:13 pm
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
Re: Nagios Core 4.08 don't send traps in order.
Posted: Fri Jul 29, 2016 2:21 am
by Nagios_Admin_M
Sorry, the solution doesn't work. I still do not know how to solve it.
Re: Nagios Core 4.08 don't send traps in order.
Posted: Fri Jul 29, 2016 11:00 am
by rkennedy
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.
Re: Nagios Core 4.08 don't send traps in order.
Posted: Wed Aug 03, 2016 9:10 am
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 ?
Re: Nagios Core 4.08 don't send traps in order.
Posted: Wed Aug 03, 2016 10:14 am
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
Re: Nagios Core 4.08 don't send traps in order.
Posted: Wed Aug 03, 2016 3:39 pm
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.
Re: Nagios Core 4.08 don't send traps in order.
Posted: Thu Aug 04, 2016 3:51 am
by Nagios_Admin_M
I use the $SERVICEOUTPUT$ with service notification value, but I have an empty value in the log files.