/usr/share/icinga/plugins/eventhandlers/distributed-monitoring/send_nsca_host_or_service_check_result is in nagios-plugins-contrib 14.20141104.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/bin/bash
# Enhanced version of the send_nsca wrappers to handle service and host checks.
# Allows to specify the nsca host and send_nsca config file in the command definition.
#define command{
# command_name obsessive_host_handler
# command_line /usr/share/icinga/plugins/eventhandlers/distributed-monitoring/send_nsca_host_or_service_check_result '$_HOSTOCHP_HOST$' '$_HOSTOCHP_CONFIG$' '$HOSTNAME$' '$HOSTSTATE$' '$HOSTOUTPUT$\\n$LONGHOSTOUTPUT$|$HOSTPERFDATA$'
#}
#define command{
# command_name obsessive_service_handler
# command_line /usr/share/icinga/plugins/eventhandlers/distributed-monitoring/send_nsca_host_or_service_check_result '$_SERVICEOCSP_HOST$' '$_SERVICEOCSP_CONFIG$' '$HOSTNAME$' '$SERVICEDESC$' '$SERVICESTATE$' '$SERVICEOUTPUT$\\n$LONGSERVICEOUTPUT$|$SERVICEPERFDATA$'
#}
NSCA_HOST="$1"
shift
SEND_NSCA_CFG="$1"
shift
# Service check
# 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)
#
# Host check
# Arguments:
# $1 = host_name (Short name of host that the service is
# associated with)
# $2 = state_string (A string representing the status of
# the given service - "OK", "WARNING", "CRITICAL"
# or "UNKNOWN")
# $3 = plugin_output (A text string that should be used
# as the plugin output for the service checks)
#
HOSTNAME="$1"
shift
if [ $# -eq 3 ]; then
# we have a service check
# append service name to target.
SERVICE="${1}"
shift
fi
# Convert the state string to the corresponding return code
RETURN_CODE=-1
case "$1" in
OK|UP)
RETURN_CODE=0
;;
WARNING)
RETURN_CODE=1
;;
CRITICAL|DOWN)
RETURN_CODE=2
;;
UNKNOWN|UNREACHABLE)
RETURN_CODE=3
;;
esac
shift
# 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
if [ -n "${SERVICE}" ]; then
/usr/bin/printf "%s\t%s\t%s\t%s\n" "${HOSTNAME}" "${SERVICE}" "$RETURN_CODE" "$1"
else
/usr/bin/printf "%s\t%s\t%s\n" "${HOSTNAME}" "$RETURN_CODE" "$1"
fi | /usr/sbin/send_nsca -H ${NSCA_HOST} -c ${SEND_NSCA_CFG}
|