LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-16-2014, 03:38 AM   #1
filius_deus
LQ Newbie
 
Registered: Feb 2010
Posts: 13

Rep: Reputation: 1
Help with Nagios and NRPE Event Handlers


Hi

I apologize if this isnt the right place to post this but I am not certain it should be under security.

That said, I would really like some assistance with setting up event handlers for Nagios, and I am unable to complete registration at their site. This seems to be the first best option!

I have a few services that I am monitoring on different systems, and some of them just need to be restarted (for instance, strongswan VPNs) and my real problem of the day is a freeIPA/redhat IdM system whose dirvsrv instance just times out for no reason, and everything stops working til I kill ns-slapd and run "ipactl restart".

I wrote a small bash script that does just exactly that (killall -9 ns-slapd and ipactl stop && ipactl start), and I since I have the IPA server being monitored by nagios ldap_check and dns_check, I wanted to make sure that the script will run when there is a time out. I use NRPE on the remote (the IPA server) to monitor.
The IPA server and the Nagios server both run 64-bit RHEL6.5 with 2GB RAM. They are guests in different KVM hypervisors.

To this end I dropped the executable bash script into the /usr/lib64/nagios/plugins/eventhandlers/ directory on the IPA server, and created a line for the command in the /etc/nagios/nrpe.cfg file like so:

command[ipactl_restart]=/usr/lib64/nagios/plugins/eventhandlers/ipactl_restart.sh

I now went to the Nagios server and created a command for this, and also copied the bash script into its own event handler directory like so:

##ipactl restart command
define command{
command_name ipactl_restart
command_line $USER1$/eventhandlers/ipactl_restart.sh $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$
}


I now created added an eventhandler line to the service definition in the appropriate file in Nagios:

define service {
use generic-service
hostgroup_name IPAServers
service_description IPA Directory Service
check_command check_nrpe!check_ipa389
max_check_attempts 3
check_interval 5
retry_interval 1
check_period 24x7
notification_interval 60
notification_period 24x7
contacts admins
event_handler check_nrpe!ipactl_restart
}


I restarted Nagios but nothing happens, it only logs outage times, but no event handling!

[1397636010] SERVICE NOTIFICATION: nagiosadmin;services.example.com;IPA Directory Service;CRITICAL;notify-service-by-email;CHECK_NRPE: Socket timeout after 20 seconds.

Please can someone guide me through what I am doing wrong? I also tried a command_line with NRPE in it but that didnt work either:

#command_line $USER1$/check_nrpe -n -H $HOSTADDRESS$ -c /usr/lib64/nagios/plugins/eventhandlers/ipactl_restart.sh -a $ARG1$

Any assistance welcome, and thanks in advance!
 
Old 06-22-2014, 05:08 AM   #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
What does manually executing '/bin/bash -vx /usr/lib64/nagios/plugins/eventhandlers/ipactl_restart.sh', with the appropriately populated "$SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTADDRESS$" variables, return?


//NTLB
 
  


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 On
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
event handlers not working in nagios nasiruddin Linux - Networking 1 02-08-2011 05:07 AM
How to shutdown VMs on ESX server through nagios event handlers angel115 Linux - Software 1 09-14-2010 07:37 AM
Installing Nagios agent nrpe, problems following nrpe install steps rfreiberger Linux - Newbie 3 04-19-2010 08:43 AM
Action/Event/Change handlers in Java Swing plk Programming 2 06-21-2007 04:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:32 AM.

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