Discussion:
submit_check_result script
Kenny Rasschaert
2013-12-20 09:26:16 UTC
Permalink
I'm trying to set up Icinga in a distributed configuration with one
remote Icinga instance and one central instance. I'm following the
instructions in this guide:
http://docs.icinga.org/latest/en/distributed.html

Section 7.6.7 "ocsp_command=submit_check_result" mentions the
submit_check_result command definition and shows the corresponding shell
script. That script basically pipes the right data into send_nsca and
sends it to the central Icinga server.

On my (Ubuntu Precise, Icinga 1.10) I found
/usr/share/icinga/plugins/eventhandlers/submit_check_result. That script
does something entirely different. It appends the data to the local
command file and doesn't use the NSCA client at all.
Here are the contents:

#!/bin/sh

# SUBMIT_CHECK_RESULT
# Written by Ethan Galstad (egalstad-hvcSvQUnuUQdnm+***@public.gmane.org)
# Modified by Icinga Development Team (https://dev.icinga.org)
#
# This script will write a command to the Icinga command
# file to cause Icinga to process a passive service check
# result. Note: This script is intended to be run on the
# same host that is running Icinga. If you want to
# submit passive check results from a remote machine, look
# at using the nsca addon.
#
# 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)
#

echocmd="/bin/echo"

CommandFile="/var/lib/icinga/rw/icinga.cmd"

# get the current date/time in seconds since UNIX epoch
datetime=`date +%s`

# create the command line to add to the command file
cmdline="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$4"

# append the command to the end of the command file
`$echocmd $cmdline >> $CommandFile`

I'm very confused now. Isn't the NSCA daemon supposed to be the one
writing to the command file? What's the purpose of this script? Should I
replace the contents of the submit_check_result script on the
distributed machine with the example given in the docs?

Right now I'm considering just creating the script with a different name
and use that for the ocsp_command.

--
Kenny Rasschaert
+32 497 72 27 69 | Open Source consultant - Inuits.eu
Michael Friedrich
2013-12-20 10:37:44 UTC
Permalink
Post by Kenny Rasschaert
I'm trying to set up Icinga in a distributed configuration with one
remote Icinga instance and one central instance. I'm following the
http://docs.icinga.org/latest/en/distributed.html
Section 7.6.7 "ocsp_command=submit_check_result" mentions the
submit_check_result command definition and shows the corresponding shell
script. That script basically pipes the right data into send_nsca and
sends it to the central Icinga server.
On my (Ubuntu Precise, Icinga 1.10) I found
/usr/share/icinga/plugins/eventhandlers/submit_check_result. That script
does something entirely different. It appends the data to the local
command file and doesn't use the NSCA client at all.
You're confusing an o{h.s}cp command and script with a script used for
event handlers which are a totally different story here.

- o{h.s}cp scripts are used to send passive checkresults via send_nsca
to the remote master. so the docs are right about that and only do tell
you that.
- the eventhandler script is used in a different context. Like
http://docs.icinga.org/latest/en/eventhandlers.html#serviceexample
unveils, eventhandlers are triggered on state changes. While you cannot
only restart your httpd server, you may also just re-send a new
checkresult based on the current state. that's reasonable for a check
triggering an alarm once and being reset to the ok state afterwards. or
any other possible use case - users have plenty of ideas how to use that
one.

i for myself use that script to test icinga 2, and force trigger events
based on incoming checkresults. Though, i've revamped the original
script a bit for icinga 2 using getopts and other stuff required for
proper operations (find it in tools/scripts/process_check_result)

You should follow the docs, and use the provided sample over there
including nsca. and while at it, you may consider nsca-ng as alternative
to nsca.
--
DI (FH) Michael Friedrich

mail: michael.friedrich-***@public.gmane.org
twitter: https://twitter.com/dnsmichi
jabber: dnsmichi-***@public.gmane.org
irc: irc.freenode.net/icinga dnsmichi

icinga open source monitoring
position: lead core developer
url: https://www.icinga.org
Continue reading on narkive:
Loading...