[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dig.c,1.18,1.19

Karl DeBisschop kdebisschop at users.sourceforge.net
Fri Aug 22 00:00:07 CEST 2003


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

Modified Files:
	check_dig.c 
Log Message:
- add perf data for time

Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** check_dig.c	22 Aug 2003 06:22:37 -0000	1.18
--- check_dig.c	22 Aug 2003 06:55:07 -0000	1.19
***************
*** 49,52 ****
--- 49,54 ----
  	char *command_line;
  	char *output;
+ 	long microsec;
+ 	double elapsed_time;
  	int result = STATE_UNKNOWN;
  
***************
*** 69,76 ****
  
  	alarm (timeout_interval);
! 	time (&start_time);
  
  	if (verbose)
  		printf ("%s\n", command_line);
  	/* run the command */
  	child_process = spopen (command_line);
--- 71,79 ----
  
  	alarm (timeout_interval);
! 	gettimeofday (&tv, NULL);
  
  	if (verbose)
  		printf ("%s\n", command_line);
+ 
  	/* run the command */
  	child_process = spopen (command_line);
***************
*** 131,148 ****
  	}
  
! 	(void) time (&end_time);
  
  	if (output == NULL || strlen (output) == 0)
  		asprintf (&output, _(" Probably a non-existent host/domain"));
  
! 	if (result == STATE_OK)
! 		printf (_("DNS OK - %d seconds response time (%s)\n"),
! 						(int) (end_time - start_time), output);
! 	else if (result == STATE_WARNING)
! 		printf (_("DNS WARNING - %s\n"), output);
  	else if (result == STATE_CRITICAL)
! 		printf (_("DNS CRITICAL - %s\n"), output);
  	else
! 		printf (_("DNS problem - %s\n"), output);
  
  	return result;
--- 134,165 ----
  	}
  
! 	microsec = deltime (tv);
! 	elapsed_time = (double)microsec / 1.0e6;
  
  	if (output == NULL || strlen (output) == 0)
  		asprintf (&output, _(" Probably a non-existent host/domain"));
  
! 	if (elapsed_time > critical_interval)
! 		die (STATE_CRITICAL,
! 		     _("DNS OK - %d seconds response time (%s)|time=%ldus\n"),
! 		     elapsed_time, output, microsec);
! 
  	else if (result == STATE_CRITICAL)
! 		printf (_("DNS CRITICAL - %s|time=%ldus\n"), output);
! 
! 	else if (elapsed_time > warning_interval)
! 		die (STATE_WARNING,
! 		     _("DNS OK - %d seconds response time (%s)|time=%ldus\n"),
! 		     elapsed_time, output, microsec);
! 
! 	else if (result == STATE_WARNING)
! 		printf (_("DNS WARNING - %s|time=%ldus\n"), output);
! 
! 	else if (result == STATE_OK)
! 		printf (_("DNS OK - %d seconds response time (%s)|time=%ldus\n"),
! 						elapsed_time, output, microsec);
! 
  	else
! 		printf (_("DNS problem - %s|time=%ldus\n"), output);
  
  	return result;





More information about the Commits mailing list