[Nagiosplug-checkins] CVS: nagiosplug/plugins check_http.c,1.37,1.38

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat Aug 2 17:02:01 CEST 2003


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

Modified Files:
	check_http.c 
Log Message:
markup for translation

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -r1.37 -r1.38
*** check_http.c	29 Jul 2003 03:05:50 -0000	1.37
--- check_http.c	3 Aug 2003 00:01:22 -0000	1.38
***************
*** 25,105 ****
  
  const char *progname = "check_http";
! #define REVISION "$Revision$"
! #define COPYRIGHT "1999-2001"
! #define AUTHORS "Ethan Galstad/Karl DeBisschop"
! #define EMAIL "kdebisschop at users.sourceforge.net"
  
- #include "config.h"
  #include "common.h"
  #include "netutils.h"
  #include "utils.h"
  
! #define SUMMARY "\
  This plugin tests the HTTP service on the specified host. It can test\n\
  normal (http) and secure (https) servers, follow redirects, search for\n\
  strings and regular expressions, check connection times, and report on\n\
! certificate expiration times.\n"
  
! #define OPTIONS "\
! (-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
!             [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
!             [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
!             [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
!             [-P string] [-m min_pg_size] [-4|-6]"
  
! #define LONGOPTIONS "\
   -H, --hostname=ADDRESS\n\
      Host name argument for servers using host headers (virtual host)\n\
   -I, --IP-address=ADDRESS\n\
     IP address or name (use numeric address if possible to bypass DNS lookup).\n\
-  -4, --use-ipv4\n\
-    Use IPv4 protocol\n\
-  -6, --use-ipv6\n\
-    Use IPv6 protocol\n\
-  -e, --expect=STRING\n\
-    String to expect in first (status) line of server response (default: %s)\n\
-    If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\
-  -s, --string=STRING\n\
-    String to expect in the content\n\
-  -u, --url=PATH\n\
-    URL to GET or POST (default: /)\n\
   -p, --port=INTEGER\n\
!    Port number (default: %d)\n\
!  -P, --post=STRING\n\
!    URL encoded http POST data\n\
!  -w, --warning=INTEGER\n\
!    Response time to result in warning status (seconds)\n\
!  -c, --critical=INTEGER\n\
!    Response time to result in critical status (seconds)\n\
!  -t, --timeout=INTEGER\n\
!    Seconds before connection times out (default: %d)\n\
!  -a, --authorization=AUTH_PAIR\n\
!    Username:password on sites with basic authentication\n\
!  -L, --link=URL\n\
!    Wrap output in HTML link (obsoleted by urlize)\n\
!  -f, --onredirect=<ok|warning|critical|follow>\n\
!    How to handle redirected pages\n%s%s\
! -m, --min=INTEGER\n\
!    Minimum page size required (bytes)\n\
!  -v, --verbose\n\
!     Show details for command-line debugging (do not use with nagios server)\n\
!  -h, --help\n\
!     Print detailed help screen\n\
!  -V, --version\n\
!     Print version information\n"
  
  #ifdef HAVE_SSL
! #define SSLOPTIONS "\
   -S, --ssl\n\
      Connect via SSL\n\
   -C, --certificate=INTEGER\n\
      Minimum number of days a certificate has to be valid.\n\
!     (when this option is used the url is not checked.)\n"
! #else
! #define SSLOPTIONS ""
  #endif
  
  #ifdef HAVE_REGEX_H
! #define REGOPTIONS "\
   -l, --linespan\n\
      Allow regex to span newlines (must precede -r or -R)\n\
--- 25,106 ----
  
  const char *progname = "check_http";
! const char *revision = "$Revision$";
! const char *copyright = "1999-2001";
! const char *email = "nagiosplug-devel at lists.sourceforge.net";
  
  #include "common.h"
  #include "netutils.h"
  #include "utils.h"
  
! #define HTTP_EXPECT "HTTP/1."
! enum {
! 	MAX_IPV4_HOSTLENGTH = 255,
! 	HTTP_PORT = 80,
! 	HTTPS_PORT = 443
! };
! 
! void
! print_usage (void)
! {
! 	printf (_("\
! Usage: %s (-H <vhost> | -I <IP-address>) [-u <uri>] [-p <port>]\n\
!   [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]\n\
!   [-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]\n\
!   [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n\
!   [-P string] [-m min_pg_size] [-4|-6]\n"), progname);
! 	printf (_(UT_HLP_VRS), progname, progname);
! }
! 
! void
! print_help (void)
! {
! 	print_revision (progname, revision);
! 
! 	printf (_(COPYRIGHT), copyright, email);
! 
! 	printf (_("\
  This plugin tests the HTTP service on the specified host. It can test\n\
  normal (http) and secure (https) servers, follow redirects, search for\n\
  strings and regular expressions, check connection times, and report on\n\
! certificate expiration times.\n"));
! 
! 	print_usage ();
  
! 	printf (_("NOTE: One or both of -H and -I must be specified\n"));
  
! 	printf (_(UT_HELP_VRSN));
! 
! 	printf (_("\
   -H, --hostname=ADDRESS\n\
      Host name argument for servers using host headers (virtual host)\n\
   -I, --IP-address=ADDRESS\n\
     IP address or name (use numeric address if possible to bypass DNS lookup).\n\
   -p, --port=INTEGER\n\
!    Port number (default: %d)\n"), HTTP_PORT);
! 
! 	printf (_(UT_IPv46));
  
  #ifdef HAVE_SSL
! 	printf (_("\
   -S, --ssl\n\
      Connect via SSL\n\
   -C, --certificate=INTEGER\n\
      Minimum number of days a certificate has to be valid.\n\
!     (when this option is used the url is not checked.)\n"));
  #endif
  
+ 	printf (_("\
+  -e, --expect=STRING\n\
+    String to expect in first (status) line of server response (default: %s)\n\
+    If specified skips all other status line logic (ex: 3xx, 4xx, 5xx processing)\n\
+  -s, --string=STRING\n\
+    String to expect in the content\n\
+  -u, --url=PATH\n\
+    URL to GET or POST (default: /)\n\
+  -P, --post=STRING\n\
+    URL encoded http POST data\n"), HTTP_EXPECT);
+ 
  #ifdef HAVE_REGEX_H
! 	printf (_("\
   -l, --linespan\n\
      Allow regex to span newlines (must precede -r or -R)\n\
***************
*** 107,137 ****
      Search page for regex STRING\n\
   -R, --eregi=STRING\n\
!     Search page for case-insensitive regex STRING\n"
! #else
! #define REGOPTIONS ""
  #endif
  
! #define DESCRIPTION "\
! This plugin will attempt to open an HTTP connection with the host. Successul\n\
  connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\
  errors return STATE_UNKNOWN.  Successful connects, but incorrect reponse\n\
  messages from the host result in STATE_WARNING return values.  If you are\n\
! checking a virtual server that uses \"host headers\" you must supply the FQDN\n\
! \(fully qualified domain name) as the [host_name] argument.\n"
  
! #define SSLDESCRIPTION "\
  This plugin can also check whether an SSL enabled web server is able to\n\
  serve content (optionally within a specified time) or whether the X509 \n\
! certificate is still valid for the specified number of days.\n\n\
  CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com\n\n\
  When the 'www.verisign.com' server returns its content within 5 seconds, a\n\
  STATE_OK will be returned. When the server returns its content but exceeds\n\
  the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,\n\
! a STATE_CRITICAL will be returned.\n\n\
  CHECK CERTIFICATE: check_http www.verisign.com -C 14\n\n\
  When the certificate of 'www.verisign.com' is valid for more than 14 days, a\n\
  STATE_OK is returned. When the certificate is still valid, but for less than\n\
  14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when\n\
! the certificate is expired.\n"
  
  #ifdef HAVE_SSL_H
--- 108,161 ----
      Search page for regex STRING\n\
   -R, --eregi=STRING\n\
!     Search page for case-insensitive regex STRING\n"));
  #endif
  
! 	printf (_("\
!  -a, --authorization=AUTH_PAIR\n\
!    Username:password on sites with basic authentication\n\
!  -L, --link=URL\n\
!    Wrap output in HTML link (obsoleted by urlize)\n\
!  -f, --onredirect=<ok|warning|critical|follow>\n\
!    How to handle redirected pages\n\
!  -m, --min=INTEGER\n\
!    Minimum page size required (bytes)\n"));
! 
! 	printf (_(UT_WARN_CRIT));
! 
! 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
! 
! 	printf (_(UT_VERBOSE));
! 
! 					printf (_("\
! This plugin will attempt to open an HTTP connection with the host. Successful\n\
  connects return STATE_OK, refusals and timeouts return STATE_CRITICAL, other\n\
  errors return STATE_UNKNOWN.  Successful connects, but incorrect reponse\n\
  messages from the host result in STATE_WARNING return values.  If you are\n\
! checking a virtual server that uses 'host headers' you must supply the FQDN\n\
! (fully qualified domain name) as the [host_name] argument.\n"));
  
! #ifdef HAVE_SSL
! 	printf (_("\n\
  This plugin can also check whether an SSL enabled web server is able to\n\
  serve content (optionally within a specified time) or whether the X509 \n\
! certificate is still valid for the specified number of days.\n"));
! 	printf (_("\n\
  CHECK CONTENT: check_http -w 5 -c 10 --ssl www.verisign.com\n\n\
  When the 'www.verisign.com' server returns its content within 5 seconds, a\n\
  STATE_OK will be returned. When the server returns its content but exceeds\n\
  the 5-second threshold, a STATE_WARNING will be returned. When an error occurs,\n\
! a STATE_CRITICAL will be returned.\n\n"));
! 
! 	printf (_("\
  CHECK CERTIFICATE: check_http www.verisign.com -C 14\n\n\
  When the certificate of 'www.verisign.com' is valid for more than 14 days, a\n\
  STATE_OK is returned. When the certificate is still valid, but for less than\n\
  14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when\n\
! the certificate is expired.\n"));
! #endif
! 
! 	printf (_(UT_SUPPORT));
! 
! }
  
  #ifdef HAVE_SSL_H
***************
*** 195,205 ****
  #define URI_PATH "%[-_.!~*'();/?:@&=+$,%#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"
  
- enum {
- 	MAX_IPV4_HOSTLENGTH = 255,
- 	HTTP_PORT = 80,
- 	HTTPS_PORT = 443
- };
- 
- #define HTTP_EXPECT "HTTP/1."
  #define HTTP_URL "/"
  #define CRLF "\r\n"
--- 219,222 ----
***************
*** 232,237 ****
  char buffer[MAX_INPUT_BUFFER];
  
- void print_usage (void);
- void print_help (void);
  int process_arguments (int, char **);
  static char *base64 (char *bin, int len);
--- 249,252 ----
***************
*** 250,254 ****
  
  	if (process_arguments (argc, argv) == ERROR)
! 		usage ("check_http: could not parse arguments\n");
  
  	if (strstr (timestamp, ":")) {
--- 265,269 ----
  
  	if (process_arguments (argc, argv) == ERROR)
! 		usage (_("check_http: could not parse arguments\n"));
  
  	if (strstr (timestamp, ":")) {
***************
*** 272,276 ****
  		if (connect_SSL () != OK)
  			terminate (STATE_CRITICAL,
! 			           "HTTP CRITICAL - Could not make SSL connection\n");
  		if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
  			result = check_certificate (&server_cert);
--- 287,291 ----
  		if (connect_SSL () != OK)
  			terminate (STATE_CRITICAL,
! 			           _("HTTP CRITICAL - Could not make SSL connection\n"));
  		if ((server_cert = SSL_get_peer_certificate (ssl)) != NULL) {
  			result = check_certificate (&server_cert);
***************
*** 278,282 ****
  		}
  		else {
! 			printf ("ERROR: Cannot retrieve server certificate.\n");
  			result = STATE_CRITICAL;
  		}
--- 293,297 ----
  		}
  		else {
! 			printf (_("ERROR: Cannot retrieve server certificate.\n"));
  			result = STATE_CRITICAL;
  		}
***************
*** 349,353 ****
  		switch (c) {
  		case '?': /* usage */
! 			usage3 ("unknown argument", optopt);
  			break;
  		case 'h': /* help */
--- 364,368 ----
  		switch (c) {
  		case '?': /* usage */
! 			usage3 (_("unknown argument"), optopt);
  			break;
  		case 'h': /* help */
***************
*** 356,370 ****
  			break;
  		case 'V': /* version */
! 			print_revision (progname, REVISION);
  			exit (STATE_OK);
  			break;
  		case 't': /* timeout period */
  			if (!is_intnonneg (optarg))
! 				usage2 ("timeout interval must be a non-negative integer", optarg);
  			socket_timeout = atoi (optarg);
  			break;
  		case 'c': /* critical time threshold */
  			if (!is_intnonneg (optarg))
! 				usage2 ("invalid critical threshold", optarg);
  			critical_time = strtod (optarg, NULL);
  			check_critical_time = TRUE;
--- 371,385 ----
  			break;
  		case 'V': /* version */
! 			print_revision (progname, revision);
  			exit (STATE_OK);
  			break;
  		case 't': /* timeout period */
  			if (!is_intnonneg (optarg))
! 				usage2 (_("timeout interval must be a non-negative integer"), optarg);
  			socket_timeout = atoi (optarg);
  			break;
  		case 'c': /* critical time threshold */
  			if (!is_intnonneg (optarg))
! 				usage2 (_("invalid critical threshold"), optarg);
  			critical_time = strtod (optarg, NULL);
  			check_critical_time = TRUE;
***************
*** 372,376 ****
  		case 'w': /* warning time threshold */
  			if (!is_intnonneg (optarg))
! 				usage2 ("invalid warning threshold", optarg);
  			warning_time = strtod (optarg, NULL);
  			check_warning_time = TRUE;
--- 387,391 ----
  		case 'w': /* warning time threshold */
  			if (!is_intnonneg (optarg))
! 				usage2 (_("invalid warning threshold"), optarg);
  			warning_time = strtod (optarg, NULL);
  			check_warning_time = TRUE;
***************
*** 384,388 ****
  		case 'S': /* use SSL */
  #ifndef HAVE_SSL
! 			usage ("check_http: invalid option - SSL is not available\n");
  #endif
  			use_ssl = TRUE;
--- 399,403 ----
  		case 'S': /* use SSL */
  #ifndef HAVE_SSL
! 			usage (_("check_http: invalid option - SSL is not available\n"));
  #endif
  			use_ssl = TRUE;
***************
*** 393,401 ****
  #ifdef HAVE_SSL
  			if (!is_intnonneg (optarg))
! 				usage2 ("invalid certificate expiration period", optarg);
  			days_till_exp = atoi (optarg);
  			check_cert = TRUE;
  #else
! 			usage ("check_http: invalid option - SSL is not available\n");
  #endif
  			break;
--- 408,416 ----
  #ifdef HAVE_SSL
  			if (!is_intnonneg (optarg))
! 				usage2 (_("invalid certificate expiration period"), optarg);
  			days_till_exp = atoi (optarg);
  			check_cert = TRUE;
  #else
! 			usage (_("check_http: invalid option - SSL is not available\n"));
  #endif
  			break;
***************
*** 412,416 ****
  				onredirect = STATE_CRITICAL;
  			if (verbose)
! 				printf("option f:%d \n", onredirect);  
  			break;
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
--- 427,431 ----
  				onredirect = STATE_CRITICAL;
  			if (verbose)
! 				printf(_("option f:%d \n"), onredirect);  
  			break;
  		/* Note: H, I, and u must be malloc'd or will fail on redirects */
***************
*** 427,431 ****
  		case 'p': /* Host or server */
  			if (!is_intnonneg (optarg))
! 				usage2 ("invalid port number", optarg);
  			server_port = atoi (optarg);
  			specify_port = TRUE;
--- 442,446 ----
  		case 'p': /* Host or server */
  			if (!is_intnonneg (optarg))
! 				usage2 (_("invalid port number"), optarg);
  			server_port = atoi (optarg);
  			specify_port = TRUE;
***************
*** 452,456 ****
   		case 'r': /* linespan */
   		case 'R': /* linespan */
! 			usage ("check_http: call for regex which was not a compiled option\n");
  			break;
  #else
--- 467,471 ----
   		case 'r': /* linespan */
   		case 'R': /* linespan */
! 			usage (_("check_http: call for regex which was not a compiled option\n"));
  			break;
  #else
***************
*** 466,470 ****
  			if (errcode != 0) {
  				(void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
! 				printf ("Could Not Compile Regular Expression: %s", errbuf);
  				return ERROR;
  			}
--- 481,485 ----
  			if (errcode != 0) {
  				(void) regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
! 				printf (_("Could Not Compile Regular Expression: %s"), errbuf);
  				return ERROR;
  			}
***************
*** 478,482 ****
  			address_family = AF_INET6;
  #else
! 			usage ("IPv6 support not available\n");
  #endif
  			break;
--- 493,497 ----
  			address_family = AF_INET6;
  #else
! 			usage (_("IPv6 support not available\n"));
  #endif
  			break;
***************
*** 500,504 ****
  	if (strcmp (server_address ,"") == 0) {
  		if (strcmp (host_name, "") == 0)
! 			usage ("check_http: you must specify a server address or host name\n");
  		else
  			asprintf (&server_address, "%s", host_name);
--- 515,519 ----
  	if (strcmp (server_address ,"") == 0) {
  		if (strcmp (host_name, "") == 0)
! 			usage (_("check_http: you must specify a server address or host name\n"));
  		else
  			asprintf (&server_address, "%s", host_name);
***************
*** 581,585 ****
  
  		if (connect_SSL () != OK) {
! 			terminate (STATE_CRITICAL, "Unable to open TCP socket");
  		}
  
--- 596,600 ----
  
  		if (connect_SSL () != OK) {
! 			terminate (STATE_CRITICAL, _("Unable to open TCP socket"));
  		}
  
***************
*** 588,592 ****
  		}
  		else {
! 			printf ("ERROR: Cannot retrieve server certificate.\n");
  			return STATE_CRITICAL;
  		}
--- 603,607 ----
  		}
  		else {
! 			printf (_("ERROR: Cannot retrieve server certificate.\n"));
  			return STATE_CRITICAL;
  		}
***************
*** 596,600 ****
  #endif
  		if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
! 			terminate (STATE_CRITICAL, "Unable to open TCP socket");
  #ifdef HAVE_SSL
  	}
--- 611,615 ----
  #endif
  		if (my_tcp_connect (server_address, server_port, &sd) != STATE_OK)
! 			terminate (STATE_CRITICAL, _("Unable to open TCP socket"));
  #ifdef HAVE_SSL
  	}
***************
*** 609,613 ****
  	/* send user agent */
  	asprintf (&buf, "%sUser-Agent: check_http/%s (nagios-plugins %s)\r\n",
! 	          buf, clean_revstring (REVISION), PACKAGE_VERSION);
  
  	/* optionally send the authentication info */
--- 624,628 ----
  	/* send user agent */
  	asprintf (&buf, "%sUser-Agent: check_http/%s (nagios-plugins %s)\r\n",
! 	          buf, clean_revstring (revision), VERSION);
  
  	/* optionally send the authentication info */
***************
*** 654,665 ****
  			sslerr=SSL_get_error(ssl, i);
  			if ( sslerr == SSL_ERROR_SSL ) {
! 				terminate (STATE_WARNING, "Client Certificate Required\n");
  			} else {
! 				terminate (STATE_CRITICAL, "Error in recv()");
  			}
  		}
  		else {
  #endif
! 			terminate (STATE_CRITICAL, "Error in recv()");
  #ifdef HAVE_SSL
  		}
--- 669,680 ----
  			sslerr=SSL_get_error(ssl, i);
  			if ( sslerr == SSL_ERROR_SSL ) {
! 				terminate (STATE_WARNING, _("Client Certificate Required\n"));
  			} else {
! 				terminate (STATE_CRITICAL, _("Error in recv()"));
  			}
  		}
  		else {
  #endif
! 			terminate (STATE_CRITICAL, _("Error in recv()"));
  #ifdef HAVE_SSL
  		}
***************
*** 669,673 ****
  	/* return a CRITICAL status if we couldn't read any data */
  	if (pagesize == (size_t) 0)
! 		terminate (STATE_CRITICAL, "No data received %s", timestamp);
  
  	/* close the connection */
--- 684,688 ----
  	/* return a CRITICAL status if we couldn't read any data */
  	if (pagesize == (size_t) 0)
! 		terminate (STATE_CRITICAL, _("No data received %s"), timestamp);
  
  	/* close the connection */
***************
*** 712,719 ****
  	if (!strstr (status_line, server_expect)) {
  		if (server_port == HTTP_PORT)
! 			asprintf (&msg, "Invalid HTTP response received from host\n");
  		else
  			asprintf (&msg,
! 			                "Invalid HTTP response received from host on port %d\n",
  			                server_port);
  		terminate (STATE_CRITICAL, msg);
--- 727,734 ----
  	if (!strstr (status_line, server_expect)) {
  		if (server_port == HTTP_PORT)
! 			asprintf (&msg, _("Invalid HTTP response received from host\n"));
  		else
  			asprintf (&msg,
! 			                _("Invalid HTTP response received from host on port %d\n"),
  			                server_port);
  		terminate (STATE_CRITICAL, msg);
***************
*** 723,727 ****
  	/* Exit here if server_expect was set by user and not default */
  	if ( server_expect_yn  )  {
! 		asprintf (&msg, "HTTP OK: Status line output matched \"%s\"\n",
  	                  server_expect);
  		if (verbose)
--- 738,742 ----
  	/* Exit here if server_expect was set by user and not default */
  	if ( server_expect_yn  )  {
! 		asprintf (&msg, _("HTTP OK: Status line output matched \"%s\"\n"),
  	                  server_expect);
  		if (verbose)
***************
*** 738,742 ****
  	    	strstr (status_line, "502") ||
  		    strstr (status_line, "503")) {
! 			terminate (STATE_CRITICAL, "HTTP CRITICAL: %s\n", status_line);
  		}
  
--- 753,757 ----
  	    	strstr (status_line, "502") ||
  		    strstr (status_line, "503")) {
! 			terminate (STATE_CRITICAL, _("HTTP CRITICAL: %s\n"), status_line);
  		}
  
***************
*** 747,751 ****
  		    strstr (status_line, "403") ||
  		    strstr (status_line, "404")) {
! 			terminate (STATE_WARNING, "HTTP WARNING: %s\n", status_line);
  		}
  
--- 762,766 ----
  		    strstr (status_line, "403") ||
  		    strstr (status_line, "404")) {
! 			terminate (STATE_WARNING, _("HTTP WARNING: %s\n"), status_line);
  		}
  
***************
*** 764,773 ****
  					if (server_address == NULL)
  						terminate (STATE_UNKNOWN,
! 										 "HTTP UNKNOWN: could not allocate server_address");
! 					if (strcspn (pos, "\r\n") > server_url_length) {
  						server_url = realloc (server_url, strcspn (pos, "\r\n"));
  						if (server_url == NULL)
  							terminate (STATE_UNKNOWN,
! 							           "HTTP UNKNOWN: could not allocate server_url");
  						server_url_length = strcspn (pos, "\r\n");
  					}
--- 779,788 ----
  					if (server_address == NULL)
  						terminate (STATE_UNKNOWN,
! 										 _("HTTP UNKNOWN: could not allocate server_address"));
! 					if (strcspn (pos, "\r\n") > (size_t)server_url_length) {
  						server_url = realloc (server_url, strcspn (pos, "\r\n"));
  						if (server_url == NULL)
  							terminate (STATE_UNKNOWN,
! 							           _("HTTP UNKNOWN: could not allocate server_url"));
  						server_url_length = strcspn (pos, "\r\n");
  					}
***************
*** 808,812 ****
  					pos += (size_t) strspn (pos, "\r\n");
  				} /* end while (pos) */
! 				printf ("UNKNOWN - Could not find redirect location - %s%s",
  				        status_line, (display_html ? "</A>" : ""));
  				exit (STATE_UNKNOWN);
--- 823,827 ----
  					pos += (size_t) strspn (pos, "\r\n");
  				} /* end while (pos) */
! 				printf (_("UNKNOWN - Could not find redirect location - %s%s"),
  				        status_line, (display_html ? "</A>" : ""));
  				exit (STATE_UNKNOWN);
***************
*** 814,826 ****
  			
  			else if (onredirect == STATE_UNKNOWN)
! 				printf ("UNKNOWN");
  			else if (onredirect == STATE_OK)
! 				printf ("OK");
  			else if (onredirect == STATE_WARNING)
! 				printf ("WARNING");
  			else if (onredirect == STATE_CRITICAL)
! 				printf ("CRITICAL");
  			elapsed_time = delta_time (tv);
! 			asprintf (&msg, " - %s - %.3f second response time %s%s|time=%.3f\n",
  		                 status_line, elapsed_time, timestamp,
  	                   (display_html ? "</A>" : ""), elapsed_time);
--- 829,841 ----
  			
  			else if (onredirect == STATE_UNKNOWN)
! 				printf (_("UNKNOWN"));
  			else if (onredirect == STATE_OK)
! 				printf (_("OK"));
  			else if (onredirect == STATE_WARNING)
! 				printf (_("WARNING"));
  			else if (onredirect == STATE_CRITICAL)
! 				printf (_("CRITICAL"));
  			elapsed_time = delta_time (tv);
! 			asprintf (&msg, _(" - %s - %.3f second response time %s%s|time=%.3f\n"),
  		                 status_line, elapsed_time, timestamp,
  	                   (display_html ? "</A>" : ""), elapsed_time);
***************
*** 834,838 ****
  	/* check elapsed time */
  	elapsed_time = delta_time (tv);
! 	asprintf (&msg, "HTTP problem: %s - %.3f second response time %s%s|time=%.3f\n",
  	               status_line, elapsed_time, timestamp,
  	               (display_html ? "</A>" : ""), elapsed_time);
--- 849,853 ----
  	/* check elapsed time */
  	elapsed_time = delta_time (tv);
! 	asprintf (&msg, _("HTTP problem: %s - %.3f second response time %s%s|time=%.3f\n"),
  	               status_line, elapsed_time, timestamp,
  	               (display_html ? "</A>" : ""), elapsed_time);
***************
*** 847,851 ****
  	if (strlen (string_expect)) {
  		if (strstr (page, string_expect)) {
! 			printf ("HTTP OK %s - %.3f second response time %s%s|time=%.3f\n",
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""), elapsed_time);
--- 862,866 ----
  	if (strlen (string_expect)) {
  		if (strstr (page, string_expect)) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|time=%.3f\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""), elapsed_time);
***************
*** 853,857 ****
  		}
  		else {
! 			printf ("CRITICAL - string not found%s|time=%.3f\n",
  			        (display_html ? "</A>" : ""), elapsed_time);
  			exit (STATE_CRITICAL);
--- 868,872 ----
  		}
  		else {
! 			printf (_("CRITICAL - string not found%s|time=%.3f\n"),
  			        (display_html ? "</A>" : ""), elapsed_time);
  			exit (STATE_CRITICAL);
***************
*** 862,866 ****
  		errcode = regexec (&preg, page, REGS, pmatch, 0);
  		if (errcode == 0) {
! 			printf ("HTTP OK %s - %.3f second response time %s%s|time=%.3f\n",
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""), elapsed_time);
--- 877,881 ----
  		errcode = regexec (&preg, page, REGS, pmatch, 0);
  		if (errcode == 0) {
! 			printf (_("HTTP OK %s - %.3f second response time %s%s|time=%.3f\n"),
  			        status_line, elapsed_time,
  			        timestamp, (display_html ? "</A>" : ""), elapsed_time);
***************
*** 869,873 ****
  		else {
  			if (errcode == REG_NOMATCH) {
! 				printf ("CRITICAL - pattern not found%s|time=%.3f\n",
  				        (display_html ? "</A>" : ""), elapsed_time);
  				exit (STATE_CRITICAL);
--- 884,888 ----
  		else {
  			if (errcode == REG_NOMATCH) {
! 				printf (_("CRITICAL - pattern not found%s|time=%.3f\n"),
  				        (display_html ? "</A>" : ""), elapsed_time);
  				exit (STATE_CRITICAL);
***************
*** 875,879 ****
  			else {
  				regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
! 				printf ("CRITICAL - Execute Error: %s\n", errbuf);
  				exit (STATE_CRITICAL);
  			}
--- 890,894 ----
  			else {
  				regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER);
! 				printf (_("CRITICAL - Execute Error: %s\n"), errbuf);
  				exit (STATE_CRITICAL);
  			}
***************
*** 885,894 ****
  	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|time=%.3f\n",
  	                status_line, (float)elapsed_time,
  	                timestamp, (display_html ? "</A>" : ""), elapsed_time);
--- 900,909 ----
  	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|time=%.3f\n"),
  	                status_line, (float)elapsed_time,
  	                timestamp, (display_html ? "</A>" : ""), elapsed_time);
***************
*** 907,911 ****
  	RAND_seed (randbuff, strlen (randbuff));
  	if (verbose)
! 		printf("SSL seeding: %s\n", (RAND_status()==1 ? "OK" : "Failed") );
  
  	/* Initialize SSL context */
--- 922,926 ----
  	RAND_seed (randbuff, strlen (randbuff));
  	if (verbose)
! 		printf(_("SSL seeding: %s\n"), (RAND_status()==1 ? _("OK") : _("Failed")) );
  
  	/* Initialize SSL context */
***************
*** 914,918 ****
  	SSL_load_error_strings ();
  	if ((ctx = SSL_CTX_new (meth)) == NULL) {
! 		printf ("CRITICAL -  Cannot create SSL context.\n");
  		return STATE_CRITICAL;
  	}
--- 929,933 ----
  	SSL_load_error_strings ();
  	if ((ctx = SSL_CTX_new (meth)) == NULL) {
! 		printf (_("CRITICAL -  Cannot create SSL context.\n"));
  		return STATE_CRITICAL;
  	}
***************
*** 938,942 ****
  		}
  		else {
! 			printf ("CRITICAL - Cannot initiate SSL handshake.\n");
  		}
  		SSL_free (ssl);
--- 953,957 ----
  		}
  		else {
! 			printf (_("CRITICAL - Cannot initiate SSL handshake.\n"));
  		}
  		SSL_free (ssl);
***************
*** 966,970 ****
  	if (tm->type == V_ASN1_UTCTIME) {
  		if (tm->length < 10) {
! 			printf ("CRITICAL - Wrong time format in certificate.\n");
  			return STATE_CRITICAL;
  		}
--- 981,985 ----
  	if (tm->type == V_ASN1_UTCTIME) {
  		if (tm->length < 10) {
! 			printf (_("CRITICAL - Wrong time format in certificate.\n"));
  			return STATE_CRITICAL;
  		}
***************
*** 978,982 ****
  	else {
  		if (tm->length < 12) {
! 			printf ("CRITICAL - Wrong time format in certificate.\n");
  			return STATE_CRITICAL;
  		}
--- 993,997 ----
  	else {
  		if (tm->length < 12) {
! 			printf (_("CRITICAL - Wrong time format in certificate.\n"));
  			return STATE_CRITICAL;
  		}
***************
*** 1007,1024 ****
  
  	if (days_left > 0 && days_left <= days_till_exp) {
! 		printf ("WARNING - Certificate expires in %d day(s) (%s).\n", days_left, timestamp);
  		return STATE_WARNING;
  	}
  	if (days_left < 0) {
! 		printf ("CRITICAL - Certificate expired on %s.\n", timestamp);
  		return STATE_CRITICAL;
  	}
  
  	if (days_left == 0) {
! 		printf ("WARNING - Certificate expires today (%s).\n", timestamp);
  		return STATE_WARNING;
  	}
  
! 	printf ("OK - Certificate will expire on %s.\n", timestamp);
  
  	return STATE_OK;
--- 1022,1039 ----
  
  	if (days_left > 0 && days_left <= days_till_exp) {
! 		printf (_("WARNING - Certificate expires in %d day(s) (%s).\n"), days_left, timestamp);
  		return STATE_WARNING;
  	}
  	if (days_left < 0) {
! 		printf (_("CRITICAL - Certificate expired on %s.\n"), timestamp);
  		return STATE_CRITICAL;
  	}
  
  	if (days_left == 0) {
! 		printf (_("WARNING - Certificate expires today (%s).\n"), timestamp);
  		return STATE_WARNING;
  	}
  
! 	printf (_("OK - Certificate will expire on %s.\n"), timestamp);
  
  	return STATE_OK;
***************
*** 1062,1094 ****
  	}
  #endif
- }
- 
- 
- 
- void
- print_help (void)
- {
- 	print_revision (progname, REVISION);
- 	printf
- 		("Copyright (c) %s %s <%s>\n\n%s\n",
- 		 COPYRIGHT, AUTHORS, EMAIL, SUMMARY);
- 	print_usage ();
- 	printf ("NOTE: One or both of -H and -I must be specified\n");
- 	printf ("\nOptions:\n" LONGOPTIONS "\n", HTTP_EXPECT, HTTP_PORT,
- 	        DEFAULT_SOCKET_TIMEOUT, SSLOPTIONS, REGOPTIONS);
- #ifdef HAVE_SSL
- 	printf (SSLDESCRIPTION);
- #endif
- }
- 
- 
- void
- print_usage (void)
- {
- 	printf ("\
- Usage:\n\
-  %s %s\n\
-  %s (-h | --help) for detailed help\n\
-  %s (-V | --version) for version information\n",
- 	progname, OPTIONS, progname, progname);
  }
--- 1077,1079 ----





More information about the Commits mailing list