OK…this is a bit different from what I usually post here, but I want to put this somewhere in case anyone else is ever trying to figure this out.

After fighting with Nagios distributed monitoring off and on for months, I have concluded that the submit_check_result_via_nsca script is just broken. It is sending the service state (“OK”, “CRITICAL”, etc.) to nsca, which is expecting a return code (-1,0,1,2).

The solution is to just change the script. Here is my version:

#!/bin/sh
# SUBMIT_CHECK_RESULT_VIA_NSCA
# Written by Ethan Galstad (nagios@nagios.org)
# Last Modified: 11-21-2008 by Brian Knotts
#
# This script will send passive check results to the
# nsca daemon that runs on the central Nagios server.
# If you simply want to submit passive checks from the
# same machine that Nagios is running on, look at the
# submit_check_result script.
#
# Arguments:
#  $1 = host_name (Short name of host that the service is
#       associated with)
#  $2 = svc_description (Description of the service)
#  $3 = return_code (An integer that determines the state
#       of the service check, 0=OK, 1=WARNING, 2=CRITICAL,
#       3=UNKNOWN).
#  $4 = plugin_output (A text string that should be used
#       as the plugin output for the service check)s
#
#
# Note:
# Modify the NagiosHost parameter to match the name or
# IP address of the central server that has the nsca
# daemon running.
printfcmd="/usr/bin/printf"
NscaBin="/usr/sbin/send_nsca"
NscaCfg="/etc/send_nsca.cfg"
NagiosHost="<your nagios central server>"
# 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=3
;;
esac
# Fire the data off to the NSCA daemon using the send_nsca script
$printfcmd "%s\t%s\t%s\t%s\n" "$1" "$2" $return_code "$4" | $NscaBin -H $NagiosHost -c $NscaCfg
# EOF