@computerone, Right now you're passing all three services under the $_SERVICESERVICE$ variable. So all three service names get assigned to $3 in your event handler. Windows can not restart 3 processes at the same time using net start. So what you could do:
a) change the command to pass each service as a new argument to the event handler:
Code: Select all
define command {
command_name Service Restart - Windows
command_line $USER1$/restart_service.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$ $_SERVICESERVICE$ $_SERVICESERVICE$ $SERVICESTATETYPE$ $HOSTDOWNTIME$ $SERVICEDOWNTIME$
}
Then in the event handler you run the command three times with a different argument==servicename each time. $4, $5, $6 in my example.
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$4" >> $logfile
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$5" >> $logfile
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c restart_service -a "$6" >> $logfile
But, as you can probably guess this won't work quite well because the event handler will have to restart all three services each time, there is no way for it to determine which one went down. Nagios will always pass all services to $_SERVICESERVICE$, not just the one that caused the check to go critical.
So either you can pass all of the services to the restart script on Windows and modify the windows script to dynamically determine which of three services is actually down, or just create a separate check for each service and use the same event handler.