[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.52,1.53

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Sep 11 06:44:05 CEST 2003


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

Modified Files:
	check_http.c 
Log Message:
use prefdata function for size too

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -r1.52 -r1.53
*** check_http.c	11 Sep 2003 08:02:31 -0000	1.52
--- check_http.c	11 Sep 2003 11:50:45 -0000	1.53
***************
*** 121,124 ****
--- 121,125 ----
  int server_port_check(int ssl_flag);
  char *perfd_time (long microsec);
+ char *perfd_size (int page_len);
  int my_recv (void);
  int my_close (void);
***************
*** 673,680 ****
  			elapsed_time = (double)microsec / 1.0e6;
  			die (onredirect,
! 			     _(" - %s - %.3f second response time %s%s|%s size=%dB\n"),
  			     status_line, elapsed_time, timestamp,
  			     (display_html ? "</A>" : ""),
! 					 perfd_time (microsec), pagesize);
  		} /* end if (strstr (status_line, "30[0-4]") */
  
--- 674,681 ----
  			elapsed_time = (double)microsec / 1.0e6;
  			die (onredirect,
! 			     _(" - %s - %.3f second response time %s%s|%s %s\n"),
  			     status_line, elapsed_time, timestamp,
  			     (display_html ? "</A>" : ""),
! 					 perfd_time (microsec), perfd_size (pagesize));
  		} /* end if (strstr (status_line, "30[0-4]") */
  
***************
*** 687,694 ****
  	elapsed_time = (double)microsec / 1.0e6;
  	asprintf (&msg,
! 	          _("HTTP problem: %s - %.3f second response time %s%s|%s size=%dB\n"),
  	          status_line, elapsed_time, timestamp,
  	          (display_html ? "</A>" : ""),
! 						perfd_time (microsec), pagesize);
  	if (check_critical_time == TRUE && elapsed_time > critical_time)
  		die (STATE_CRITICAL, "%s", msg);
--- 688,695 ----
  	elapsed_time = (double)microsec / 1.0e6;
  	asprintf (&msg,
! 	          _("HTTP problem: %s - %.3f second response time %s%s|%s %s\n"),
  	          status_line, elapsed_time, timestamp,
  	          (display_html ? "</A>" : ""),
! 						perfd_time (microsec), perfd_size (pagesize));
  	if (check_critical_time == TRUE && elapsed_time > critical_time)
  		die (STATE_CRITICAL, "%s", msg);
***************
*** 701,714 ****
  	if (strlen (string_expect)) {
  		if (strstr (page, string_expect)) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), pagesize);
  			exit (STATE_OK);
  		}
  		else {
! 			printf (_("CRITICAL - string not found%s|%s size=%dB\n"),
  			        (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), pagesize);
  			exit (STATE_CRITICAL);
  		}
--- 702,715 ----
  	if (strlen (string_expect)) {
  		if (strstr (page, string_expect)) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), perfd_size (pagesize));
  			exit (STATE_OK);
  		}
  		else {
! 			printf (_("CRITICAL - string not found%s|%s %s\n"),
  			        (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), perfd_size (pagesize));
  			exit (STATE_CRITICAL);
  		}
***************
*** 718,732 ****
  		errcode = regexec (&preg, page, REGS, pmatch, 0);
  		if (errcode == 0) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), pagesize);
  			exit (STATE_OK);
  		}
  		else {
  			if (errcode == REG_NOMATCH) {
! 				printf (_("CRITICAL - pattern not found%s|%s size=%dB\n"),
  				        (display_html ? "</A>" : ""),
! 				        perfd_time (microsec), pagesize);
  				exit (STATE_CRITICAL);
  			}
--- 719,733 ----
  		errcode = regexec (&preg, page, REGS, pmatch, 0);
  		if (errcode == 0) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|%s %s\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""),
! 			        perfd_time (microsec), perfd_size (pagesize));
  			exit (STATE_OK);
  		}
  		else {
  			if (errcode == REG_NOMATCH) {
! 				printf (_("CRITICAL - pattern not found%s|%s %s\n"),
  				        (display_html ? "</A>" : ""),
! 				        perfd_time (microsec), perfd_size (pagesize));
  				exit (STATE_CRITICAL);
  			}
***************
*** 743,755 ****
  	page_len = strlen (page);
  	if ((min_page_len > 0) && (page_len < min_page_len)) {
! 		printf (_("HTTP WARNING: page size too small%s|size=%i\n"),
! 			(display_html ? "</A>" : ""), page_len );
  		exit (STATE_WARNING);
  	}
  	/* We only get here if all tests have been passed */
! 	asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|%s size=%dB\n"),
! 	          status_line, elapsed_time,
  	          timestamp, (display_html ? "</A>" : ""),
! 						perfd_time (microsec), pagesize);
  	die (STATE_OK, "%s", msg);
  	return STATE_UNKNOWN;
--- 744,756 ----
  	page_len = strlen (page);
  	if ((min_page_len > 0) && (page_len < min_page_len)) {
! 		printf (_("HTTP WARNING: page size %d too small%s|%s\n"),
! 			page_len, (display_html ? "</A>" : ""), perfd_size (page_len) );
  		exit (STATE_WARNING);
  	}
  	/* We only get here if all tests have been passed */
! 	asprintf (&msg, _("HTTP OK %s - %d bytes in %.3f seconds %s%s|%s %s\n"),
! 	          status_line, page_len, elapsed_time,
  	          timestamp, (display_html ? "</A>" : ""),
! 						perfd_time (microsec), perfd_size (page_len));
  	die (STATE_OK, "%s", msg);
  	return STATE_UNKNOWN;
***************
*** 1040,1048 ****
  char *perfd_time (long microsec)
  {
! 	perfdata ("time", microsec, "us",
  	          check_warning_time, (int)(1e6*warning_time),
  	          check_critical_time, (int)(1e6*critical_time),
  	          TRUE, 0, FALSE, 0);
  }
  
  int
--- 1041,1059 ----
  char *perfd_time (long microsec)
  {
! 	return perfdata ("time", microsec, "us",
  	          check_warning_time, (int)(1e6*warning_time),
  	          check_critical_time, (int)(1e6*critical_time),
  	          TRUE, 0, FALSE, 0);
  }
+ 
+ 
+ char *perfd_size (int page_len)
+ {
+ 	return perfdata ("size", page_len, "B",
+ 	          (min_page_len>0?TRUE:FALSE), min_page_len,
+ 	          (min_page_len>0?TRUE:FALSE), 0,
+ 	          TRUE, 0, FALSE, 0);
+ }
+ 
  
  int





More information about the Commits mailing list