aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-22 01:33:26 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-22 01:33:26 +0000
commit61bf15c0f6a584a1503752b89cb13c44508b6922 (patch)
tree212c7bcf792e9ba9a365995b3f773f8703fd11bc
parente26253cd0216921f276143cefb4f3da58c2d66dd (diff)
downloadmonitoring-plugins-61bf15c0f6a584a1503752b89cb13c44508b6922.tar.gz
add a few comments, trap a few place where a NULL string might have been handled
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@222 f882894a-f735-0410-b71e-b25c423dba1c
-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 27cd2dae..967b4de7 100644
--- a/plugins/check_procs.c
+++ b/plugins/check_procs.c
@@ -61,7 +61,7 @@ int cmax = -1;
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
@@ -89,15 +89,13 @@ main (int argc, char **argv)
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");
@@ -127,13 +125,13 @@ main (int argc, char **argv)
) {
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;