submit_check_result problems

I posted this to nagios-users too, I’m running to a problem with submit_check_result…

Hey everyone – I’m having a problem with
submit_check_result. I’m attempting to setup a
distributed configuration with Nagios 2.0. On the
distributed server I have

obsess_over_services=1
ocsp_command=submit_check_result

and from the submit_check_result script:

/usr/bin/printf “%s\t%s\t%s\t%s\n” “$1” “$2"
”$return_code" “$4” |
/usr/local/libexec/nagios/send_nsca 192.168.11.27 -c
/usr/local/etc/nagios/send_nsca.cfg

and in the checkcommands.cfg:

define command{
command_name submit_check_result
command_line
/usr/local/libexec/nagios/submit_check_result
$HOSTNAME$ ‘$SERVICEDESC$’ $SERVICESTATE$ ‘$OUTPUT$’
}

Here seems to be the problem, i never get a
PROCESS_SVC_CHECK_RESULT command entered. I have
debugging turned on for nsca and when watch
/var/log/messages on the central server I see this
entry:

Aug 27 15:33:13 nagios3 nsca[10900]: SERVICE CHECK ->
Host Name: ‘w2k-813’, Service Description: ‘submit’,
Return Code: ‘0’, Output: '$OUTPUT$'
Aug 27 15:33:13 nagios3 nsca[10900]: End of
connection…

This is all running on FreeBSD as well. Is there
something wrong with printf or one of the variables?
As you can tell, i’m not very good with shell
programming. If there is any more information I can
provide, please let me know. Any insight at all into
this problem would be very much appreciated.

Thanks,
Bill

You got your script from the docs and I didn’t have much luck with that one.
I use the following script, obtained from ??? (maybe the readme with nsca).

#!/bin/sh

    # Arguments:
    #  $1 = host_name (Short name of host that the service is
    #       associated with)
    #  $2 = svc_description (Description of the service)
    #  $3 = state_string (A string representing the status of
    #       the given service - "OK", "WARNING", "CRITICAL"
    #       or "UNKNOWN")
    #  $4 = plugin_output (A text string that should be used
    #       as the plugin output for the service checks)
    #

    # Convert the state string to the corresponding return code
    return_code=-1

    case "$3" in
        OK)
                    return_code=0
                ;;
            WARNING)
                return_code=1
                    ;;
            CRITICAL)
                return_code=2
                    ;;
            UNKNOWN)
                return_code=-1
                    ;;
    esac

    # pipe the service check info into the send_nsca program, which
    # in turn transmits the data to the nsca daemon on the central
    # monitoring server

    /bin/echo "$1\\t$2\\t$return_code\\t$4\\n" | /export/home/nagios/bin/send_nsca centralserveripaddy -c /export/home/nagios/etc/send_nsca.cfg

Try that one instead.

Edited Sun Aug 28 2005, 08:21AM ]

Hi guys. I had the same problems. Use a real “tab” in the script instead of the \t (that is backslash t, the backslash don’t show in this portal). So don’t put in a backslash t but a real tab!

Grz. Johan

It works!!! Thanks for all your help!