From 12536a8506afce67a19248fd51462ebf2b80fd72 Mon Sep 17 00:00:00 2001 From: Ton Voon Date: Fri, 11 Apr 2003 23:47:39 +0000 Subject: [PATCH] Match -a STRING anywhere in ps args (Laurent Vaslin - 719783) git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@488 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/check_procs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/check_procs.c b/plugins/check_procs.c index 3671559..737a87b 100644 --- a/plugins/check_procs.c +++ b/plugins/check_procs.c @@ -80,7 +80,7 @@ Optional Filters:\n\ -u, --user=USER\n\ Only scan for processes with user name or ID indicated.\n\ -a, --argument-array=STRING\n\ - Only scan for ARGS that match up to the length of the given STRING.\n\ + Only scan for processes with args that contain STRING.\n\ -C, --command=COMMAND\n\ Only scan for exact matches to the named COMMAND.\n\ \n\ @@ -206,14 +206,13 @@ main (int argc, char **argv) cols = 7; } if ( cols >= 7 ) { - found++; resultsum = 0; asprintf (&procargs, "%s", input_buffer + pos); strip (procargs); if ((options & STAT) && (strstr (statopts, procstat))) resultsum |= STAT; - if ((options & ARGS) && procargs && (strstr (procargs, args) == procargs)) + if ((options & ARGS) && procargs && (strstr (procargs, args) != NULL)) resultsum |= ARGS; if ((options & PROG) && procprog && (strcmp (prog, procprog) == 0)) resultsum |= PROG; @@ -233,6 +232,12 @@ main (int argc, char **argv) procs, procuid, procvsz, procrss, procppid, procpcpu, procstat, procprog, procargs); + /* Ignore self */ + if (strcmp (procprog, progname) == 0) + continue; + + found++; + /* Next line if filters not matched */ if (!(options == resultsum || options == ALL)) continue; -- 2.30.2