Page 1 of 1

NCPA service event handler not working

Posted: Mon Feb 22, 2021 6:48 am
by HIINNS
All,

I am currently using Nagios XI 5.7.5 and am trying to set up a service (RLM) to restart when it is not available. I believe I have configured it correctly, and am able to execute the ./check_ncpa.py -H 10.25.14.3 -P 5693 -t Str0ngT0k3n -M 'plugins/restart_service.bat' -a RLM and /usr/local/nagios/libexec/restart_service.sh CRITICAL 10.25.14.3 Str0ngT0k3n RLM from the command line. I added Service Restart - WIndows to Commands as a Misc command type, and checked Active. On the Check Settings tab of the Service I set the Event Handler dropdown as Service Restart - Windows, and set Event handler enabled to On. On the Manage Free Variables window I ser _xwizart to ncpa, and _service to RLM. I turned off the RLM service on the Windows server, and Nagios reports that the service is down. However, the service fails to restart. Am I doing something wrong? I pretty much tried for 6 hours last Friday to get it to work. :cry:

Re: NCPA service event handler not working

Posted: Mon Feb 22, 2021 11:17 am
by HIINNS
I have also checked the /usr/local/nagios/var/nagios.log for errors. Could not find any.

Re: NCPA service event handler not working

Posted: Mon Feb 22, 2021 6:41 pm
by ssax
Please send a copy of your profile.zip, you can download it from Admin > System Profile by clicking the Download Profile button.

Please attach this file:

Code: Select all

/usr/local/nagios/libexec/restart_service.sh
Include the output of this command:

Code: Select all

ls -l /usr/local/nagios/libexec/restart_service.sh

Re: NCPA service event handler not working

Posted: Fri Feb 26, 2021 5:25 am
by HIINNS
Have you received my last post? I sent it this past Wednesday.

Re: NCPA service event handler not working

Posted: Mon Mar 01, 2021 1:10 pm
by ssax
The script expects four arguments but the command is only passing three:

Code: Select all

define command {
    command_name    Service Restart - Windows
    command_line    $USER1$/restart_service.sh $SERVICESTATE$ $HOSTADDRESS$ $_SERVICESERVICE$
}
It should be this:

Code: Select all

define command {
    command_name    Service Restart - Windows
    command_line    $USER1$/restart_service.sh $SERVICESTATE$ $HOSTADDRESS$ 'your_NCPA_token' $_SERVICESERVICE$
}
Try that and see if it resolves the issue.

Re: NCPA service event handler not working

Posted: Mon Mar 01, 2021 1:38 pm
by HIINNS
Please feel free to close this case. I finally figured out that the restart_service.sh script did not contain the token.

Re: NCPA service event handler not working

Posted: Mon Mar 01, 2021 1:41 pm
by scottwilkerson
HIINNS wrote:Please feel free to close this case. I finally figured out that the restart_service.sh script did not contain the token.
Great!

Locking thread