Browse Source

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
Ton Voon 23 years ago
parent
commit
12536a8506
1 changed files with 8 additions and 3 deletions
  1. 8 3
      plugins/check_procs.c

+ 8 - 3
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;