LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-16-2011, 08:50 AM   #1
thllgo
Member
 
Registered: Sep 2003
Location: Laurel MD
Posts: 296

Rep: Reputation: 32
Nagios, checking remote services


Hello,

My question is about checking remote services under Nagios. I have installed nrpe and the standard plugins on my Nagios server (RHEL 5.4) and the systems I want to monitor. I have been able to create hostgroups. I am somewhat confused as to how to add a new service. I want to check to see if tomcat is running on the remote servers. I found a plugin check_procs. If I run the following command on one of the remotes it works.

Quote:
check_procs -u tomcat6
PROCS OK: 1 process with UID = 101 (tomcat6)
My question is how to I add this service to the Nagios server. I tried the following.

Quote:
define service{
use generic-service
hostgroup_name anaservers
service_description Tomcat
check_command check_nrpe!check_procs -u tomcat6
}
It doesn't work. I'm not sure how to format the service. I've found gobs of documentation on how to setup and install Nagios, done. I've not been so lucky on how to setup a new service.

Any help will be appreciated. Any link to a good set of documentation on this will be really appreciated.

Thanks
 
Old 05-16-2011, 09:35 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

This should be easy to follow:
http://wiki.centos.org/HowTos/Nagios...ddff62a0314b8d
Also check that you've set up access to your remote machines with NRPE correctly and that you've set the permissions to execute the scripts.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-16-2011, 09:46 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
I don't see where you modified the nrpe.cfg on the target host. Instead it appears you're simply trying to call the command line from the remote host via the check_nrpe on the Nagios master. That isn't how it works.

The link above talks about the master setup but not the nrpe.cfg. On the remote host have a look at <installdir>/etc/nrpe.cfg (usually /usr/local/nagios/etc/nrpe.cfg).

Essentially you need a line in that file that the check_nrpe on the master will read.

For example:
Code:
command[check_tomcat6]=/usr/local/nagios/libexec/check_procs -u tomcat6
Your command on the master would then be:
Code:
check_command check_nrpe!check_tomcat6
The command on master tells it to get the command you defined (check_tomcat) from the remote hosts' nrpe.

Don't forget to bounce nrpe daemon on remote host after modifying nrpe.cfg (unless you're running nrpe from xinetd.)

P.S. You don't need to do anything to nrpe.cfg on Nagios Master for this.

Last edited by MensaWater; 05-16-2011 at 02:40 PM.
 
1 members found this post helpful.
Old 05-16-2011, 11:06 AM   #4
thllgo
Member
 
Registered: Sep 2003
Location: Laurel MD
Posts: 296

Original Poster
Rep: Reputation: 32
First, EricTRA, I like the documentation at the link you provided.

Second, MensaWater, yuk, but it worked. I edited the nrpe.cfg file on one of the hosts and put the following in

Quote:
command[check_tomcat]=/usr/local/nagios/libexec/check_procs -u tomcat6
I then added the following to the services.cfg file on the nagios server

Quote:
define service{
use generic-service
hostgroup_name anaservers
service_description Tomcat
check_command check_nrpe!check_tomcat
}
Am I correct to believe this means I have to edit every nagios client for every service I want to add? I can't just make the changes on the nagios server? Ouch, yuk

But it worked, Thanks
 
1 members found this post helpful.
Old 05-16-2011, 12:06 PM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Glad it worked. If you have a lot of servers you want to monitor, you can prepare the nrpe.cfg file to include all the commands you want to use as described by MensaWater, copy that file over to your servers to the right location and restart your nrpe daemon if not configured with xinetd. That way all your nodes will be prepared to run the commands you have included and all you have to do is create the services and assign it to the hosts you define in Nagios.

Kind regards,

Eric
 
1 members found this post helpful.
Old 05-16-2011, 12:28 PM   #6
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You can run commands from Nagios master to clients without NRPE (e.g. SNMP checks, web checks etc...). However, NRPE, itself is designed to run on the client and therefore has its own configuration file. The check_nrpe command on master is designed to work on the master and interact with NRPE on the clients. Note that NRPE/check_nrpe are a plugin and not part of Nagios itself though they are clearly designed to interact with it. Personally I like being able to customize each server. However what you could do is simply create a master nrpe.cfg and roll it out to all your clients. The check_tomcat command in such a master nrpe.cfg would only be invoked when you checked it from the master for that client and not those that you don't check it for.

Of course you can write any script you want using the Nagios framework and run it from the master to the client using ssh and not even use NRPE. The main thing in such a script is to set the standard Nagios exit status values.

Code:
# Define standard Nagios return codes
#
UNKNOWN_STATE=3
CRITICAL_STATE=2
WARNING_STATE=1
OK_STATE=0
You'd then have to set your tests so that they gave the expected return codes. (That is to say if the normal exit code of the command you're calling is 1 you'd want to catch that and interpret as 2 to make it critical.)

The downside of such an approach is you'd have to make Nagios master a trusted host to ssh to the remote client as opposed to using the framkework (and even SSL) understood by Nagios and NRPE that doesn't require an actual login from the master to the client.

I have done such scripts for things that run on the master to compare things (e.g. I have scripts to determine which node of a cluster gives me an "OK" response for given cluster services so I can have Nagios note which is the active node.) Also I've written scripts to check web URLs from the master. Also of course you can write scripts that are designed to run on the client itself and put that script in nrpe.cfg to be checked by check_nrpe from the master. I have such a script for checking memory on Linux because the standard check_memory plugin doesn't deal with the special way Linux handles buffers and caching differently than most UNIX flavors do it.

P.S. By the way I called it "check_tomcat". You could call it "billybob" or anything else you want. The important thing being that the name you use in [] in nrpe.cfg is the same name you call from check_nrpe on master.

Last edited by MensaWater; 05-16-2011 at 12:30 PM.
 
1 members found this post helpful.
Old 05-16-2011, 01:55 PM   #7
thllgo
Member
 
Registered: Sep 2003
Location: Laurel MD
Posts: 296

Original Poster
Rep: Reputation: 32
I thank both of you. One hindrance I've had, is I thought NRPE was part of the Nagios core. All the quick install pages I found talk about installing it along with Nagios. I guess its' just really popular. I will take the advice you both gave and create a master nrpe.cfg file and push it out to all the clients. Since I have nrpe running under xinetd I don't have to worry about restarting the service. Simply pushing a file out to all my clients is easy or will be since my next project is a puppet server. For puppet though we have a guy here who took the classes.

Thanks for the help and good info.
 
Old 02-02-2012, 11:39 AM   #8
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 173

Rep: Reputation: 1
Quote:
Originally Posted by thllgo View Post
First, EricTRA, I like the documentation at the link you provided.

Second, MensaWater, yuk, but it worked. I edited the nrpe.cfg file on one of the hosts and put the following in



I then added the following to the services.cfg file on the nagios server



Am I correct to believe this means I have to edit every nagios client for every service I want to add? I can't just make the changes on the nagios server? Ouch, yuk

But it worked, Thanks
How to check Tomcat 7 using nagios .User runs tomcat as a root.


Please help
 
Old 02-06-2012, 10:52 AM   #9
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Krushna - Please do not append to old threads. Create a new one. A new thread will get wider exposure than old threads which may only be viewed by those who subscribed at the time.
 
  


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 reports host as down, services as OK eblonk Linux - Software 9 06-27-2013 03:41 PM
[SOLVED] Nagios: monitoring xenapp services TalkingMarble Linux - Software 4 04-03-2012 01:28 PM
[SOLVED] [nagios] send emails to gmail when services are down. Xanios Linux - Newbie 8 08-07-2010 06:38 AM
Checking which services are running morrolan Ubuntu 3 01-21-2006 05:38 PM
Checking Running Services Chijtska General 3 03-13-2002 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:59 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