Page 1 of 1

eventhandler

Posted: Fri Sep 07, 2018 8:32 am
by alain1988
Hy,

i am attemting to create an event handler for my windows services but cant get it working.

what i have done is :

installed ns client on the windows side configured the base install (ip port etc).

created a script called restart_service.bat

Code: Select all

@echo off
net stop %1
net start %1
@exit 0
i created a script alias restart_service= scripts\restart_service.bat $ARG1$ and a script command restart_service = scripts\restart_service.bat $ARG1$

on the linux side i created a script and placed it in the libex folder :

Code: Select all

#!/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

and then i created a new command in commands.cfg

Code: Select all

#restart sevice
define command{
        command_name    restart_service
        command_line    $USER1$/restart_service $SERVICESTATE$ $HOSTADDRESS$
}

then i adjusted my server.cfg, but when is stop my service on the windows machine it does not restart how can i fix this ?

Re: eventhandler

Posted: Fri Sep 07, 2018 8:41 am
by scottwilkerson
We have a topic on the settings needed for this setup here
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

If you cannot restart the nsclient agent, I would look to the nsclient log to see what the error is after trying to restart