#!/bin/sh

# SUBMIT_CHECK_RESULT
# Written by Ethan Galstad (netsaint@netsaint.org) 
# Last Modified: 05-16-2000
#
# This script will write a command to the NetSaint command
# file to cause NetSaint to process a passive service check
# result.  Note: This script is intended to be run on the
# same host that is running NetSaint.  If you want to 
# submit passive check results from a remote machine, look
# at the submit_check_result_via_nsca 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,
#       -1=UNKNOWN).
#  $4 = plugin_output (A text string that should be used
#       as the plugin output for the service check)s
# 
 
echocmd="/bin/echo"
 
CommandFile="/usr/local/netsaint/var/rw/netsaint.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`

# Add code here to reset the ownership and permissions on
# the command file if necessary...