LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Nagios Event Handler issue (https://www.linuxquestions.org/questions/linux-networking-3/nagios-event-handler-issue-624316/)

lil_drummaboy 02-27-2008 05:25 PM

Nagios Event Handler issue
 
Hey Guys,

I have followed Nagios' document regarding event handlers to set one up:

http://nagios.sourceforge.net/docs/1...thandlers.html

I used the same paths and filenames and everything, the only difference being that the apache restart commmand in the script provided in that document, is an:

ssh user@host -i <RSA Key to login directly> -c "sudo /etc/rc.d/init.d/httpd restart"

Rather than the:

"/etc/rc.d/init.d/httpd restart"

I am able to test this script as user nagios on my nagios server, and it execs fine:

"[root@monitor nagios]# su - nagios -c "/usr/local/nagios/libexec/eventhandlers/restart-httpd CRITICAL HARD"
Restarting HTTP service...
[root@monitor nagios]#"

So nagios has the permissions to exec it.

Here are my config options regarding the service I speak of:

Commands.cnf:

"define command{
command_name restart-httpd
command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd $SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$
}"

Nagios host file:

"define service{
use local-service ; Name of service template to use
host_name content3
service_description HTTP
check_command check_http
notifications_enabled 1
event_handler restart-httpd
}"

local-service:

"define service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 4 ; Re-check the service up to 4 times in order to determine its final (hard) state normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined contact_groups admins,mobile ; Notifications get sent out to everyone in the 'admins' group
event_handler_enabled 1
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}"

With all of this set, I shutdown apache on the remote server, nagios detects it and still never execs the event handler. I even tail the logs and it goes straight to "Critical/Hard" state, then sends notifications without ever running the event handler. Event handler logging is in fact enabled in the global nagios.cnf.

If anyone can point out what I missed, or where to start looking I would be very very happy!

Thanks guys!

Tim

unSpawn 02-27-2008 05:47 PM

Quote:

Originally Posted by lil_drummaboy (Post 3071947)
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

Don't mind me because I know zilch about Nagios but isn't this "register 1; yes, I've enabled stuff, this is not a template."?

lil_drummaboy 02-27-2008 07:10 PM

Quote:

Originally Posted by unSpawn (Post 3071966)
Don't mind me because I know zilch about Nagios but isn't this "register 1; yes, I've enabled stuff, this is not a template."?

I have no clue really. It is working and all my services use "local-service". It is kind of unclear what they mean by this comment, to me at least.

twantrd 02-29-2008 03:03 AM

It means that it's a template and not an actual service/host definition. Looks like you have 2 templates - local-service and generic-service but you're using the local-service template. If the local-service template definition was set to 'register 1', then it's no longer a template and you have just defined it as a service/host. Kind of makes sense?

Anyhow, back to your problem....the obvious thing that I can see is your command definition syntax:

Quote:

"define command{
command_name restart-httpd
command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd $SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$
}"
This is wrong. It should be
Code:

command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
-twantrd


All times are GMT -5. The time now is 03:49 PM.