Event Handler script not running
Event Handler script not running
I can't get the event-handler script to run. I'm not getting any errors in the log file and the script runs manually.
Service:
define service{
use local-service
host_name localhost
service_description restart ulink PolicyServer
check_command check_ulink_procs!2:2!'uLinkPolicyServer'
check_interval 2
event_handler restart_ulink-policy
}
Handler (defined in command.cfg):
define command{
command_name restart_ulink-policy
command_line /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
The script is the template copied from the nagios event-handler instructions.
permissions for the script:
-rwxr-xr-x restart_ulink-policy
nagios.log doesn't indicate any problems:
[1430607293] SERVICE EVENT HANDLER: localhost;restart ulink PolicyServer;CRITICAL;SOFT;3;restart_ulink-policy
[1430607353] SERVICE ALERT: localhost;restart ulink PolicyServer;CRITICAL;HARD;4;PROCS CRITICAL: 0 processes with args 'uLinkPolicyServer'
[1430607353] SERVICE NOTIFICATION: nagiosadmin;localhost;restart ulink PolicyServer;CRITICAL;notify-service-by-email;PROCS CRITICAL: 0 processes with args 'uLinkPolicyServer'
[1430607353] SERVICE EVENT HANDLER: localhost;restart ulink PolicyServer;CRITICAL;HARD;4;restart_ulink-policy
[1430607593] SERVICE ALERT: localhost;restart ulink PolicyServer;OK;HARD;4;PROCS OK: 2 processes with args 'uLinkPolicyServer'
It seems the script isn't being run at all. echo commands in the script isn't being printed either.
Any help would be greatly appreciated as I'm out of ideas.
Service:
define service{
use local-service
host_name localhost
service_description restart ulink PolicyServer
check_command check_ulink_procs!2:2!'uLinkPolicyServer'
check_interval 2
event_handler restart_ulink-policy
}
Handler (defined in command.cfg):
define command{
command_name restart_ulink-policy
command_line /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
The script is the template copied from the nagios event-handler instructions.
permissions for the script:
-rwxr-xr-x restart_ulink-policy
nagios.log doesn't indicate any problems:
[1430607293] SERVICE EVENT HANDLER: localhost;restart ulink PolicyServer;CRITICAL;SOFT;3;restart_ulink-policy
[1430607353] SERVICE ALERT: localhost;restart ulink PolicyServer;CRITICAL;HARD;4;PROCS CRITICAL: 0 processes with args 'uLinkPolicyServer'
[1430607353] SERVICE NOTIFICATION: nagiosadmin;localhost;restart ulink PolicyServer;CRITICAL;notify-service-by-email;PROCS CRITICAL: 0 processes with args 'uLinkPolicyServer'
[1430607353] SERVICE EVENT HANDLER: localhost;restart ulink PolicyServer;CRITICAL;HARD;4;restart_ulink-policy
[1430607593] SERVICE ALERT: localhost;restart ulink PolicyServer;OK;HARD;4;PROCS OK: 2 processes with args 'uLinkPolicyServer'
It seems the script isn't being run at all. echo commands in the script isn't being printed either.
Any help would be greatly appreciated as I'm out of ideas.
Re: Event Handler script not running
Please post the output of the following command:
Have you tried running it as the nagios user?
Code: Select all
ls -l /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy
Code: Select all
su nagios
cd /usr/local/nagios/libexec/eventhandlers
./restart_ulink-policy
Re: Event Handler script not running
Thanks for your reply.
The output for the ls is:
ls -l /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy
-rwxr-xr-x 1 nagios nagios 2815 May 3 14:40 /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy
I can't su to nagios because it's asking for a password and I don't know what it is.
Where can i find it?
The output for the ls is:
ls -l /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy
-rwxr-xr-x 1 nagios nagios 2815 May 3 14:40 /usr/local/nagios/libexec/eventhandlers/restart_ulink-policy
I can't su to nagios because it's asking for a password and I don't know what it is.
Where can i find it?
Re: Event Handler script not running
sudoer.
Tried switching but nothing happens:
/usr/local/nagios/etc/objects$ sudo su nagios
$ cd /usr/local/nagios/libexec/eventhandlers ./restart_ulink-policy
$
no errors but the script isn't running
Tried switching but nothing happens:
/usr/local/nagios/etc/objects$ sudo su nagios
$ cd /usr/local/nagios/libexec/eventhandlers ./restart_ulink-policy
$
no errors but the script isn't running
Re: Event Handler script not running
I'm sorry if this sounds stupid, but it doesn't look like i switched user, it looks like i switched environment.
Re: Event Handler script not running
Post the output of the following command:
Code: Select all
grep nagios /etc/passwd
Re: Event Handler script not running
Code: Select all
/usr/local/nagios/libexec/eventhandlers$ grep nagios /etc/passwd
nagios:x:1001:1001::/home/nagios:/bin/sh
Re: Event Handler script not running
Ok, let's try this:
Nothing happens? No errors or anything? Is it supposed to output anything?
Can you attach your restart_ulink-policy script so we can review it (might want to sanitize it first)?
Code: Select all
sudo su - nagios
Code: Select all
cd /usr/local/nagios/libexec/eventhandlers
Code: Select all
./restart_ulink-policy
Can you attach your restart_ulink-policy script so we can review it (might want to sanitize it first)?
Re: Event Handler script not running
Ok, there was a permission problem. Now it runs the script and I get the echo printouts, but it's ignoring the command:
Could it be a sudo problem?
Code: Select all
sudo nohup mono >/dev/null /opt/ulink/Tools/PolicyServer/uLinkPolicyServer.exe &