Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm connected with root via ssh on a debian squeeze server. If I execute the command:

 /usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -a '/usr/local/freeswitch/bin/freeswitch'

I get the result:

PROCS OK: 1 process with args '/usr/local/freeswitch/bin/freeswitch'

If I execute:

sudo /usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -a '/usr/local/freeswitch/bin/freeswitch'

I get:

PROCS CRITICAL: 2 processes with args '/usr/local/freeswitch/bin/freeswitch'

Here my /etc/sudoers:

Defaults    env_reset
root    ALL=(ALL) ALL
nagios      ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/

However sudo also executes the command as root I get another result. How can that be? On an other machine with debian lenny I do not have the problem, both commands give the same result.

share|improve this question
Is the second output correct ? – adaptr Oct 25 '11 at 8:35
and what is the output when running this plugin as nagios user? – quanta Oct 25 '11 at 8:41
I got the 'PROCS CRITICAL' command when running as nagios – markus Oct 25 '11 at 9:16
up vote 3 down vote accepted

I think what you are seeing is a result of the amount of the command line being returned by the underlying 'ps' command that is used by check_procs.

In the case of the sudo blah...blah, it is possible that the entire command sudo blah....blah is displayed as one process as well as simply the one with just blah.

This is similar why when you pipeline commands such as grep, one generally has to include a command to get rid of the grep command itself.

For Example:

     ps -aef | grep -v grep | grep xinetd
share|improve this answer
OK, know I understand the problem. I opened another question to understand why the bahaviour is different on different servers: – markus Oct 25 '11 at 9:50
It's equally efficient to do something like: ps -aef | grep [x]inetd The square brackets around the x indicate 'match the character class that only has an x' so /[x]inetd/ match "xinetd" but not "[x]inetd". – Vatine Oct 25 '11 at 9:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.