diff options
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 116 |
1 files changed, 68 insertions, 48 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 315848f..77a235e 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -58,8 +58,8 @@ enum { | |||
58 | 58 | ||
59 | #ifdef HAVE_SSL | 59 | #ifdef HAVE_SSL |
60 | int check_cert = FALSE; | 60 | int check_cert = FALSE; |
61 | int days_till_exp; | ||
62 | int ssl_version; | 61 | int ssl_version; |
62 | int days_till_exp_warn, days_till_exp_crit; | ||
63 | char *randbuff; | 63 | char *randbuff; |
64 | X509 *server_cert; | 64 | X509 *server_cert; |
65 | # define my_recv(buf, len) ((use_ssl) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) | 65 | # define my_recv(buf, len) ((use_ssl) ? np_net_ssl_read(buf, len) : read(sd, buf, len)) |
@@ -147,7 +147,7 @@ main (int argc, char **argv) | |||
147 | /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */ | 147 | /* Set default URL. Must be malloced for subsequent realloc if --onredirect=follow */ |
148 | server_url = strdup(HTTP_URL); | 148 | server_url = strdup(HTTP_URL); |
149 | server_url_length = strlen(server_url); | 149 | server_url_length = strlen(server_url); |
150 | asprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)", | 150 | xasprintf (&user_agent, "User-Agent: check_http/v%s (nagios-plugins %s)", |
151 | NP_VERSION, VERSION); | 151 | NP_VERSION, VERSION); |
152 | 152 | ||
153 | /* Parse extra opts if any */ | 153 | /* Parse extra opts if any */ |
@@ -178,6 +178,7 @@ process_arguments (int argc, char **argv) | |||
178 | { | 178 | { |
179 | int c = 1; | 179 | int c = 1; |
180 | char *p; | 180 | char *p; |
181 | char *temp; | ||
181 | 182 | ||
182 | enum { | 183 | enum { |
183 | INVERT_REGEX = CHAR_MAX + 1, | 184 | INVERT_REGEX = CHAR_MAX + 1, |
@@ -264,7 +265,7 @@ process_arguments (int argc, char **argv) | |||
264 | warning_thresholds = optarg; | 265 | warning_thresholds = optarg; |
265 | break; | 266 | break; |
266 | case 'A': /* User Agent String */ | 267 | case 'A': /* User Agent String */ |
267 | asprintf (&user_agent, "User-Agent: %s", optarg); | 268 | xasprintf (&user_agent, "User-Agent: %s", optarg); |
268 | break; | 269 | break; |
269 | case 'k': /* Additional headers */ | 270 | case 'k': /* Additional headers */ |
270 | if (http_opt_headers_count == 0) | 271 | if (http_opt_headers_count == 0) |
@@ -272,7 +273,7 @@ process_arguments (int argc, char **argv) | |||
272 | else | 273 | else |
273 | http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count)); | 274 | http_opt_headers = realloc (http_opt_headers, sizeof (char *) * (++http_opt_headers_count)); |
274 | http_opt_headers[http_opt_headers_count - 1] = optarg; | 275 | http_opt_headers[http_opt_headers_count - 1] = optarg; |
275 | /* asprintf (&http_opt_headers, "%s", optarg); */ | 276 | /* xasprintf (&http_opt_headers, "%s", optarg); */ |
276 | break; | 277 | break; |
277 | case 'L': /* show html link */ | 278 | case 'L': /* show html link */ |
278 | display_html = TRUE; | 279 | display_html = TRUE; |
@@ -282,13 +283,25 @@ process_arguments (int argc, char **argv) | |||
282 | break; | 283 | break; |
283 | case 'C': /* Check SSL cert validity */ | 284 | case 'C': /* Check SSL cert validity */ |
284 | #ifdef HAVE_SSL | 285 | #ifdef HAVE_SSL |
285 | if (!is_intnonneg (optarg)) | 286 | if ((temp=strchr(optarg,','))!=NULL) { |
286 | usage2 (_("Invalid certificate expiration period"), optarg); | 287 | *temp='\0'; |
288 | if (!is_intnonneg (temp)) | ||
289 | usage2 (_("Invalid certificate expiration period"), optarg); | ||
290 | days_till_exp_warn = atoi(optarg); | ||
291 | *temp=','; | ||
292 | temp++; | ||
293 | if (!is_intnonneg (temp)) | ||
294 | usage2 (_("Invalid certificate expiration period"), temp); | ||
295 | days_till_exp_crit = atoi (temp); | ||
296 | } | ||
287 | else { | 297 | else { |
288 | days_till_exp = atoi (optarg); | 298 | days_till_exp_crit=0; |
289 | check_cert = TRUE; | 299 | if (!is_intnonneg (optarg)) |
300 | usage2 (_("Invalid certificate expiration period"), optarg); | ||
301 | days_till_exp_warn = atoi (optarg); | ||
290 | } | 302 | } |
291 | /* Fall through to -S option */ | 303 | check_cert = TRUE; |
304 | /* Fall through to -S option */ | ||
292 | #endif | 305 | #endif |
293 | case 'S': /* use SSL */ | 306 | case 'S': /* use SSL */ |
294 | #ifndef HAVE_SSL | 307 | #ifndef HAVE_SSL |
@@ -381,7 +394,7 @@ process_arguments (int argc, char **argv) | |||
381 | server_expect_yn = 1; | 394 | server_expect_yn = 1; |
382 | break; | 395 | break; |
383 | case 'T': /* Content-type */ | 396 | case 'T': /* Content-type */ |
384 | asprintf (&http_content_type, "%s", optarg); | 397 | xasprintf (&http_content_type, "%s", optarg); |
385 | break; | 398 | break; |
386 | case 'l': /* linespan */ | 399 | case 'l': /* linespan */ |
387 | cflags &= ~REG_NEWLINE; | 400 | cflags &= ~REG_NEWLINE; |
@@ -677,31 +690,31 @@ check_document_dates (const char *headers, char **msg) | |||
677 | 690 | ||
678 | /* Done parsing the body. Now check the dates we (hopefully) parsed. */ | 691 | /* Done parsing the body. Now check the dates we (hopefully) parsed. */ |
679 | if (!server_date || !*server_date) { | 692 | if (!server_date || !*server_date) { |
680 | asprintf (msg, _("%sServer date unknown, "), *msg); | 693 | xasprintf (msg, _("%sServer date unknown, "), *msg); |
681 | date_result = max_state_alt(STATE_UNKNOWN, date_result); | 694 | date_result = max_state_alt(STATE_UNKNOWN, date_result); |
682 | } else if (!document_date || !*document_date) { | 695 | } else if (!document_date || !*document_date) { |
683 | asprintf (msg, _("%sDocument modification date unknown, "), *msg); | 696 | xasprintf (msg, _("%sDocument modification date unknown, "), *msg); |
684 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 697 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
685 | } else { | 698 | } else { |
686 | time_t srv_data = parse_time_string (server_date); | 699 | time_t srv_data = parse_time_string (server_date); |
687 | time_t doc_data = parse_time_string (document_date); | 700 | time_t doc_data = parse_time_string (document_date); |
688 | 701 | ||
689 | if (srv_data <= 0) { | 702 | if (srv_data <= 0) { |
690 | asprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); | 703 | xasprintf (msg, _("%sServer date \"%100s\" unparsable, "), *msg, server_date); |
691 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 704 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
692 | } else if (doc_data <= 0) { | 705 | } else if (doc_data <= 0) { |
693 | asprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date); | 706 | xasprintf (msg, _("%sDocument date \"%100s\" unparsable, "), *msg, document_date); |
694 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 707 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
695 | } else if (doc_data > srv_data + 30) { | 708 | } else if (doc_data > srv_data + 30) { |
696 | asprintf (msg, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data); | 709 | xasprintf (msg, _("%sDocument is %d seconds in the future, "), *msg, (int)doc_data - (int)srv_data); |
697 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 710 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
698 | } else if (doc_data < srv_data - maximum_age) { | 711 | } else if (doc_data < srv_data - maximum_age) { |
699 | int n = (srv_data - doc_data); | 712 | int n = (srv_data - doc_data); |
700 | if (n > (60 * 60 * 24 * 2)) { | 713 | if (n > (60 * 60 * 24 * 2)) { |
701 | asprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24)); | 714 | xasprintf (msg, _("%sLast modified %.1f days ago, "), *msg, ((float) n) / (60 * 60 * 24)); |
702 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 715 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
703 | } else { | 716 | } else { |
704 | asprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60); | 717 | xasprintf (msg, _("%sLast modified %d:%02d:%02d ago, "), *msg, n / (60 * 60), (n / 60) % 60, n % 60); |
705 | date_result = max_state_alt(STATE_CRITICAL, date_result); | 718 | date_result = max_state_alt(STATE_CRITICAL, date_result); |
706 | } | 719 | } |
707 | } | 720 | } |
@@ -810,7 +823,7 @@ check_http (void) | |||
810 | if (result != STATE_OK) | 823 | if (result != STATE_OK) |
811 | return result; | 824 | return result; |
812 | if (check_cert == TRUE) { | 825 | if (check_cert == TRUE) { |
813 | result = np_net_ssl_check_cert(days_till_exp); | 826 | result = np_net_ssl_check_cert(days_till_exp_warn, days_till_exp_crit); |
814 | np_net_ssl_cleanup(); | 827 | np_net_ssl_cleanup(); |
815 | if (sd) close(sd); | 828 | if (sd) close(sd); |
816 | return result; | 829 | return result; |
@@ -818,10 +831,10 @@ check_http (void) | |||
818 | } | 831 | } |
819 | #endif /* HAVE_SSL */ | 832 | #endif /* HAVE_SSL */ |
820 | 833 | ||
821 | asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); | 834 | xasprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent); |
822 | 835 | ||
823 | /* tell HTTP/1.1 servers not to keep the connection alive */ | 836 | /* tell HTTP/1.1 servers not to keep the connection alive */ |
824 | asprintf (&buf, "%sConnection: close\r\n", buf); | 837 | xasprintf (&buf, "%sConnection: close\r\n", buf); |
825 | 838 | ||
826 | /* optionally send the host header info */ | 839 | /* optionally send the host header info */ |
827 | if (host_name) { | 840 | if (host_name) { |
@@ -832,16 +845,16 @@ check_http (void) | |||
832 | */ | 845 | */ |
833 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || | 846 | if ((use_ssl == FALSE && server_port == HTTP_PORT) || |
834 | (use_ssl == TRUE && server_port == HTTPS_PORT)) | 847 | (use_ssl == TRUE && server_port == HTTPS_PORT)) |
835 | asprintf (&buf, "%sHost: %s\r\n", buf, host_name); | 848 | xasprintf (&buf, "%sHost: %s\r\n", buf, host_name); |
836 | else | 849 | else |
837 | asprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); | 850 | xasprintf (&buf, "%sHost: %s:%d\r\n", buf, host_name, server_port); |
838 | } | 851 | } |
839 | 852 | ||
840 | /* optionally send any other header tag */ | 853 | /* optionally send any other header tag */ |
841 | if (http_opt_headers_count) { | 854 | if (http_opt_headers_count) { |
842 | for (i = 0; i < http_opt_headers_count ; i++) { | 855 | for (i = 0; i < http_opt_headers_count ; i++) { |
843 | for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) | 856 | for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) |
844 | asprintf (&buf, "%s%s\r\n", buf, pos); | 857 | xasprintf (&buf, "%s%s\r\n", buf, pos); |
845 | } | 858 | } |
846 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ | 859 | /* This cannot be free'd here because a redirection will then try to access this and segfault */ |
847 | /* Covered in a testcase in tests/check_http.t */ | 860 | /* Covered in a testcase in tests/check_http.t */ |
@@ -851,29 +864,29 @@ check_http (void) | |||
851 | /* optionally send the authentication info */ | 864 | /* optionally send the authentication info */ |
852 | if (strlen(user_auth)) { | 865 | if (strlen(user_auth)) { |
853 | base64_encode_alloc (user_auth, strlen (user_auth), &auth); | 866 | base64_encode_alloc (user_auth, strlen (user_auth), &auth); |
854 | asprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); | 867 | xasprintf (&buf, "%sAuthorization: Basic %s\r\n", buf, auth); |
855 | } | 868 | } |
856 | 869 | ||
857 | /* optionally send the proxy authentication info */ | 870 | /* optionally send the proxy authentication info */ |
858 | if (strlen(proxy_auth)) { | 871 | if (strlen(proxy_auth)) { |
859 | base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); | 872 | base64_encode_alloc (proxy_auth, strlen (proxy_auth), &auth); |
860 | asprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); | 873 | xasprintf (&buf, "%sProxy-Authorization: Basic %s\r\n", buf, auth); |
861 | } | 874 | } |
862 | 875 | ||
863 | /* either send http POST data (any data, not only POST)*/ | 876 | /* either send http POST data (any data, not only POST)*/ |
864 | if (http_post_data) { | 877 | if (http_post_data) { |
865 | if (http_content_type) { | 878 | if (http_content_type) { |
866 | asprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); | 879 | xasprintf (&buf, "%sContent-Type: %s\r\n", buf, http_content_type); |
867 | } else { | 880 | } else { |
868 | asprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); | 881 | xasprintf (&buf, "%sContent-Type: application/x-www-form-urlencoded\r\n", buf); |
869 | } | 882 | } |
870 | 883 | ||
871 | asprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); | 884 | xasprintf (&buf, "%sContent-Length: %i\r\n\r\n", buf, (int)strlen (http_post_data)); |
872 | asprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); | 885 | xasprintf (&buf, "%s%s%s", buf, http_post_data, CRLF); |
873 | } | 886 | } |
874 | else { | 887 | else { |
875 | /* or just a newline so the server knows we're done with the request */ | 888 | /* or just a newline so the server knows we're done with the request */ |
876 | asprintf (&buf, "%s%s", buf, CRLF); | 889 | xasprintf (&buf, "%s%s", buf, CRLF); |
877 | } | 890 | } |
878 | 891 | ||
879 | if (verbose) printf ("%s\n", buf); | 892 | if (verbose) printf ("%s\n", buf); |
@@ -883,7 +896,7 @@ check_http (void) | |||
883 | full_page = strdup(""); | 896 | full_page = strdup(""); |
884 | while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) { | 897 | while ((i = my_recv (buffer, MAX_INPUT_BUFFER-1)) > 0) { |
885 | buffer[i] = '\0'; | 898 | buffer[i] = '\0'; |
886 | asprintf (&full_page_new, "%s%s", full_page, buffer); | 899 | xasprintf (&full_page_new, "%s%s", full_page, buffer); |
887 | free (full_page); | 900 | free (full_page); |
888 | full_page = full_page_new; | 901 | full_page = full_page_new; |
889 | pagesize += i; | 902 | pagesize += i; |
@@ -968,11 +981,11 @@ check_http (void) | |||
968 | /* make sure the status line matches the response we are looking for */ | 981 | /* make sure the status line matches the response we are looking for */ |
969 | if (!expected_statuscode (status_line, server_expect)) { | 982 | if (!expected_statuscode (status_line, server_expect)) { |
970 | if (server_port == HTTP_PORT) | 983 | if (server_port == HTTP_PORT) |
971 | asprintf (&msg, | 984 | xasprintf (&msg, |
972 | _("Invalid HTTP response received from host: %s\n"), | 985 | _("Invalid HTTP response received from host: %s\n"), |
973 | status_line); | 986 | status_line); |
974 | else | 987 | else |
975 | asprintf (&msg, | 988 | xasprintf (&msg, |
976 | _("Invalid HTTP response received from host on port %d: %s\n"), | 989 | _("Invalid HTTP response received from host on port %d: %s\n"), |
977 | server_port, status_line); | 990 | server_port, status_line); |
978 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); | 991 | die (STATE_CRITICAL, "HTTP CRITICAL - %s", msg); |
@@ -981,7 +994,7 @@ check_http (void) | |||
981 | /* Bypass normal status line check if server_expect was set by user and not default */ | 994 | /* Bypass normal status line check if server_expect was set by user and not default */ |
982 | /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */ | 995 | /* NOTE: After this if/else block msg *MUST* be an asprintf-allocated string */ |
983 | if ( server_expect_yn ) { | 996 | if ( server_expect_yn ) { |
984 | asprintf (&msg, | 997 | xasprintf (&msg, |
985 | _("Status line output matched \"%s\" - "), server_expect); | 998 | _("Status line output matched \"%s\" - "), server_expect); |
986 | if (verbose) | 999 | if (verbose) |
987 | printf ("%s\n",msg); | 1000 | printf ("%s\n",msg); |
@@ -1004,12 +1017,12 @@ check_http (void) | |||
1004 | } | 1017 | } |
1005 | /* server errors result in a critical state */ | 1018 | /* server errors result in a critical state */ |
1006 | else if (http_status >= 500) { | 1019 | else if (http_status >= 500) { |
1007 | asprintf (&msg, _("%s - "), status_line); | 1020 | xasprintf (&msg, _("%s - "), status_line); |
1008 | result = STATE_CRITICAL; | 1021 | result = STATE_CRITICAL; |
1009 | } | 1022 | } |
1010 | /* client errors result in a warning state */ | 1023 | /* client errors result in a warning state */ |
1011 | else if (http_status >= 400) { | 1024 | else if (http_status >= 400) { |
1012 | asprintf (&msg, _("%s - "), status_line); | 1025 | xasprintf (&msg, _("%s - "), status_line); |
1013 | result = max_state_alt(STATE_WARNING, result); | 1026 | result = max_state_alt(STATE_WARNING, result); |
1014 | } | 1027 | } |
1015 | /* check redirected page if specified */ | 1028 | /* check redirected page if specified */ |
@@ -1019,11 +1032,11 @@ check_http (void) | |||
1019 | redir (header, status_line); | 1032 | redir (header, status_line); |
1020 | else | 1033 | else |
1021 | result = max_state_alt(onredirect, result); | 1034 | result = max_state_alt(onredirect, result); |
1022 | asprintf (&msg, _("%s - "), status_line); | 1035 | xasprintf (&msg, _("%s - "), status_line); |
1023 | } /* end if (http_status >= 300) */ | 1036 | } /* end if (http_status >= 300) */ |
1024 | else { | 1037 | else { |
1025 | /* Print OK status anyway */ | 1038 | /* Print OK status anyway */ |
1026 | asprintf (&msg, _("%s - "), status_line); | 1039 | xasprintf (&msg, _("%s - "), status_line); |
1027 | } | 1040 | } |
1028 | 1041 | ||
1029 | } /* end else (server_expect_yn) */ | 1042 | } /* end else (server_expect_yn) */ |
@@ -1043,7 +1056,7 @@ check_http (void) | |||
1043 | if(output_string_search[sizeof(output_string_search)-1]!='\0') { | 1056 | if(output_string_search[sizeof(output_string_search)-1]!='\0') { |
1044 | bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); | 1057 | bcopy("...",&output_string_search[sizeof(output_string_search)-4],4); |
1045 | } | 1058 | } |
1046 | asprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); | 1059 | xasprintf (&msg, _("%sstring '%s' not found on '%s://%s:%d%s', "), msg, output_string_search, use_ssl ? "https" : "http", host_name ? host_name : server_address, server_port, server_url); |
1047 | result = STATE_CRITICAL; | 1060 | result = STATE_CRITICAL; |
1048 | } | 1061 | } |
1049 | } | 1062 | } |
@@ -1056,15 +1069,15 @@ check_http (void) | |||
1056 | } | 1069 | } |
1057 | else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { | 1070 | else if ((errcode == REG_NOMATCH && invert_regex == 0) || (errcode == 0 && invert_regex == 1)) { |
1058 | if (invert_regex == 0) | 1071 | if (invert_regex == 0) |
1059 | asprintf (&msg, _("%spattern not found, "), msg); | 1072 | xasprintf (&msg, _("%spattern not found, "), msg); |
1060 | else | 1073 | else |
1061 | asprintf (&msg, _("%spattern found, "), msg); | 1074 | xasprintf (&msg, _("%spattern found, "), msg); |
1062 | result = STATE_CRITICAL; | 1075 | result = STATE_CRITICAL; |
1063 | } | 1076 | } |
1064 | else { | 1077 | else { |
1065 | /* FIXME: Shouldn't that be UNKNOWN? */ | 1078 | /* FIXME: Shouldn't that be UNKNOWN? */ |
1066 | regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); | 1079 | regerror (errcode, &preg, errbuf, MAX_INPUT_BUFFER); |
1067 | asprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf); | 1080 | xasprintf (&msg, _("%sExecute Error: %s, "), msg, errbuf); |
1068 | result = STATE_CRITICAL; | 1081 | result = STATE_CRITICAL; |
1069 | } | 1082 | } |
1070 | } | 1083 | } |
@@ -1080,10 +1093,10 @@ check_http (void) | |||
1080 | */ | 1093 | */ |
1081 | page_len = pagesize; | 1094 | page_len = pagesize; |
1082 | if ((max_page_len > 0) && (page_len > max_page_len)) { | 1095 | if ((max_page_len > 0) && (page_len > max_page_len)) { |
1083 | asprintf (&msg, _("%spage size %d too large, "), msg, page_len); | 1096 | xasprintf (&msg, _("%spage size %d too large, "), msg, page_len); |
1084 | result = max_state_alt(STATE_WARNING, result); | 1097 | result = max_state_alt(STATE_WARNING, result); |
1085 | } else if ((min_page_len > 0) && (page_len < min_page_len)) { | 1098 | } else if ((min_page_len > 0) && (page_len < min_page_len)) { |
1086 | asprintf (&msg, _("%spage size %d too small, "), msg, page_len); | 1099 | xasprintf (&msg, _("%spage size %d too small, "), msg, page_len); |
1087 | result = max_state_alt(STATE_WARNING, result); | 1100 | result = max_state_alt(STATE_WARNING, result); |
1088 | } | 1101 | } |
1089 | 1102 | ||
@@ -1094,7 +1107,7 @@ check_http (void) | |||
1094 | msg[strlen(msg)-3] = '\0'; | 1107 | msg[strlen(msg)-3] = '\0'; |
1095 | 1108 | ||
1096 | /* check elapsed time */ | 1109 | /* check elapsed time */ |
1097 | asprintf (&msg, | 1110 | xasprintf (&msg, |
1098 | _("%s - %d bytes in %.3f second response time %s|%s %s"), | 1111 | _("%s - %d bytes in %.3f second response time %s|%s %s"), |
1099 | msg, page_len, elapsed_time, | 1112 | msg, page_len, elapsed_time, |
1100 | (display_html ? "</A>" : ""), | 1113 | (display_html ? "</A>" : ""), |
@@ -1201,7 +1214,7 @@ redir (char *pos, char *status_line) | |||
1201 | if ((url[0] != '/')) { | 1214 | if ((url[0] != '/')) { |
1202 | if ((x = strrchr(server_url, '/'))) | 1215 | if ((x = strrchr(server_url, '/'))) |
1203 | *x = '\0'; | 1216 | *x = '\0'; |
1204 | asprintf (&url, "%s/%s", server_url, url); | 1217 | xasprintf (&url, "%s/%s", server_url, url); |
1205 | } | 1218 | } |
1206 | i = server_port; | 1219 | i = server_port; |
1207 | strcpy (type, server_type); | 1220 | strcpy (type, server_type); |
@@ -1427,6 +1440,13 @@ print_help (void) | |||
1427 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); | 1440 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); |
1428 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); | 1441 | printf (" %s\n", _("14 days, a STATE_WARNING is returned. A STATE_CRITICAL will be returned when")); |
1429 | printf (" %s\n", _("the certificate is expired.")); | 1442 | printf (" %s\n", _("the certificate is expired.")); |
1443 | |||
1444 | printf (" %s\n\n", "CHECK CERTIFICATE: check_http -H www.verisign.com -C 30,14"); | ||
1445 | printf (" %s\n", _("When the certificate of 'www.verisign.com' is valid for more than 30 days,")); | ||
1446 | printf (" %s\n", _("a STATE_OK is returned. When the certificate is still valid, but for less than")); | ||
1447 | printf (" %s\n", _("30 days, but more than 14 days, a STATE_WARNING is returned.")); | ||
1448 | printf (" %s\n", _("A STATE_CRITICAL will be returned when certificate expires in less than 14 days")); | ||
1449 | |||
1430 | #endif | 1450 | #endif |
1431 | 1451 | ||
1432 | printf (UT_SUPPORT); | 1452 | printf (UT_SUPPORT); |
@@ -1444,6 +1464,6 @@ print_usage (void) | |||
1444 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); | 1464 | printf (" [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]\n"); |
1445 | printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); | 1465 | printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n"); |
1446 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); | 1466 | printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n"); |
1447 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <age>] [-T <content-type>]\n"); | 1467 | printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <warn_age>[,<crit_age>]]\n"); |
1448 | printf (" [-j method]\n"); | 1468 | printf (" [-T <content-type>] [-j method]\n"); |
1449 | } | 1469 | } |