Restart Windows Failed Service batch script with log. File: win_service_restart.cmd Author: Vadims Zenins http://vadimszenins.blogspot.com Version: 1.04 Date: 20/04/2009 17:41 Windows Failed Service restart batch file for Nagios Event Handler
Copy win_service_restart.cmd to NSClient++scripts folder.
Nagios commands.cfg:
define command{
command_name win_service_restart
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666 -c win_service_restart -a "$SERVICEDESC$" $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
Nagios template-services_common-win.cfg
define service{
name generic-service-win-wuauserv
service_description wuauserv
display_name Automatic Updates
event_handler win_service_restart
event_handler_enabled 1
check_command check_nt!SERVICESTATE!-d SHOWALL -l $SERVICEDESC$
}
NSCLIENT++ NSC.ini:
[NRPE] allowed_hosts=192.168.1.1/32 ; your Nagios server IP allow_arguments=1 [External Script] allow_arguments=1 allow_nasty_meta_chars=1 [NRPE Handlers] command[win_service_restart]=scriptswin_service_restart.cmd "$ARG1$" $ARG2$ $ARG3$ $ARG4$
Version 1.04 revision: Double restart of the servise is fixed
Version 1.03 revision: Description is changed
Version 1.02 revision: @NET changed to @SC
Version 1.01 revision: Service name's with spase problem is fixed
http://vadimszenins.blogspot.com/2008/12/nagios-restart-windows-failed-services.html
md5: fd00753533e5fb655d824c3bf1d36d4f *win_service_restart.zip