monitoring-plugins/plugins
Anton Lofgren 77fc3548ae check_procs: ignore plugin parent process
This fixes an issue that appears when running check_procs over NRPE,
where the default shell is configured to (for example) dash, as is the
case on Debian.

dash (and tcsh, and mksh, and probably others), when invoked with -c forks an additional process
to execute the argument string. Contrast this with bash, which does not
do this, provided that the argument string simply can be exec()'d as-is.

To demonstrate:
$ bash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───pstree

versus
$ dash -c pstree
init─┬ ..
    ...
	├─sshd─-─sshd───dash───pstree

The consequence of this fork is that the following invocation:
    /opt/plugins/check_procs -a init

will result in this output:

    PROCS OK: 2 processes with args 'init' | processes=2;;;0;

because the check_procs, in addition to finding the actual init process,
finds its parent shell as well.

This example is a bit contrived, but I think it illustrates the
point.

This wouldn't really be a problem, and normally isn't, if it weren't
for the fact that NRPE uses a call to popen() which does exactly the
above (executes '/bin/sh -c ...'), causing inconsistent behaviour
between distributions and much confusion for end users.

The argument may be made that the dash process spawned by NRPE is just a
process like any other, and should therefore be included in the process
count just like any other. However, this is not very intuitive, because
of the previously mentioned inconsistencies.

The argument might also well be made that we're _never_ interested in the
immediate ancestor of the plugin, and while it is unknown how many
installations have already made the necessary modifications to their
setups to make up for the fact that the plugin behaves the way it does,
it is not deemed worthwhile to entertain such workarounds.

Thus, this patch ignores the parent process.

See also these bug reports:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626913
http://sourceforge.net/p/nagiosplug/bugs/512/
https://github.com/nagios-plugins/nagios-plugins/issues/999
https://bugs.op5.com/view.php?id=4398
2013-11-19 23:57:27 +01:00
..
t check_procs: ignore plugin parent process 2013-11-19 23:57:27 +01:00
tests Fix the "check_http -d" tests 2013-08-18 18:31:59 +02:00
check_apt.c Merge pull request #54 from g0hl1n/check_apt_-_run_update_upgrade_return_fix 2013-08-15 02:26:08 -07:00
check_by_ssh.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_cluster.c Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
check_dbi.c check_dbi: Hint the user about cause when dbi init fails. 2012-06-06 15:06:44 +02:00
check_dig.c plugins: rename runcmd's signal handler. 2013-05-12 14:15:13 +02:00
check_disk.c check_disk: get_fs_usage hasn't been run if using groups 2013-09-16 15:30:56 +02:00
check_dns.c plugins: rename runcmd's signal handler. 2013-05-12 14:15:13 +02:00
check_dummy.c Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
check_fping.c fping: some fping versions set loss to 0% by mistake 2013-09-13 17:14:33 +02:00
check_game.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_hpjd.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_http.c Die on SSL initialization errors 2013-09-26 17:01:28 +02:00
check_ide_smart.c Fix GCC's -Wimplicit-function-declaration warnings 2013-09-10 22:29:46 +02:00
check_ldap.c unified ipv4/6 usage and help text 2012-11-28 11:03:11 +01:00
check_load.c check_load: add alternative uptime syntax 2013-09-14 20:44:54 +02:00
check_mrtg.c Add newline after "Usage:" in --help 2010-04-22 08:57:14 -04:00
check_mrtgtraf.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_mysql.c check_mysql: Don't accept new positional arguments 2013-08-18 22:30:30 +02:00
check_mysql_query.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_nagios.c Fixed SF.net bug 3602586, added timeout option for check_nagios 2013-03-25 23:35:13 +01:00
check_nt.c check_nt: Fixes NULL pointer dereference 2013-07-08 18:52:50 +02:00
check_ntp.c check_ntp(_time): don't die on connect errors 2012-11-28 13:51:16 +01:00
check_ntp_peer.c check_ntp_peer: Verify type of response packets 2013-06-30 16:05:48 +02:00
check_ntp_time.c check_ntp(_time): don't die on connect errors 2012-11-28 13:51:16 +01:00
check_nwstat.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_overcr.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_pgsql.c check_pgsql: Don't exit UNKNOWN instead of OK 2013-09-19 12:41:42 +02:00
check_ping.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_procs.c check_procs: ignore plugin parent process 2013-11-19 23:57:27 +01:00
check_radius.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_real.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_smtp.c Fixed SF.net bug 2555775, threshold can be double for check_smtp 2013-08-06 10:55:49 +02:00
check_snmp.c check_snmp: add timeout handler befor running snmpget 2013-09-12 23:39:32 +02:00
check_ssh.c unified ipv4/6 usage and help text 2012-11-28 11:03:11 +01:00
check_swap.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_tcp.c check_tcp: use receive timeout for checks that expect response 2013-09-15 20:49:36 +02:00
check_time.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_ups.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
check_users.c check_users: Use utmpx(5) only if available 2013-08-20 21:13:25 +02:00
common.h Partially revert "check_snmp: Close potential for using uninitialized memory" 2013-08-27 18:32:38 +02:00
Makefile.am check_users: Use utmpx(5) only if available 2013-08-20 21:13:25 +02:00
negate.c Fix GCC's -Wimplicit-function-declaration warnings 2013-09-10 22:29:46 +02:00
netutils.c Move global variables from .h to .c files 2013-09-10 22:45:45 +02:00
netutils.h Move global variables from .h to .c files 2013-09-10 22:45:45 +02:00
popen.c Removing CVS/SVN tags and replacing with git-based versioning 2008-11-23 05:38:47 +00:00
popen.h Removing CVS/SVN tags and replacing with git-based versioning 2008-11-23 05:38:47 +00:00
runcmd.c plugins: rename runcmd's signal handler. 2013-05-12 14:15:13 +02:00
runcmd.h Fix GCC's -Wimplicit-function-declaration warnings 2013-09-10 22:29:46 +02:00
sslutils.c Don't mark SSL_METHOD variable as "const" 2013-09-10 22:49:03 +02:00
urlize.c Die when asprintf fails 2012-06-29 13:39:11 +02:00
utils.c Move global variables from .h to .c files 2013-09-10 22:45:45 +02:00
utils.h Move global variables from .h to .c files 2013-09-10 22:45:45 +02:00