LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2008, 05:25 PM   #1
lil_drummaboy
Member
 
Registered: May 2003
Location: Victoria, CANADA!
Distribution: OpenBSD, Slackware, Debian
Posts: 85

Rep: Reputation: 15
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
 
Old 02-27-2008, 05:47 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lil_drummaboy View Post
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."?
 
Old 02-27-2008, 07:10 PM   #3
lil_drummaboy
Member
 
Registered: May 2003
Location: Victoria, CANADA!
Distribution: OpenBSD, Slackware, Debian
Posts: 85

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by unSpawn View Post
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.
 
Old 02-29-2008, 03:03 AM   #4
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
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

Last edited by twantrd; 02-29-2008 at 03:05 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios Event Handler not running - NRPE: Unable to read output notque Linux - Software 7 04-05-2013 06:27 AM
Gtkmm / UIManager / passing info to event handler cheeseplz Programming 4 10-18-2007 11:33 PM
Looking for Joystick to Mouse Event Handler that supports Acceleration / Keyboard... fragged Linux - Software 0 08-06-2007 08:17 AM
regarding nagios issue wellspringblossom Linux - Server 1 02-21-2007 08:28 AM
TCP-IP event-handler in a Linux server Zingaro2002 Linux - Networking 4 06-06-2002 10:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration