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 »

Did you fix the error from your previous post as that could be the problem?
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 »

[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.
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 »

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.
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 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'
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 »

I would assume this is causing the error
....$SERVICEOUTPUT$ /usr/bin/send_trap
Check your command definition and see if it is correct.
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 »

[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'
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 »

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$'
}
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 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.
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 »

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
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 have a log full with empty apostrophes.

"" "" "" "" "" "" "" "" "" ""
Locked