Unable to get check_nrpe to find process on Linux server

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.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

I had posted the same issue yesterday and thought we had corrected the problem. I am attempting to add a process to monitoring on a Linux server in Nagios Xi. On the server when I run the following command I receive the expected results:

# /usr/local/nagios/libexec/check_procs -a 'Route /opt/nyfix/abim/current/config/appia FMPQA2-10011 DEBUG'
PROCS OK: 1 process with args 'Route /opt/nyfix/abim/current/config/appia FMPQA2-10011 DEBUG' | procs=1;;;0;

There is one process running, so the output is correct. When I test the same command from the Nagios console I receive the following:

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_procs -a 'Route /opt/nyfix/abim/current/config/appia FMPQA2-10011 DEBUG'
OUTPUT: PROCS OK: 0 processes with STATE = FMPQA2-10011 | procs=0;Route;/opt/nyfix/abim/current/config/appia;0;

This is happening with every process I am trying to add if it has / or - in the process descriptor. How can we correct this? To me it looks like from the console it is trying to find multiple processes instead of a single process. How can we correct this?
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by jolson »

This is a shot in the dark - but have you tried escaping the '/' characters?

/usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_procs -a "Route \/opt\/nyfix\/abim\/current\/config\/appia FMPQA2-10011 DEBUG"

Let me know if that helps - I'm glad this is almost working for you.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

Thanks for getting back to me. Unfortunately I did try that and it still does not find the process:

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a 'Route \\/opt\\/nyfix\\/abim\\/current\\/config\\/appia FMPQA2-10011 DEBUG'
OUTPUT: CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

Even if I try the following it still fails:

-a 'FMPQA2-10011 DEBUG'

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a 'FMPQA2-10011 DEBUG'
OUTPUT: Unknown argument: DEBUG

check_services -

Usage: check_services -p egrep_patern_to_find_in_procs[,...]
Usage: check_services -h (help)
Usage: check_services -V (version)


If I try the following it works:

-a 'FMPQA2-10011'

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a 'FMPQA2-10011'
OUTPUT: FMPQA2-10011: 1

There is current 1 process running that matches that criteria. It definitely looks like there is an issue with spaces in the $ARG2$.

I just tested the following and it also worked:

-a '/opt/nyfix/abim/current'

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a '/opt/nyfix/abim/current'
OUTPUT: /opt/nyfix/abim/current: 5

There are 5 processes running matching that criteria.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

I meant to add... It looks like the spaces are actually the issue. I even tried to escaping the spaces which did not work either...
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by jolson »

check_services -p egrep
Let's bust out some regex:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_procs -a 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'
Let me know if that helps.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

Unfortunately it is also not working:

-a 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_procs -a 'Route\\s/opt/nyfix/abim/current/config/appia\\sFMPQA2-10011\\sDEBUG'
OUTPUT: CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages

From the command line that also does not work:

# /usr/local/nagios/libexec/check_procs -a 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'
PROCS OK: 0 processes with args 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG' | procs=0;;;0;

It is also not a user issue. I am running the commands as the nagios user on the actual server:

[nagios@csappia21.qa ~]$ /usr/local/nagios/libexec/check_procs -a 'Route /opt/nyfix/abim/current/config/appia FMPQA2-10011 DEBUG'
PROCS OK: 1 process with args 'Route /opt/nyfix/abim/current/config/appia FMPQA2-10011 DEBUG' | procs=1;;;0;
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by jolson »

Can you please show me your remote machines nrpe.cfg?

Code: Select all

cat /usr/local/nagios/etc/nrpe.cfg
If you define a command in nrpe.cfg as follows:

Code: Select all

command[check_for_space_thing]=/usr/local/nagios/libexec/check_services -p 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'

Code: Select all

service xinetd restart
Then, from your nagios machine:

Code: Select all

./check_nrpe -H client.nrpe.machine.ip -c check_for_space_thing
This worked like a charm for me - I had forgotten that arguments cannot be passed through NRPE unless you have the "dont_blame_nrpe=" argument set to 1. Try the above method and let me know if it works.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

On the machine I am trying to monitor this is what is present in the nrpe.cfg (I removed all the items that were commented out):

log_facility=daemon

pid_file=/var/run/nrpe.pid

server_port=5666

nrpe_user=nagios

nrpe_group=nagios

allowed_hosts=127.0.0.1

dont_blame_nrpe=1

debug=0

command_timeout=60

connection_timeout=300

include_dir=/usr/local/nagios/etc/nrpe

I then added the 2 lines you suggested:

command[check_for_logstash]=/usr/local/nagios/libexec/check_procs -a logstash -w 2:2 -c 2:2
command[check_for_space_thing]=/usr/local/nagios/libexec/check_services -p 'exec\s/usr/local'

I restarted the xinetd service as requested.

I went to the Nagios server and ran the command you requested and this was the output:

# ./check_nrpe -H 10.10.205.69 -c check_for_space_thing
*** exec\s/usr/local: Nok ***

I went back into the Nagios console and all processes are still showing up with the following:

Unknown argument: /opt/nyfix/abim/current/config/appia

So the problem has not been fixed. Let me know what to check next. Thanks. Steve.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by jolson »

My apologies - I did not mean my commands exactly. I have edited my original post for clarity. Please remove the two previous entries that you had added, and add the following:

Code: Select all

command[check_for_space_thing]=/usr/local/nagios/libexec/check_services -p 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'
Then restart xinetd:

Code: Select all

service xinetd restart
Try checking once more from Nagios:

Code: Select all

./check_nrpe -H 10.10.205.69 -c check_for_space_thing
What we are trying to do here is define a command in nrpe.cfg that functions properly when run on the remote machine. The 'check_services' command above is an example, but you are free to use any command.
Then you call this command - [check_for_space_thing] - using NRPE.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
srg1970nj
Posts: 23
Joined: Wed Apr 08, 2015 12:10 pm

Re: Unable to get check_nrpe to find process on Linux server

Post by srg1970nj »

Ok. I removed the 2 lines I originally added and added the one line you indicated on the server I am trying to monitor:

command[check_for_space_thing]=/usr/local/nagios/libexec/check_services -p 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'

I then restarted the xinetd process on the server I am trying to monitor.

I then ran the command you indicated, from the Nagios server and this was the output:

# ./check_nrpe -H 10.10.205.69 -c check_for_space_thing
*** Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG: Nok ***

I then tried to run the command from the console using the Service Management view:

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a 'Route\\s/opt/nyfix/abim/current/config/appia\\sFMPQA2-10011\\sDEBUG'
OUTPUT: CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

Looking at the information you provided I was under the impression I needed to add check_for_space_thing as a command in the Nagios console. I added the command with the following:

Command Name - check_for_space_thing

Command Line - $USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$

I then updated the service to the following:

Check Command - check_for_space_thing

$ARG1$ - check_services

$ARG2$ - -a 'Route\s/opt/nyfix/abim/current/config/appia\sFMPQA2-10011\sDEBUG'

I ran the test from the console:

COMMAND: /usr/local/nagios/libexec/check_nrpe -H csappia21.qa.nyfix.net -t 30 -c check_services -a 'Route\\s/opt/nyfix/abim/current/config/appia\\sFMPQA2-10011\\sDEBUG'
OUTPUT: CHECK_NRPE: Received 0 bytes from daemon. Check the remote server logs for error messages.

The process is still not being found.
Locked