diff options
author | Sebastian Schmidt <sschmidt@interhyp.de> | 2012-12-09 14:31:23 +0100 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-08-18 12:59:57 +0200 |
commit | d5677d9b42562b429218dd9436efd5f0e79d7929 (patch) | |
tree | 5fe2fd38bcba6ca177452e046d1cf6085a274453 /plugins/check_procs.c | |
parent | 274f3ddee2431e27c5c48fcaf1aaf2ef3e40b266 (diff) | |
download | monitoring-plugins-d5677d9b42562b429218dd9436efd5f0e79d7929.tar.gz |
check_procs: Ignore ENOENT when checking for myself
Previously, when a process exited between the call to /bin/ps and
stat("/proc/his/exe") was exiting it was not considered as possible
instance of check_procs. This commit makes check_procs ignore all
processes where /proc/pid/exe does not exist.
Diffstat (limited to 'plugins/check_procs.c')
-rw-r--r-- | plugins/check_procs.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 6a30ce00..d6441f0a 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -42,6 +42,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include "regex.h" #include <pwd.h> +#include <errno.h> #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> @@ -157,6 +158,7 @@ main (int argc, char **argv) int crit = 0; /* number of processes in crit state */ int i = 0, j = 0; int result = STATE_UNKNOWN; + int ret; output chld_out, chld_err; setlocale (LC_ALL, ""); @@ -241,7 +243,8 @@ main (int argc, char **argv) /* Ignore self */ if ((usepid && mypid == procpid) || - (!usepid && stat_exe(procpid, &statbuf) != -1 && statbuf.st_dev == mydev && statbuf.st_ino == myino)) { + (!usepid && ((ret = stat_exe(procpid, &statbuf) != -1) && statbuf.st_dev == mydev && statbuf.st_ino == myino) || + (ret == -1 && errno == ENOENT))) { if (verbose >= 3) printf("not considering - is myself\n"); continue; |