summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e26253c)
raw | patch | inline | side by side (parent: e26253c)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 22 Nov 2002 01:33:26 +0000 (01:33 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 22 Nov 2002 01:33:26 +0000 (01:33 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@222 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_procs.c | patch | blob | history |
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 27cd2daee7f17b8be3330952b05896935672242b..967b4de7d00409c01c29eabb54ee04b70b694351 100644 (file)
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
int wmin = -1;
int cmin = -1;
-int options = 0;
+int options = 0; /* bitmask of filter criteria to test against */
#define ALL 1
#define STAT 2
#define PPID 4
char procprog[MAX_INPUT_BUFFER];
char *procargs;
- int resultsum = 0;
- int found = 0;
- int procs = 0;
- int pos;
+ int resultsum = 0; /* bitmask of the filter criteria met by a process */
+ int found = 0; /* counter for number of lines returned in `ps` output */
+ int procs = 0; /* counter for number of processes meeting filter criteria */
+ int pos; /* number of spaces before 'args' in `ps` output */
int result = STATE_UNKNOWN;
- procargs = malloc (MAX_INPUT_BUFFER);
-
if (process_arguments (argc, argv) == ERROR)
usage ("Unable to parse command line\n");
) {
found++;
resultsum = 0;
- procargs = strcpy (procargs, &input_buffer[pos]);
- strip (procargs);
+ asprintf (&procargs, "%s", input_buffer + pos);
+ strip (procargs);
if ((options & STAT) && (strstr (statopts, procstat)))
resultsum |= STAT;
- if ((options & ARGS) && (strstr (procargs, args) == procargs))
+ if ((options & ARGS) && procargs && (strstr (procargs, args) == procargs))
resultsum |= ARGS;
- if ((options & PROG) && (strcmp (prog, procprog) == 0))
+ if ((options & PROG) && procprog && (strcmp (prog, procprog) == 0))
resultsum |= PROG;
if ((options & PPID) && (procppid == ppid))
resultsum |= PPID;