Event Handler for Restart-Service

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Event Handler for Restart-Service

Post by kwhogster »

benjaminsmith

I thought my event handler logic was simple

Has anyone reviewed my logic?

Does anyone have a working event handler that they can post

Thanks
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Event Handler for Restart-Service

Post by gormank »

I won't claim to be good with the event handlers and am following along to educate myself.
From what I can see there's a command to check the service, that runs an EH that runs on the Nagios host that in turn runs the command (via nrpe) on the remote host to do the restart.
One thing is the local command and the remote command have the same name. You might rename the remote command and script to restart_service_win and restart_service_win.cmd. I don't see this as helping, but something is going on that we're missing.
That said, it looks like somehow, on the nagios server, it isn't finding the shell script although it exists. All I can think is there's some slight mistake in the path or something that we're missing.
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Event Handler for Restart-Service

Post by kwhogster »

Is there another log we can looks at ???
The nagios log reports this

[1598558394] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;1;CRITICAL: Spooler: stopped delayed ()
[1598558394] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;1;restart_service
[1598558454] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;2;CRITICAL: Spooler: stopped delayed ()
[1598558454] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;2;restart_service
[1598558514] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;3;CRITICAL: Spooler: stopped delayed ()
[1598558514] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;3;restart_service
[1598558574] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;4;CRITICAL: Spooler: stopped delayed ()
[1598558574] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;4;restart_service
[1598558634] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;5;CRITICAL: Spooler: stopped delayed ()
[1598558634] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;5;restart_service
[1598558695] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;6;CRITICAL: Spooler: stopped delayed ()
[1598558695] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;6;restart_service
[1598558754] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;7;CRITICAL: Spooler: stopped delayed ()
[1598558754] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;7;restart_service
[1598558814] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;8;CRITICAL: Spooler: stopped delayed ()
[1598558814] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;8;restart_service
[1598558874] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;9;CRITICAL: Spooler: stopped delayed ()
[1598558874] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;9;restart_service
[1598558934] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;HARD;10;CRITICAL: Spooler: stopped delayed ()
[1598558934] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;HARD;10;restart_service
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Event Handler for Restart-Service

Post by kwhogster »

Guys

I tested on the client side by running NSCP TEST from a command prompt after stopping the nscp service.

I monitored the test and saw no activity from the nagios server when a service was stopped.

When I ran the command manually on the nagios service I saw the command on the test console.
So the client is fine it has to be on the nagios server side it looks like the command is not running

Anyway to trace this on the nagios server?
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Event Handler for Restart-Service

Post by kwhogster »

Well
I renamed the script and command to restart-aservice.sh and restart-aservice

Same results.

Nagios is not send a request to the nsclient to run the command

Some in Nagios is not correct

Need help.....
kwhogster
Posts: 644
Joined: Wed Oct 14, 2015 6:51 pm
Location: Wood Ridge NJ USA
Contact:

Re: Event Handler for Restart-Service

Post by kwhogster »

This is still not working.

I am most surely it is on the Nagios side.

The tail command of the nagios log was not helpful

There has be be another log to look at

Any one have this working ? If so please share your files.

Thank you
Locked