| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# SUBMIT_CHECK_RESULT |
| 4 |
# Written by Ethan Galstad ([email protected]) |
| 5 |
# Last Modified: 02-18-2002 |
| 6 |
# |
| 7 |
# This script will write a command to the Nagios command |
| 8 |
# file to cause Nagios to process a passive service check |
| 9 |
# result. Note: This script is intended to be run on the |
| 10 |
# same host that is running Nagios. If you want to |
| 11 |
# submit passive check results from a remote machine, look |
| 12 |
# at using the nsca addon. |
| 13 |
# |
| 14 |
# Arguments: |
| 15 |
# $1 = host_name (Short name of host that the service is |
| 16 |
# associated with) |
| 17 |
# $2 = svc_description (Description of the service) |
| 18 |
# $3 = return_code (An integer that determines the state |
| 19 |
# of the service check, 0=OK, 1=WARNING, 2=CRITICAL, |
| 20 |
# 3=UNKNOWN). |
| 21 |
# $4 = plugin_output (A text string that should be used |
| 22 |
# as the plugin output for the service check) |
| 23 |
# |
| 24 |
|
| 25 |
echocmd="/bin/echo" |
| 26 |
|
| 27 |
CommandFile="/usr/local/nagios/var/rw/nagios.cmd" |
| 28 |
|
| 29 |
# get the current date/time in seconds since UNIX epoch |
| 30 |
datetime=`date +%s` |
| 31 |
|
| 32 |
# create the command line to add to the command file |
| 33 |
cmdline="[$datetime] PROCESS_SERVICE_CHECK_RESULT;$1;$2;$3;$4" |
| 34 |
|
| 35 |
# append the command to the end of the command file |
| 36 |
`$echocmd $cmdline >> $CommandFile` |