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

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Mar 6 23:46:11 CET 2003


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

Modified Files:
	check_smtp.c 
Log Message:
millisecond timing and perf data

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_smtp.c	7 Mar 2003 07:17:26 -0000	1.10
--- check_smtp.c	7 Mar 2003 07:45:45 -0000	1.11
***************
*** 74,78 ****
  int critical_time = 0;
  int check_critical_time = FALSE;
! int verbose = FALSE;
  
  int
--- 74,78 ----
  int critical_time = 0;
  int check_critical_time = FALSE;
! int verbose = 0;
  
  int
***************
*** 80,87 ****
--- 80,89 ----
  {
  	int sd;
+ 	double elapsed_time;
  	int result = STATE_UNKNOWN;
  	char buffer[MAX_INPUT_BUFFER] = "";
  	char *from_str = NULL;
  	char *helocmd = NULL;
+ 	struct timeval tv;
  
  	if (process_arguments (argc, argv) != OK)
***************
*** 99,113 ****
  	asprintf (&from_str, "%sFROM: %s%s", SMTP_DUMMYCMD, from_arg, "\r\n");
  
! 	if (verbose == TRUE)
  		printf ("FROMCMD: %s\n", from_str);
  	
  	/* initialize alarm signal handling */
! 	signal (SIGALRM, socket_timeout_alarm_handler);
  
  	/* set socket timeout */
! 	alarm (socket_timeout);
  
  	/* try to connect to the host at the given port number */
- 	time (&start_time);
  	result = my_tcp_connect (server_address, server_port, &sd);
  
--- 101,117 ----
  	asprintf (&from_str, "%sFROM: %s%s", SMTP_DUMMYCMD, from_arg, "\r\n");
  
! 	if (verbose)
  		printf ("FROMCMD: %s\n", from_str);
  	
  	/* initialize alarm signal handling */
! 	(void) signal (SIGALRM, socket_timeout_alarm_handler);
  
  	/* set socket timeout */
! 	(void) alarm (socket_timeout);
! 
! 	/* start timer */
! 	gettimeofday (&tv, NULL);
  
  	/* try to connect to the host at the given port number */
  	result = my_tcp_connect (server_address, server_port, &sd);
  
***************
*** 147,151 ****
  		recv(sd, buffer, MAX_INPUT_BUFFER-1, 0);
  
! 		if (verbose == TRUE) 
  			printf("DUMMYCMD: %s\n%s\n",from_str,buffer);
  #endif /* SMTP_USE_DUMMYCMD */
--- 151,155 ----
  		recv(sd, buffer, MAX_INPUT_BUFFER-1, 0);
  
! 		if (verbose) 
  			printf("DUMMYCMD: %s\n%s\n",from_str,buffer);
  #endif /* SMTP_USE_DUMMYCMD */
***************
*** 161,176 ****
  	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;
--- 165,181 ----
  	alarm (0);
  
! 	elapsed_time = delta_time (tv);
  
! 	if (check_critical_time && elapsed_time > (double) critical_time)
  		result = STATE_CRITICAL;
! 	else if (check_warning_time && elapsed_time > (double) warning_time)
  		result = STATE_WARNING;
  
! 	if (verbose)
! 		printf ("SMTP %s - %7.3f sec. response time, %s|time=%7.3f\n",
! 		        state_text (result), elapsed_time, buffer, elapsed_time);
  	else
! 		printf ("SMTP %s - %7.3f second response time|time=%7.3f\n",
! 		        state_text (result), elapsed_time, elapsed_time);
  
  	return result;
***************
*** 269,273 ****
  			break;
  		case 'v':									/* verbose */
! 			verbose = TRUE;
  			break;
  		case 't':									/* timeout */
--- 274,278 ----
  			break;
  		case 'v':									/* verbose */
! 			verbose++;
  			break;
  		case 't':									/* timeout */





More information about the Commits mailing list