Windows Service Event Handler Not Working
Posted: Thu Feb 18, 2021 1:00 pm
Good Day,
I am unable to get a simple service restart event handler working, the components all function separately (I.e., I can call the restart.bat from nrpe as well as execute the "libexec/restart_service.sh CRITICAL HOST spooler" command), however the service check appears to not execute it on failure. I've spent hours looking through the support forum and reviewing the documentation but nothing seems to work.
restart_service.sh perms:
ls -la libexec/restart_service.sh
-rwxr-xr-x. 1 apache nagios 158 Feb 18 10:01 libexec/restart_service.sh
restart_service.sh:
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$3"
;;
esac
exit 0
restart_service.bat:
@echo off
net stop %1
net start %1
@exit 0
Relevant nsclient.ini settings:
[/modules]
CheckExternalScripts = enabled
CheckHelpers = enabled
[/settings/NRPE/server]
allow arguments = true
[/settings/external scripts]
allow arguments = true
[/settings/external scripts/scripts]
restart_service=scripts\restart_service.bat "$ARG1$" (I have tried not wrapping $ARG1$ in quotes and get the same results)
Thank you
I am unable to get a simple service restart event handler working, the components all function separately (I.e., I can call the restart.bat from nrpe as well as execute the "libexec/restart_service.sh CRITICAL HOST spooler" command), however the service check appears to not execute it on failure. I've spent hours looking through the support forum and reviewing the documentation but nothing seems to work.
restart_service.sh perms:
ls -la libexec/restart_service.sh
-rwxr-xr-x. 1 apache nagios 158 Feb 18 10:01 libexec/restart_service.sh
restart_service.sh:
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$3"
;;
esac
exit 0
restart_service.bat:
@echo off
net stop %1
net start %1
@exit 0
Relevant nsclient.ini settings:
[/modules]
CheckExternalScripts = enabled
CheckHelpers = enabled
[/settings/NRPE/server]
allow arguments = true
[/settings/external scripts]
allow arguments = true
[/settings/external scripts/scripts]
restart_service=scripts\restart_service.bat "$ARG1$" (I have tried not wrapping $ARG1$ in quotes and get the same results)
Thank you