[Nagiosplug-checkins] CVS: nagiosplug/plugins check_ldap.c,1.14,1.15

Karl DeBisschop kdebisschop at users.sourceforge.net
Mon Sep 15 22:47:02 CEST 2003


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

Modified Files:
	check_ldap.c 
Log Message:
milisecond timing and perfdata, fix NULL pointer error in validate_arguments

Index: check_ldap.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ldap.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** check_ldap.c	22 Aug 2003 06:22:37 -0000	1.14
--- check_ldap.c	16 Sep 2003 05:45:55 -0000	1.15
***************
*** 30,34 ****
  
  enum {
! 	UNDEFINED = -1,
  #ifdef HAVE_LDAP_SET_OPTION
  	DEFAULT_PROTOCOL = 2,
--- 30,34 ----
  
  enum {
! 	UNDEFINED = 0,
  #ifdef HAVE_LDAP_SET_OPTION
  	DEFAULT_PROTOCOL = 2,
***************
*** 54,57 ****
--- 54,58 ----
  int warn_time = UNDEFINED;
  int crit_time = UNDEFINED;
+ struct timeval tv;
  
  int
***************
*** 62,67 ****
  	LDAPMessage *result;
  
! 	int t_diff;
! 	time_t time0, time1;
  
  	setlocale (LC_ALL, "");
--- 63,69 ----
  	LDAPMessage *result;
  
! 	int status;
! 	long microsec;
! 	double elapsed_time;
  
  	setlocale (LC_ALL, "");
***************
*** 79,83 ****
  
  	/* get the start time */
! 	time (&time0);
  
  	/* initialize ldap */
--- 81,85 ----
  
  	/* get the start time */
! 	gettimeofday (&tv, NULL);
  
  	/* initialize ldap */
***************
*** 118,141 ****
  	alarm (0);
  
- 	/* get the finish time */
- 	time (&time1);
- 
  	/* calcutate the elapsed time and compare to thresholds */
- 	t_diff = time1 - time0;
  
! 	if (crit_time!=UNDEFINED && t_diff>=crit_time) {
! 		printf (_("LDAP CRITICAL - %i seconds response time\n"), t_diff);
! 		return STATE_CRITICAL;
! 	}
  
! 	if (warn_time!=UNDEFINED && t_diff>=warn_time) {
! 		printf (_("LDAP WARNING - %i seconds response time\n"), t_diff);
! 		return STATE_WARNING;
! 	}
  
  	/* print out the result */
! 	printf (_("LDAP OK - %i seconds response time\n"), t_diff);
  
! 	return STATE_OK;
  }
  
--- 120,145 ----
  	alarm (0);
  
  	/* calcutate the elapsed time and compare to thresholds */
  
! 	microsec = deltime (tv);
! 	elapsed_time = (double)microsec / 1.0e6;
  
! 	if (crit_time!=UNDEFINED && elapsed_time>crit_time)
! 		status = STATE_CRITICAL;
! 	else if (warn_time!=UNDEFINED && elapsed_time>warn_time)
! 		status = STATE_WARNING;
! 	else
! 		status = STATE_OK;
  
  	/* print out the result */
! 	printf (_("LDAP %s - %.3f seconds response time|%s\n"),
! 	        state_text (status),
! 	        elapsed_time,
! 	        perfdata ("time", microsec, "us",
! 	                  warn_time, warn_time,
! 	                  crit_time, crit_time,
! 	                  TRUE, 0, FALSE, 0));
  
! 	return status;
  }
  
***************
*** 257,264 ****
  validate_arguments ()
  {
! 	if (strlen(ld_host) == 0)
  		usage (_("please specify the host name\n"));
  
! 	if (strlen(ld_base) == 0)
  		usage (_("please specify the LDAP base\n"));
  
--- 261,268 ----
  validate_arguments ()
  {
! 	if (ld_host==NULL || strlen(ld_host)==0)
  		usage (_("please specify the host name\n"));
  
! 	if (ld_base==NULL || strlen(ld_base)==0)
  		usage (_("please specify the LDAP base\n"));
  





More information about the Commits mailing list