[Nagiosplug-checkins] CVS: nagiosplug/plugins check_tcp.c,1.3,1.4

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Oct 17 20:49:06 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv31823

Modified Files:
	check_tcp.c 
Log Message:
millisecond timing

Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_tcp.c	17 Oct 2002 06:09:06 -0000	1.3
--- check_tcp.c	18 Oct 2002 03:48:53 -0000	1.4
***************
*** 84,91 ****
  int crit_codes_count = 0;
  int delay = 0;
! int warning_time = 0;
  int check_warning_time = FALSE;
! int critical_time = 0;
  int check_critical_time = FALSE;
  int verbose = FALSE;
  int use_ssl = FALSE;
--- 84,92 ----
  int crit_codes_count = 0;
  int delay = 0;
! double warning_time = 0;
  int check_warning_time = FALSE;
! double critical_time = 0;
  int check_critical_time = FALSE;
+ double elapsed_time = 0;
  int verbose = FALSE;
  int use_ssl = FALSE;
***************
*** 101,104 ****
--- 102,106 ----
  	char *output = NULL;
  	char *ptr = NULL;
+ 	struct timeval tv;
  
  	if (strstr (argv[0], "check_udp")) {
***************
*** 206,210 ****
  
  	/* try to connect to the host at the given port number */
! 	time (&start_time);
  #ifdef HAVE_SSL
  	if (use_ssl)
--- 208,212 ----
  
  	/* try to connect to the host at the given port number */
! 	gettimeofday (&tv, NULL);
  #ifdef HAVE_SSL
  	if (use_ssl)
***************
*** 234,238 ****
  
  	if (delay > 0) {
! 		start_time = start_time + delay;
  		sleep (delay);
  	}
--- 236,240 ----
  
  	if (delay > 0) {
! 		tv.tv_sec += delay;
  		sleep (delay);
  	}
***************
*** 288,297 ****
  	close (sd);
  
! 	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;
  
  	/* reset the alarm */
--- 290,299 ----
  	close (sd);
  
! 	elapsed_time = delta_time (tv);
  
! 	if (check_critical_time == TRUE && elapsed_time > critical_time)
  		result = STATE_CRITICAL;
! 	else if (check_warning_time == TRUE && elapsed_time > warning_time)
! 		result = STATE_WARNING;
  
  	/* reset the alarm */
***************
*** 299,310 ****
  
  	printf
! 		("%s %s - %d second response time on port %d",
  		 SERVICE,
! 		 state_text (result), (int) (end_time - start_time), server_port);
  
  	if (status)
  		printf (" [%s]", status);
  
! 	printf ("|time=%d\n", (int) (end_time - start_time));
  
  	return result;
--- 301,312 ----
  
  	printf
! 		("%s %s - %7.3f second response time on port %d",
  		 SERVICE,
! 		 state_text (result), elapsed_time, server_port);
  
  	if (status)
  		printf (" [%s]", status);
  
! 	printf ("|time=%7.3f\n", elapsed_time);
  
  	return result;
***************
*** 399,403 ****
  			if (!is_intnonneg (optarg))
  				usage ("Critical threshold must be a nonnegative integer\n");
! 			critical_time = atoi (optarg);
  			check_critical_time = TRUE;
  			break;
--- 401,405 ----
  			if (!is_intnonneg (optarg))
  				usage ("Critical threshold must be a nonnegative integer\n");
! 			critical_time = strtod (optarg, NULL);
  			check_critical_time = TRUE;
  			break;
***************
*** 405,409 ****
  			if (!is_intnonneg (optarg))
  				usage ("Warning threshold must be a nonnegative integer\n");
! 			warning_time = atoi (optarg);
  			check_warning_time = TRUE;
  			break;
--- 407,411 ----
  			if (!is_intnonneg (optarg))
  				usage ("Warning threshold must be a nonnegative integer\n");
! 			warning_time = strtod (optarg, NULL);
  			check_warning_time = TRUE;
  			break;
***************
*** 500,506 ****
  		 " -W, --wait=INTEGER\n"
  		 "    Seconds to wait between sending string and polling for response\n"
! 		 " -w, --warning=INTEGER\n"
  		 "    Response time to result in warning status (seconds)\n"
! 		 " -c, --critical=INTEGER\n"
  		 "    Response time to result in critical status (seconds)\n"
  		 " -t, --timeout=INTEGER\n"
--- 502,508 ----
  		 " -W, --wait=INTEGER\n"
  		 "    Seconds to wait between sending string and polling for response\n"
! 		 " -w, --warning=DOUBLE\n"
  		 "    Response time to result in warning status (seconds)\n"
! 		 " -c, --critical=DOUBLE\n"
  		 "    Response time to result in critical status (seconds)\n"
  		 " -t, --timeout=INTEGER\n"





More information about the Commits mailing list