[Nagiosplug-checkins] CVS: nagiosplug/plugins check_procs.c,1.4,1.5

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Nov 21 17:34:02 CET 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv2723/plugins

Modified Files:
	check_procs.c 
Log Message:
add a few comments, trap a few place where a NULL string might have been handled

Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** check_procs.c	8 Nov 2002 07:18:49 -0000	1.4
--- check_procs.c	22 Nov 2002 01:33:26 -0000	1.5
***************
*** 62,66 ****
  int cmin = -1;
  
! int options = 0;
  #define ALL 1
  #define STAT 2
--- 62,66 ----
  int cmin = -1;
  
! int options = 0; /* bitmask of filter criteria to test against */
  #define ALL 1
  #define STAT 2
***************
*** 90,102 ****
  	char *procargs;
  
! 	int resultsum = 0;
! 	int found = 0;
! 	int procs = 0;
! 	int pos;
  
  	int result = STATE_UNKNOWN;
  
- 	procargs = malloc (MAX_INPUT_BUFFER);
- 
  	if (process_arguments (argc, argv) == ERROR)
  		usage ("Unable to parse command line\n");
--- 90,100 ----
  	char *procargs;
  
! 	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;
  
  	if (process_arguments (argc, argv) == ERROR)
  		usage ("Unable to parse command line\n");
***************
*** 128,138 ****
  			found++;
  			resultsum = 0;
! 			procargs = strcpy (procargs, &input_buffer[pos]);
! 			strip (procargs);
  			if ((options & STAT) && (strstr (statopts, procstat)))
  				resultsum |= STAT;
! 			if ((options & ARGS) && (strstr (procargs, args) == procargs))
  				resultsum |= ARGS;
! 			if ((options & PROG) && (strcmp (prog, procprog) == 0))
  				resultsum |= PROG;
  			if ((options & PPID) && (procppid == ppid))
--- 126,136 ----
  			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))
  				resultsum |= ARGS;
! 			if ((options & PROG) && procprog && (strcmp (prog, procprog) == 0))
  				resultsum |= PROG;
  			if ((options & PPID) && (procppid == ppid))





More information about the Commits mailing list