[Nagiosplug-checkins] CVS: nagiosplug/plugins check_smtp.c,1.9,1.10

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Mar 6 23:18:05 CET 2003


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

Modified Files:
	check_smtp.c 
Log Message:
whole timer loop was on the wrong side of connection close code

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_smtp.c	13 Jan 2003 12:15:16 -0000	1.9
--- check_smtp.c	7 Mar 2003 07:17:26 -0000	1.10
***************
*** 80,84 ****
  {
  	int sd;
! 	int result;
  	char buffer[MAX_INPUT_BUFFER] = "";
  	char *from_str = NULL;
--- 80,84 ----
  {
  	int sd;
! 	int result = STATE_UNKNOWN;
  	char buffer[MAX_INPUT_BUFFER] = "";
  	char *from_str = NULL;
***************
*** 115,132 ****
  	if (result == STATE_OK) {
  
! 		/* watch for the SMTP connection string */
! 		result = recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0);
! 
! 		/* strip the buffer of carriage returns */
! 		strip (buffer);
! 
  		/* return a WARNING status if we couldn't read any data */
! 		if (result == -1) {
  			printf ("recv() failed\n");
  			result = STATE_WARNING;
  		}
- 
  		else {
! 
  			/* make sure we find the response we are looking for */
  			if (!strstr (buffer, server_expect)) {
--- 115,127 ----
  	if (result == STATE_OK) {
  
! 		/* watch for the SMTP connection string and */
  		/* return a WARNING status if we couldn't read any data */
! 		if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) {
  			printf ("recv() failed\n");
  			result = STATE_WARNING;
  		}
  		else {
! 			/* strip the buffer of carriage returns */
! 			strip (buffer);
  			/* make sure we find the response we are looking for */
  			if (!strstr (buffer, server_expect)) {
***************
*** 138,167 ****
  				result = STATE_WARNING;
  			}
- 
- 			else {
- 
- 				time (&end_time);
- 
- 				result = STATE_OK;
- 
- 				if (check_critical_time == TRUE
- 						&& (end_time - start_time) > critical_time) result =
- 						STATE_CRITICAL;
- 				else if (check_warning_time == TRUE
- 								 && (end_time - start_time) > warning_time) result =
- 						STATE_WARNING;
- 
- 				if (verbose == TRUE)
- 					printf ("SMTP %s - %d sec. response time, %s\n",
- 									state_text (result), (int) (end_time - start_time), buffer);
- 				else
- 					printf ("SMTP %s - %d second response time\n", state_text (result),
- 									(int) (end_time - start_time));
- 			}
  		}
  
! 		/* close the connection */
! 
! 		/* first send the HELO command */
  		send(sd, helocmd, strlen(helocmd), 0);
  
--- 133,139 ----
  				result = STATE_WARNING;
  			}
  		}
  
! 		/* send the HELO command */
  		send(sd, helocmd, strlen(helocmd), 0);
  
***************
*** 188,191 ****
--- 160,176 ----
  	/* reset the alarm */
  	alarm (0);
+ 
+ 	time (&end_time);
+ 
+ 	if (check_critical_time == TRUE && (end_time - start_time) > critical_time)
+ 		result = STATE_CRITICAL;
+ 	else if (check_warning_time == TRUE && (end_time - start_time) > warning_time)
+ 		result = STATE_WARNING;
+ 
+ 	if (verbose == TRUE)
+ 		printf ("SMTP %s - %d sec. response time, %s\n",
+ 						state_text (result), (int) (end_time - start_time), buffer);
+ 	else
+ 		printf ("SMTP %s - %d second response time\n", state_text (result), (int) (end_time - start_time));
  
  	return result;





More information about the Commits mailing list