check_procs not working with nrpe

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: check_procs not working with nrpe

Post by tmcdonald »

Yea, I wasn't thinking when I posted. You will need to escape them as single quotes:

Code: Select all

[...] -c check_procs -a '-C \'server cmr\''
Former Nagios employee
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: check_procs not working with nrpe

Post by klee »

Thanks tmcdonald, but it's coming back with a > prompt. I tried rearranging the backslashes and quotes with no success :(

Code: Select all

[root@Nagios1]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.0 -c check_procs -a '-C \'server cmr\''
>
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: check_procs not working with nrpe

Post by Box293 »

I've been having a play with this. I don't have an answer but I can point out where things are going wrong.

First of all, I've taken NRPE out of the equation by executing all tests directly on the remote host.

I copied the file "tail" to "tail test" so I could have a command running that has spaces.

Here it is running:

Code: Select all

ps -A

2424 pts/0    00:00:00 tail test
When I enable verbose mode for running check_procs I get the following output:

Code: Select all

./check_procs -C 'tail test' -vvv
CMD: /bin/ps axwo 'stat uid pid ppid vsz rss pcpu comm args'
.... lots of output blah blah blah ....
PROCS OK: 0 processes with command name 'tail test'
Here is the 'tail test' proc:

Code: Select all

S+       0  2424  2287 100944   632  0.0 tail test       ./tail testproc#=0 uid=0 vsz=100944 rss=632 pid=2424 ppid=2287 pcpu=0.00 stat=S+ etime= prog=tail args=test       ./tail test
Compare this with another proc:

Code: Select all

Ss     500  2427  2263 108340  1808  0.0 bash            bashproc#=0 uid=500 vsz=108340 rss=1808 pid=2427 ppid=2263 pcpu=0.00 stat=Ss etime= prog=bash args=bash
The difference between the two:
prog=tail args=test
prog=bash args=bash

So it has to do with check_procs executing the ps command (or the ps command itself).
It's only looking at the first word in the command and ignoring the space, so it treats the second word as an argument.

I'm unsure if this is a bug in check_procs or in ps !
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: check_procs not working with nrpe

Post by klee »

Thanks for assisting, Box293.

check_procs is an officially supported Nagios plugin... Have users have encountered this issue in the past?

I've been told by Nagios support personnel that there's no documentation for check_procs other than the help file.

But the help file does not describe how to include spaces... Is there a solution for this issue?

Thanks,

-klee
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_procs not working with nrpe

Post by abrist »

Yep. check_procs is only checking the first word of the prog name. Spenser has already acknowledged this and will will try to make it's matching/regex more robust by nagios-plugins 2.1.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: check_procs not working with nrpe

Post by klee »

Thanks Abrist,

May I ask, who is Spencer?

When is nagios-plugins 2.1 due to be released?

Is there another Nagios plugin that would allow me to do what I need?

Thanks for the update.

-Kin
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: check_procs not working with nrpe

Post by abrist »

Spen*s*er is another member of the nagios-plugins team. He contacted me earlier today about potential issue with check_procs.
No release date yet, though we are working towards a beta for 2.1 soon.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: check_procs not working with nrpe

Post by klee »

Thanks, do you know of another Nagios plugin that would allow me to do what I need?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: check_procs not working with nrpe

Post by slansing »

Are you only trying to check if a process is running or not? There are numerous alternatives here:

http://exchange.nagios.org/index.php?op ... rd=process
klee
Posts: 147
Joined: Fri Apr 04, 2014 2:31 pm

Re: check_procs not working with nrpe

Post by klee »

Thanks Slansing,

Yes, I'm currently trying the Linux Monitoring Wizard. I've set it up to watch the same services (3 of which have multiple words).
http://exchange.nagios.org/directory/Ad ... rd/details

bioserver
workserver
server timer
server msg
server cmr

But it seems to be having the same problem seeing multi-word processes, except it's using check_services instead of check_procs

server mgr Unknown argument: mgr

The service check for 'server mgr' is actually defined as the following:
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$ $ARG2$
$ARG1$ check_services
$ARG2$ -a 'server mgr'

Do you know of a way to specify it as multiple words for check_services?

FYI: I've already tried tmcdonald earlier recommendation:

Code: Select all

[...] -c check_procs -a '-C \'server cmr\''
Locked