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.
I stopped the spooler service on the test desktop computer and Nagios alerted me that the service was stopped and critical.
I was expecting the event handler to run the cmd file and start the service but it did not .
The first place to check woudl be the Nagios Log to verify that the event handler script was called by the nagios service as defined in your configurations.
[1598297389] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;TGKW002;Check All Service;1598297386
[1598297389] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;1;CRITICAL: Spooler: stopped delayed ()
[1598297389] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;1;restart_service
[1598297389] wproc: SERVICE EVENTHANDLER job 282 from worker Core Worker 12659 is a non-check helper but exited with return code 127
[1598297389] wproc: early_timeout=0; exited_ok=1; wait_status=32512; error_code=0;
[1598297389] wproc: stderr line 01: /bin/sh: 1: /usr/local/nagios/libexec/restart_service: not found
[1598297398] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;TGKW002;Check All Service;1598297396
[1598297398] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;2;CRITICAL: Spooler: stopped delayed ()
[1598297398] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;2;restart_service
[1598297398] wproc: SERVICE EVENTHANDLER job 285 from worker Core Worker 12661 is a non-check helper but exited with return code 127
[1598297398] wproc: early_timeout=0; exited_ok=1; wait_status=32512; error_code=0;
[1598297398] wproc: stderr line 01: /bin/sh: 1: /usr/local/nagios/libexec/restart_service: not found
Looks like it is not able to find the script should I change it to
/usr/local/nagios/libexec/restart_service.sh ?????????
OK I added the .sh and now I do not get the error above.
But it still does not run the script see this log
[1598300928] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;TGKW002;Check All Service;1598300916
[1598300928] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;1;CRITICAL: Spooler: stopped delayed ()
[1598300928] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;1;restart_service
[1598300933] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;TGKW002;Check All Service;1598300932
[1598300933] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;2;CRITICAL: Spooler: stopped delayed ()
[1598300933] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;2;restart_service
[1598300993] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;3;CRITICAL: Spooler: stopped delayed ()
[1598300993] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;3;restart_service
[1598301054] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;4;CRITICAL: Spooler: stopped delayed ()
[1598301054] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;4;restart_service
[1598301113] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;5;CRITICAL: Spooler: stopped delayed ()
[1598301113] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;5;restart_service
[1598301173] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;6;CRITICAL: Spooler: stopped delayed ()
[1598301173] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;6;restart_service
[1598301233] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;7;CRITICAL: Spooler: stopped delayed ()
[1598301233] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;7;restart_service
[1598301293] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;8;CRITICAL: Spooler: stopped delayed ()
[1598301293] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;8;restart_service
[1598301353] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;SOFT;9;CRITICAL: Spooler: stopped delayed ()
[1598301353] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;SOFT;9;restart_service
[1598301414] SERVICE ALERT: TGKW002;Check All Service;CRITICAL;HARD;10;CRITICAL: Spooler: stopped delayed ()
[1598301414] SERVICE EVENT HANDLER: TGKW002;Check All Service;CRITICAL;HARD;10;restart_service
root@tgcs017:/usr/local/nagios/etc/objects#
When I run the command from the nagios server manually it works
root@tgcs017:/usr/local/nagios/libexec# /usr/local/nagios/libexec/check_nrpe -H "TGKW002" -p 5666 -c restart_service -a "spooler"
The Print Spooler service is stopping.
The Print Spooler service was stopped successfully.
The Print Spooler service is starting.
The Print Spooler service was started successfully.
So I believe the nsclinet.ini is setup correctly and the permissions are ok because as you can see the script runs.
Since it's not a permissions issue, perhaps the logic in the event handler is not working as expected. You can verify this by creating a simple event handler that directly runs the restart script.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!