[Nagiosplug-checkins] CVS: nagiosplug/plugins check_procs.c,1.8,1.9

Ton Voon tonvoon at users.sourceforge.net
Fri Jan 31 10:41:04 CET 2003


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

Modified Files:
	check_procs.c 
Log Message:
Fix for zombie processes on Solaris (Bug 677803 - Matthew Brown)


Index: check_procs.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_procs.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_procs.c	30 Jan 2003 22:55:44 -0000	1.8
--- check_procs.c	31 Jan 2003 18:40:40 -0000	1.9
***************
*** 78,81 ****
--- 78,82 ----
  char *fmt = "";
  char tmp[MAX_INPUT_BUFFER];
+ const char *zombie = "Z";
  
  int
***************
*** 94,97 ****
--- 95,99 ----
  	int procs = 0; /* counter for number of processes meeting filter criteria */
  	int pos; /* number of spaces before 'args' in `ps` output */
+ 	int cols; /* number of columns in ps output */
  
  	int result = STATE_UNKNOWN;
***************
*** 116,127 ****
  
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
- 		if (
  #ifdef USE_PS_VARS
! 				 sscanf (input_buffer, PS_FORMAT, PS_VARLIST) >= 4
  #else
! 				 sscanf (input_buffer, PS_FORMAT, procstat, &procuid, &procppid, &pos,
! 								 procprog) >= 4
  #endif
! 			) {
  			found++;
  			resultsum = 0;
--- 118,133 ----
  
  	while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
  #ifdef USE_PS_VARS
! 		cols = sscanf (input_buffer, PS_FORMAT, PS_VARLIST);
  #else
! 		cols = sscanf (input_buffer, PS_FORMAT, procstat, &procuid, 
! 							&procppid, &pos, procprog);
  #endif
! 		/* Zombie processes do not give a procprog command */
! 		if ( cols == 3 && strstr(procstat, zombie) ) {
! 			strcpy(procprog, "");
! 			cols = 4;
! 		}
! 		if ( cols >= 4 ) {
  			found++;
  			resultsum = 0;
***************
*** 148,151 ****
--- 154,161 ----
  			if (options == resultsum)
  				procs++;
+ 		} 
+ 		/* This should not happen */
+ 		else if (verbose) {
+ 			printf("Not parseable: %s", input_buffer);
  		}
  	}





More information about the Commits mailing list