summaryrefslogtreecommitdiffstats
path: root/plugins/check_procs.c
diff options
context:
space:
mode:
authorSebastian Schmidt <sschmidt@interhyp.de>2012-12-09 13:31:23 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-18 10:59:57 (GMT)
commitd5677d9b42562b429218dd9436efd5f0e79d7929 (patch)
tree5fe2fd38bcba6ca177452e046d1cf6085a274453 /plugins/check_procs.c
parent274f3ddee2431e27c5c48fcaf1aaf2ef3e40b266 (diff)
downloadmonitoring-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.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 6a30ce0..d6441f0 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -42,6 +42,7 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
42#include "regex.h" 42#include "regex.h"
43 43
44#include <pwd.h> 44#include <pwd.h>
45#include <errno.h>
45 46
46#ifdef HAVE_SYS_STAT_H 47#ifdef HAVE_SYS_STAT_H
47#include <sys/stat.h> 48#include <sys/stat.h>
@@ -157,6 +158,7 @@ main (int argc, char **argv)
157 int crit = 0; /* number of processes in crit state */ 158 int crit = 0; /* number of processes in crit state */
158 int i = 0, j = 0; 159 int i = 0, j = 0;
159 int result = STATE_UNKNOWN; 160 int result = STATE_UNKNOWN;
161 int ret;
160 output chld_out, chld_err; 162 output chld_out, chld_err;
161 163
162 setlocale (LC_ALL, ""); 164 setlocale (LC_ALL, "");
@@ -241,7 +243,8 @@ main (int argc, char **argv)
241 243
242 /* Ignore self */ 244 /* Ignore self */
243 if ((usepid && mypid == procpid) || 245 if ((usepid && mypid == procpid) ||
244 (!usepid && stat_exe(procpid, &statbuf) != -1 && statbuf.st_dev == mydev && statbuf.st_ino == myino)) { 246 (!usepid && ((ret = stat_exe(procpid, &statbuf) != -1) && statbuf.st_dev == mydev && statbuf.st_ino == myino) ||
247 (ret == -1 && errno == ENOENT))) {
245 if (verbose >= 3) 248 if (verbose >= 3)
246 printf("not considering - is myself\n"); 249 printf("not considering - is myself\n");
247 continue; 250 continue;