Page 1 of 2

EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPENS

Posted: Fri May 05, 2017 11:57 am
by phpsteve
Hello,

First.. YES.. I did try and look through the articles but did not find anything that worked for me. And YES it is possible I missed some good articles.. I know NagiosSQL is not your product but I am expecting that the result would likely be the same regardless of the event handler being in nagiossql or nagios :D

Here is my issue if anyone can help..

I need to restart a windows service (remotely.. not executed from a .sh script in nagios). I have it setup as follows:

* In NagioSQL I have a check command called "Check_Printer_Restart" ( /usr/local/nagios/libexec/check_nrpe -H $ARG1$ -c get_restart)
* On the windows server, I have a batch file and the config points to the proper location to restart a service
* In NagioSQL I have the service template configured to use the Event Handler check command above
* I have Event Handling enabled
* If I sudo to nagios and execute the command manually, that works too.


So if I run the command manually from the nagios box it works and stops the Windows service ( I say stop and not restart because I want to make sure it is working and not restarting before I catch it)

"/usr/lib64/nagios/plugins/check_nrpe -H x.x.x.x -c get_restart"

If I let the service run and try and have it do it on it's normal check, I see the output below in the nagios.log

"SERVICE EVENT HANDLER: MYSERVER;HTTP;OK;HARD;3;check_printer_restart"


So I see it says it executed.. but that is all I get log wise.. On the windows server, it never executes. I'm also trying to have this happen on the hard 3rd final attempt but for now I just need to get it to execute. Thanks!

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 12:13 pm
by tgriep
Could you post how the check_printer_restart command is defined as well as the service check with the event handler so we can verify it's settings?

On the Windows system, do you see any entries when the event handler runs in the nsclient.log file?

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 12:24 pm
by phpsteve
Sure.. Let me know if you need more info.

Here is the Check Command itself:
check_command1.JPG
Here is the Event Handler setting: The rest are blank because I have a service template for the other configs.. I also tried the Event setting in the service template as well..
check_command2.JPG
define service {
#NAGIOSQL_CONFIG_NAME MYSERVER
host_name MYSERVER
service_description HTTP
use generic-service
check_command check_http!-e 302
event_handler check_printer_restart
event_handler_enabled 1
notes_url
register 1
}


Windows NRPE config file: command[get_restart]=c:\nrpe_nt\plugins\v2\restarting.bat

I see nothing in the Windows Event Logs.

Nagios.log shows:
check_command3.JPG

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 12:27 pm
by phpsteve
Sorry.. here is the side showing enabled as well...
check_command4.JPG

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 12:48 pm
by tgriep
Your test shows that you ran the check_nrpe command from the /usr/lib64/nagios/plugins folder but the command is using the /usr/local/nagios/libexec folder.
Verify that the path it correct and that the plugin is executible by the nagios user account as well as the nagios group.

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 12:53 pm
by phpsteve
I have verified that the path is correct.. and I was able to run it as the user/group without issue and that the service stopped on the windows side. The nrpe exists in both.. pre NagioSQL implementation.. but still works.

Also.. to note.. if I make it the Service Template.. and not the event handler.. it works. It is only when it becomes an Event Handler that it does nothing.

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 1:57 pm
by tgriep
That is strange that making it a template made it work.

The nagios.log file shows that the event runs so maybe the settings in the SQL database it not getting written to the nagios cfg files.
Can you login to the nagios server as root and check the config file for that service and see if it is configured correctly.
Also, there is a file called objects.cache on the server, typically it is in the /usr/local/nagios/var folder and that file has the current running configuration.
Can you look in that file, check to see if the command is setup correctly and also the service check is setup correctly.

Post those entries here so we can view them.

Please run the following as root on the server and post the output.

Code: Select all

ls -l /usr/lib64/nagios/plugins/check_nrpe
ls -l /usr/local/nagios/libexec/check_nrpe

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 2:11 pm
by phpsteve
That's what I thought as well.. I viewed the cfg files that the DB writes to and they match.
nagios1.JPG
Executing either manually works:
nagios2.JPG

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 2:23 pm
by tgriep
The config file looks like the the handler is defined but the event handler is not enabled so there is something wrong there.

Code: Select all

event_handler_enabled 1

Re: EVENT HANDLER NAGIOS / NAGIOSSQL RUNS BUT NOTHING HAPPEN

Posted: Fri May 05, 2017 3:40 pm
by phpsteve
Sorry.. part of my screenshot was cut off.. but that enabled 1 is there.
nagios3.JPG
nagios3.JPG (25.13 KiB) Viewed 2432 times