summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_procs.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/plugins/check_procs.c b/plugins/check_procs.c
index 27cd2da..967b4de 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -61,7 +61,7 @@ int cmax = -1;
61int wmin = -1; 61int wmin = -1;
62int cmin = -1; 62int cmin = -1;
63 63
64int options = 0; 64int options = 0; /* bitmask of filter criteria to test against */
65#define ALL 1 65#define ALL 1
66#define STAT 2 66#define STAT 2
67#define PPID 4 67#define PPID 4
@@ -89,15 +89,13 @@ main (int argc, char **argv)
89 char procprog[MAX_INPUT_BUFFER]; 89 char procprog[MAX_INPUT_BUFFER];
90 char *procargs; 90 char *procargs;
91 91
92 int resultsum = 0; 92 int resultsum = 0; /* bitmask of the filter criteria met by a process */
93 int found = 0; 93 int found = 0; /* counter for number of lines returned in `ps` output */
94 int procs = 0; 94 int procs = 0; /* counter for number of processes meeting filter criteria */
95 int pos; 95 int pos; /* number of spaces before 'args' in `ps` output */
96 96
97 int result = STATE_UNKNOWN; 97 int result = STATE_UNKNOWN;
98 98
99 procargs = malloc (MAX_INPUT_BUFFER);
100
101 if (process_arguments (argc, argv) == ERROR) 99 if (process_arguments (argc, argv) == ERROR)
102 usage ("Unable to parse command line\n"); 100 usage ("Unable to parse command line\n");
103 101
@@ -127,13 +125,13 @@ main (int argc, char **argv)
127 ) { 125 ) {
128 found++; 126 found++;
129 resultsum = 0; 127 resultsum = 0;
130 procargs = strcpy (procargs, &input_buffer[pos]); 128 asprintf (&procargs, "%s", input_buffer + pos);
131 strip (procargs); 129 strip (procargs);
132 if ((options & STAT) && (strstr (statopts, procstat))) 130 if ((options & STAT) && (strstr (statopts, procstat)))
133 resultsum |= STAT; 131 resultsum |= STAT;
134 if ((options & ARGS) && (strstr (procargs, args) == procargs)) 132 if ((options & ARGS) && procargs && (strstr (procargs, args) == procargs))
135 resultsum |= ARGS; 133 resultsum |= ARGS;
136 if ((options & PROG) && (strcmp (prog, procprog) == 0)) 134 if ((options & PROG) && procprog && (strcmp (prog, procprog) == 0))
137 resultsum |= PROG; 135 resultsum |= PROG;
138 if ((options & PPID) && (procppid == ppid)) 136 if ((options & PPID) && (procppid == ppid))
139 resultsum |= PPID; 137 resultsum |= PPID;