[monitoring-plugins] check_procs: ignore our own children

Sven Hartge git at monitoring-plugins.org
Sun Dec 3 20:10:26 CET 2023


 Module: monitoring-plugins
 Branch: master
 Commit: 897e4a840929285b0a29237e12f4aa9b702f41ce
 Author: Sven Hartge <sven at svenhartge.de>
   Date: Tue Nov 28 13:21:05 2023 +0100
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=897e4a8

check_procs: ignore our own children

On systems with higher core counts check_procs will occasionally see
its own "ps" child process with a high CPU percentage and raise a
false alarm.

Ignoring the child processes of check_procs prevents this from happening.

---

 plugins/check_procs.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 6e3feae..3c98866 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -255,6 +255,13 @@ main (int argc, char **argv)
 				continue;
 			}
 
+			/* Ignore our own children */
+			if (procppid == mypid) {
+				if (verbose >= 3)
+					 printf("not considering - is our child\n");
+				continue;
+			}
+
 			/* Ignore excluded processes by name */
 			if(options & EXCLUDE_PROGS) {
 			  int found = 0;



More information about the Commits mailing list