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

Karl DeBisschop kdebisschop at users.sourceforge.net
Thu Sep 11 01:10:21 CEST 2003


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

Modified Files:
	check_http.c 
Log Message:
use prefdata function

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -r1.51 -r1.52
*** check_http.c	23 Aug 2003 15:07:33 -0000	1.51
--- check_http.c	11 Sep 2003 08:02:31 -0000	1.52
***************
*** 16,19 ****
--- 16,20 ----
  
  ******************************************************************************/
+ /* splint -I. -I../../plugins -I../../lib/ -I/usr/kerberos/include/ ../../plugins/check_http.c */
  
  const char *progname = "check_http";
***************
*** 116,122 ****
  static char *base64 (const char *bin, size_t len);
  int check_http (void);
! int redir (char *pos, char *status_line);
  int server_type_check(const char *type);
  int server_port_check(int ssl_flag);
  int my_recv (void);
  int my_close (void);
--- 117,124 ----
  static char *base64 (const char *bin, size_t len);
  int check_http (void);
! void redir (char *pos, char *status_line);
  int server_type_check(const char *type);
  int server_port_check(int ssl_flag);
+ char *perfd_time (long microsec);
  int my_recv (void);
  int my_close (void);
***************
*** 670,677 ****
  			microsec = deltime (tv);
  			elapsed_time = (double)microsec / 1.0e6;
! 			asprintf (&msg, _(" - %s - %.3f second response time %s%s|time=%ldus size=%dB\n"),
! 		                 status_line, elapsed_time, timestamp,
! 	                   (display_html ? "</A>" : ""), microsec, pagesize);
! 			die (onredirect, "%s", msg);
  		} /* end if (strstr (status_line, "30[0-4]") */
  
--- 672,680 ----
  			microsec = deltime (tv);
  			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]") */
  
***************
*** 683,689 ****
  	microsec = deltime (tv);
  	elapsed_time = (double)microsec / 1.0e6;
! 	asprintf (&msg, _("HTTP problem: %s - %.3f second response time %s%s|time=%ldus size=%dB\n"),
! 	               status_line, elapsed_time, timestamp,
! 	               (display_html ? "</A>" : ""), microsec, pagesize);
  	if (check_critical_time == TRUE && elapsed_time > critical_time)
  		die (STATE_CRITICAL, "%s", msg);
--- 686,694 ----
  	microsec = deltime (tv);
  	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);
***************
*** 696,707 ****
  	if (strlen (string_expect)) {
  		if (strstr (page, string_expect)) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"),
  			        status_line, elapsed_time,
! 			        timestamp, (display_html ? "</A>" : ""), microsec, pagesize);
  			exit (STATE_OK);
  		}
  		else {
! 			printf (_("CRITICAL - string not found%s|time=%ldus\n size=%dB"),
! 			        (display_html ? "</A>" : ""), microsec, pagesize);
  			exit (STATE_CRITICAL);
  		}
--- 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);
  		}
***************
*** 711,723 ****
  		errcode = regexec (&preg, page, REGS, pmatch, 0);
  		if (errcode == 0) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"),
  			        status_line, elapsed_time,
! 			        timestamp, (display_html ? "</A>" : ""), microsec, pagesize);
  			exit (STATE_OK);
  		}
  		else {
  			if (errcode == REG_NOMATCH) {
! 				printf (_("CRITICAL - pattern not found%s|time=%ldus size=%dB\n"),
! 				        (display_html ? "</A>" : ""), microsec, 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);
  			}
***************
*** 739,745 ****
  	}
  	/* We only get here if all tests have been passed */
! 	asprintf (&msg, _("HTTP OK %s - %.3f second response time %s%s|time=%ldus size=%dB\n"),
! 	                status_line, elapsed_time,
! 	                timestamp, (display_html ? "</A>" : ""), microsec, pagesize);
  	die (STATE_OK, "%s", msg);
  	return STATE_UNKNOWN;
--- 748,755 ----
  	}
  	/* 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;
***************
*** 761,765 ****
  #define HD5 URI_PATH
  
! int
  redir (char *pos, char *status_line)
  {
--- 771,775 ----
  #define HD5 URI_PATH
  
! void
  redir (char *pos, char *status_line)
  {
***************
*** 874,878 ****
  	server_url = strdup (url);
  
! 	return check_http ();
  }
  
--- 884,888 ----
  	server_url = strdup (url);
  
! 	check_http ();
  }
  
***************
*** 1027,1030 ****
--- 1037,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





More information about the Commits mailing list