ssax wrote:Ok, since you've changed the names on them, let's look at everything from the beginning, the permissions look good.
Your event handler command (restart_service_eh) should be exactly this based on your .sh script name:
Code: Select all
$USER1$/restart_service_script.sh $SERVICESTATE$ $HOSTADDRESS$ '$SERVICEOUTPUT$'
Confirmed. It is that exactly.
ssax wrote:The rest of the settings look proper.
Is that how it is currently?
Yes, those are the current settings for the service and template.
ssax wrote:Are you including the spooler service in the check command, stopping the print spooler service, and then manually forcing an immediate check or doing it with a different service?
I'm using a different service for testing; mfcom. Spooler has a dependent relationship with the Citrix print service on this server, so to not complicate things I picked one that doesn't have that. The procedure you noted is what I'm doing.
ssax wrote:Did you revert the restart_service_script.sh code to the one that I posted?
I have not. It is still the most recent posted in the thread. Can you post what I should revert it to?
Edit: I found it. Here it is with the current batch file name.
I think it's working!! I'm testing a few scenarios. I'll report back shortly.
Code: Select all
#!/bin/sh
# Event Handler for Restarting Windows Services
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
crittext='CRITICAL: '
autodeltext=' (auto), delayed ()'
autotext=' (auto)'
stoppedtext='=stopped'
stripped=${3//$crittext/}
stripped=${stripped//$autodeltext/}
stripped=${stripped//$autotext/}
stripped=${stripped//$stoppedtext/}
stripped=${stripped//, /,}
IFS=',' read -a array <<< "$stripped"
pattern='\ '
for ((i=0; i<${#array[@]}; i++));
do
if [[ ${array[$i]} =~ $pattern ]]; then
array[$i]="'${array[$i]}'"
fi
done
services=$(IFS=,; echo "${array[*]}")
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service_batch -a "$services"
;;
esac
exit 0