[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dig.c,1.22,1.23

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Sep 2 23:02:09 CEST 2003


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

Modified Files:
	check_dig.c 
Log Message:
allow warn/crit times to be floating point

Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** check_dig.c	26 Aug 2003 11:08:26 -0000	1.22
--- check_dig.c	3 Sep 2003 06:01:42 -0000	1.23
***************
*** 33,36 ****
--- 33,37 ----
  
  enum {
+ 	UNDEFINED = 0,
  	DEFAULT_PORT = 53
  };
***************
*** 40,45 ****
  int verbose = FALSE;
  int server_port = DEFAULT_PORT;
! int warning_interval = -1;
! int critical_interval = -1;
  struct timeval tv;
  
--- 41,46 ----
  int verbose = FALSE;
  int server_port = DEFAULT_PORT;
! double warning_interval = UNDEFINED;
! double critical_interval = UNDEFINED;
  struct timeval tv;
  
***************
*** 141,169 ****
  		asprintf (&output, _(" Probably a non-existent host/domain"));
  
! 	if (critical_interval > 0 && elapsed_time > critical_interval)
! 		printf (_("DNS OK - %.3f seconds response time (%s)"), elapsed_time, output);
  
! 	else if (result == STATE_CRITICAL)
! 		printf (_("DNS CRITICAL - %s"), output);
  
! 	else if (warning_interval > 0 && elapsed_time > warning_interval)
! 		printf (_("DNS OK - %.3f seconds response time (%s)"), elapsed_time, output);
  
! 	else if (result == STATE_WARNING)
! 		printf (_("DNS WARNING - %s"), output);
! 
! 	else if (result == STATE_OK)
! 		printf (_("DNS OK - %.3f seconds response time (%s)"),
! 						elapsed_time, output);
! 
! 	else
! 		printf (_("DNS problem - %s"), output);
! 
! 	printf ("|%s\n",
  	        perfdata("time", microsec, "us",
! 	                 (warning_interval>0?TRUE:FALSE),
! 	                 (int)1e6*warning_interval,
! 	                 (critical_interval>0?TRUE:FALSE),
! 	                 (int)1e6*critical_interval,
  									 TRUE, 0, FALSE, 0));
  	return result;
--- 142,160 ----
  		asprintf (&output, _(" Probably a non-existent host/domain"));
  
! 	if (critical_interval != UNDEFINED && elapsed_time > critical_interval)
! 		result = STATE_CRITICAL;
  
! 	else if (warning_interval != UNDEFINED && elapsed_time > warning_interval)
! 		result = STATE_WARNING;
  
! 	asprintf (&output, _("%.3f seconds response time (%s)"), elapsed_time, output);
  
! 	printf ("DNS %s - %s|%s\n",
! 	        state_text (result), output,
  	        perfdata("time", microsec, "us",
! 	                 (warning_interval!=UNDEFINED?TRUE:FALSE),
! 	                 (int)(1e6*warning_interval),
! 	                 (critical_interval!=UNDEFINED?TRUE:FALSE),
! 	                 (int)(1e6*critical_interval),
  									 TRUE, 0, FALSE, 0));
  	return result;
***************
*** 225,229 ****
  			}
  			else {
! 				usage2 (_("Server port must be a nonnegative integer\n"), optarg);
  			}
  			break;
--- 216,220 ----
  			}
  			else {
! 				usage2 (_("Server port must be a nonnegative integer"), optarg);
  			}
  			break;
***************
*** 232,248 ****
  			break;
  		case 'w':									/* warning */
! 			if (is_intnonneg (optarg)) {
! 				warning_interval = atoi (optarg);
  			}
  			else {
! 				usage2 (_("Warning interval must be a nonnegative integer\n"), optarg);
  			}
  			break;
  		case 'c':									/* critical */
! 			if (is_intnonneg (optarg)) {
! 				critical_interval = atoi (optarg);
  			}
  			else {
! 				usage2 (_("Critical interval must be a nonnegative integer\n"), optarg);
  			}
  			break;
--- 223,243 ----
  			break;
  		case 'w':									/* warning */
! 			if (is_nonnegative (optarg)) {
! 				warning_interval = strtod (optarg, NULL);
! 				if (warning_interval == HUGE_VAL)
! 					usage2 (_("Input causes overflow in warning interval"), optarg);
  			}
  			else {
! 				usage2 (_("Warning interval must be a nonnegative integer"), optarg);
  			}
  			break;
  		case 'c':									/* critical */
! 			if (is_nonnegative (optarg)) {
! 				critical_interval = strtod (optarg, NULL);
! 				if (critical_interval == HUGE_VAL)
! 					usage2 (_("Input causes overflow in critical interval"), optarg);
  			}
  			else {
! 				usage2 (_("Critical interval must be a nonnegative integer"), optarg);
  			}
  			break;
***************
*** 252,256 ****
  			}
  			else {
! 				usage2 (_("Time interval must be a nonnegative integer\n"), optarg);
  			}
  			break;
--- 247,251 ----
  			}
  			else {
! 				usage2 (_("Time interval must be a nonnegative integer"), optarg);
  			}
  			break;





More information about the Commits mailing list