Page 3 of 4

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

Posted: Thu Aug 04, 2016 11:17 am
by tgriep
Did you fix the error from your previous post as that could be the problem?

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

Posted: Thu Aug 04, 2016 11:28 am
by Nagios_Admin_M
[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


I do not know what is 127 error code.
I do not know what last line means either.

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

Posted: Thu Aug 04, 2016 11:49 am
by tgriep
You may want to edit the nagios.cfg file and enable debugging and restart nagios, then check the nagios.debug log for that error and which script is causing it.

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

Posted: Thu Aug 04, 2016 12:44 pm
by Nagios_Admin_M
I have in nagios.debug:

TCP OK - 0.042 second response time on 42.1.234.145 port 80


I found also
....$SERVICEOUTPUT$ /usr/bin/send_trap'

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

Posted: Thu Aug 04, 2016 12:51 pm
by tgriep
I would assume this is causing the error
....$SERVICEOUTPUT$ /usr/bin/send_trap
Check your command definition and see if it is correct.

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

Posted: Thu Aug 04, 2016 12:56 pm
by Nagios_Admin_M
[1470332185.319560] [2048.1] [pid=7466] Processing: '/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ | var2=$HOSTNAME$ var3=$HOSTSTATEID$ var5=$SERVICEDESC$ var6=$SERVICESTATEID$ var9=$SERVICEATTEMPT$ var8=$LASTSERVICESTATECHANGE$ var7=$SERVICEDURATIONSEC$ var10=$LASTSERVICECHECK$ var11=$SERVICEOUTPUT$ /usr/bin/send_trap'

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

Posted: Thu Aug 04, 2016 1:08 pm
by tgriep
It looks like you need to change the notify-service-by-email command. Try the example below and see if that works. You may have to edit it for your needs.

Code: Select all

define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$; /usr/bin/send-host-trap '$HOSTNAME$' '$HOSTSTATEID$' '$SERVICEDESC$' '$SERVICESTATEID$' '$SERVICEATTEMPT$' '$LASTSERVICESTATECHANGE$' '$SERVICEDURATIONSEC$' '$LASTSERVICECHECK$' '$SERVICEOUTPUT$'
}

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

Posted: Fri Aug 05, 2016 9:43 am
by Nagios_Admin_M
I used yours command definition created log file see the values.

#send-service-trap
cat << EOF >> /logfile
'$HOSTNAME$' '$HOSTSTATEID$' '$SERVICEDESC$' '$SERVICESTATEID$' '$SERVICEATTEMPT$' '$LASTSERVICESTATECHANGE$' '$SERVICEDURATIONSEC$' '$LASTSERVICECHECK$' '$SERVICEOUTPUT$'
EOF

#logfile
'host_name '$' '$' '$' '$' '$' '$' '$' '$' '$'

This is what I got. Although an email is sent plus there is a full date log in the nagios.log file.

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

Posted: Fri Aug 05, 2016 2:10 pm
by ssax
Is this what you have in your command definition or is it your send-service-trap script?

Code: Select all

#send-service-trap
cat << EOF >> /logfile
'$HOSTNAME$' '$HOSTSTATEID$' '$SERVICEDESC$' '$SERVICESTATEID$' '$SERVICEATTEMPT$' '$LASTSERVICESTATECHANGE$' '$SERVICEDURATIONSEC$' '$LASTSERVICECHECK$' '$SERVICEOUTPUT$'
EOF
If it is your script, try this:
- Note: I just added ${10} so you can see how to use multiple digit ones

Code: Select all

#send-service-trap
cat << EOF >> /logfile
"$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" "${10}"
EOF
You can only access the variables in your script with $0, $1, $2, etc, it will not know about the nagios macros, only the arguments that it's passed in.

Thank you

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

Posted: Fri Aug 05, 2016 5:09 pm
by Nagios_Admin_M
I have a log full with empty apostrophes.

"" "" "" "" "" "" "" "" "" ""