www.fgks.org   »   [go: up one dir, main page]

blob: 71250070564de3db5252f3d4a44a899214b732be [file] [log] [blame]
#!/bin/sh
# SUBMIT_CHECK_RESULT
# Written by Ethan Galstad (egalstad@nagios.org)
# Modified by Leslie Carr (lcarr@wikimedia.org)
# Modified by Daniel Zahn (dzahn@wikimedia.org)
#
# Last Modified: 09-05-2018
#
# This script will write a command to the Nagios command
# file to cause Nagios to process a passive service check
# result. Note: This script is intended to be run on the
# same host that is running Nagios. 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`
# make hostname correct for our nagios setup
hostname=`echo $1 | awk -F . ' { print $1 } '`
# create the command line to add to the command file
cmdline="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$hostname;$2;$3;$4"
# append the command to the end of the command file
echo "$cmdline" >> $CommandFile