Monitor a specific service on a Linux host

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Monitor a specific service on a Linux host

Post by neworderfac33 »

Good afternoon,

This might seem like a daft question, but I'm trying to check whether a specific service named (for example) "dave" is running on a number of Linux hosts.
I'm familiar with monitoring both services and processes on Windows hosts with check_nt and with the installation of the Nagios plugins and NRPE on Linux hosts, I'm just having difficulty in Googling whether or not either of these will do the job for me, or if I'm going to have to download something different altogether.
Thanks in anticipation of your usual excellent level of service! :-)

Pete
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor a specific service on a Linux host

Post by cdienger »

Check nrpe will be able to do this:

./check_nrpe -H $HOSTADDRESS$ -t 30 -c check_init_service -a '<service_name>'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitor a specific service on a Linux host

Post by neworderfac33 »

Good morning and thanks for your reply.
In my nrpe.cfg, I currently have:

Code: Select all

command[mycommand]=/usr/local/nagios/libexec/check_nrpe -c check_init_service -a 'myservicename'

define service{
       use                     generic-service
       #host_name               MyHost
       hostgroup_name          MyHostGroup
       service_description     Description
       check_command           check_nrpe!mycommand
       }
but this currently reports:

Code: Select all

Incorrect command line arguments supplied 
in the UI.
I also tried this:

Code: Select all

command[mycommand]=/usr/local/nagios/libexec/check_nrpe -c check_init_service $ARG1$

define service{
       use                     generic-service
       #host_name               MyHost
       hostgroup_name          MyHostGroup
       service_description     Description
       check_command           check_nrpe!mycommand!myservicename
       }
and that returns the same result.

I have also set

Code: Select all

dont_blame_nrpe=1
in nrpe.cfg on the remote host and nrpe was compiled using the --enable-command-args argument

What am I missing?

Thanks - Pete
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitor a specific service on a Linux host

Post by neworderfac33 »

I can't believe it - I finally realised that the reason why this doesn't work is because I don't have check_init_service installed on my remote host!
How do I get hold of it, please - as it doesn't come with the standard Nagios plugins?
Yours, stupidly
Pete
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Monitor a specific service on a Linux host

Post by cdienger »

How did you install the agent? The service check should be a part of the linux-npre-agent:

https://assets.nagios.com/downloads/nag ... ent.tar.gz
https://assets.nagios.com/downloads/nag ... _Agent.pdf
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitor a specific service on a Linux host

Post by neworderfac33 »

Good morning - I installed nrpe using the following steps:
cd /home/downloads
tar xvfz nrpe-2.15.tar.gz
cd nrpe-2.15
yum install openssl-devel
./configure --enable-ssl –enable-command-args
make all
make install-plugin
make install-daemon
make install-daemon-config
yum install xinetd
make install-xinetd

And I'm using Core 4.3.4, not XI. So, when I unpack it, all I seem to get is check_nrpe in my /usr/local/nagios/libexec folder - nothing that looks like check_init_service.

I've since downloaded check_service.sh which is working fine - it's just that I wanted to have the minimum number of nor-"core" plugins installed, but not to worry.

Pete
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor a specific service on a Linux host

Post by lmiltchev »

I've since downloaded check_service.sh which is working fine - it's just that I wanted to have the minimum number of nor-"core" plugins installed, but not to worry.
I am glad your issue has been resolved!

The check_init_service is actually in the tarball, that cdienger provided you with a link to...
https://assets.nagios.com/downloads/nag ... ent.tar.gz

It's in linux-nrpe-agent\subcomponents\extraplugins\plugins directory.

In addition to this, you could have used the "check_procs" plugin, which is a "native" nagios plugin. With it, you can filter processes by PPID, command, etc.

Example:

Code: Select all

# ./check_procs -C crond
PROCS OK: 8 processes with command name 'crond' | procs=8;;;0;
Let us know if you have any more questions or it is ok to lock this topic. Thank you!
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitor a specific service on a Linux host

Post by neworderfac33 »

Thanks for your reply - can I use it to check services though, as well as processes?
Have a nice weekend all and thanks for your help.
Pete
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor a specific service on a Linux host

Post by lmiltchev »

I am sure you can. In Linux, it is more difficult to differentiate between a process and a service. All services are processes in a way - there could be one or more processes, that stem from a service . A process is not necessarily a "service", i.e. your web browser or email client. The bottom line - use whatever plugin fits your needs. :)

Have a nice weekend too!
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Monitor a specific service on a Linux host

Post by neworderfac33 »

This thread can now be closed, by the way.
Thanks.
Locked