summaryrefslogtreecommitdiffstats
path: root/plugins/check_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r--plugins/check_http.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 71f94b91..73e4f3b6 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -205,7 +205,8 @@ bool process_arguments(int argc, char **argv) {
205 SNI_OPTION, 205 SNI_OPTION,
206 MAX_REDIRS_OPTION, 206 MAX_REDIRS_OPTION,
207 CONTINUE_AFTER_CHECK_CERT, 207 CONTINUE_AFTER_CHECK_CERT,
208 STATE_REGEX 208 STATE_REGEX,
209 TIMEOUT_RESULT
209 }; 210 };
210 211
211 int option = 0; 212 int option = 0;
@@ -247,6 +248,7 @@ bool process_arguments(int argc, char **argv) {
247 {"extended-perfdata", no_argument, 0, 'E'}, 248 {"extended-perfdata", no_argument, 0, 'E'},
248 {"show-body", no_argument, 0, 'B'}, 249 {"show-body", no_argument, 0, 'B'},
249 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION}, 250 {"max-redirs", required_argument, 0, MAX_REDIRS_OPTION},
251 {"timeout-result", required_argument, 0, TIMEOUT_RESULT},
250 {0, 0, 0, 0}}; 252 {0, 0, 0, 0}};
251 253
252 if (argc < 2) { 254 if (argc < 2) {
@@ -298,6 +300,21 @@ bool process_arguments(int argc, char **argv) {
298 socket_timeout = atoi(optarg); 300 socket_timeout = atoi(optarg);
299 } 301 }
300 break; 302 break;
303 case TIMEOUT_RESULT:
304 if (!strcmp(optarg, "0") || !strcasecmp(optarg, "ok")) {
305 socket_timeout_state = STATE_OK;
306 } else if (!strcmp(optarg, "1") || !strcasecmp(optarg, "warning")) {
307 socket_timeout_state = STATE_WARNING;
308 } else if (!strcmp(optarg, "2") || !strcasecmp(optarg, "critical")) {
309 socket_timeout_state = STATE_CRITICAL;
310 } else if (!strcmp(optarg, "3") || !strcasecmp(optarg, "unknown")) {
311 socket_timeout_state = STATE_UNKNOWN;
312 } else {
313 usage2(_("Invalid timeout-result state option, give either a return code or state "
314 "name in lowercase"),
315 optarg);
316 }
317 break;
301 case 'c': /* critical time threshold */ 318 case 'c': /* critical time threshold */
302 critical_thresholds = optarg; 319 critical_thresholds = optarg;
303 break; 320 break;
@@ -1032,7 +1049,7 @@ int check_http(void) {
1032 printf("SSL initialized\n"); 1049 printf("SSL initialized\n");
1033 } 1050 }
1034 if (result != STATE_OK) { 1051 if (result != STATE_OK) {
1035 die(STATE_CRITICAL, _("HTTP CRITICAL - SSL error\n")); 1052 die(STATE_CRITICAL, _("HTTP CRITICAL - SSL error\n"));
1036 } 1053 }
1037 microsec_ssl = deltime(tv_temp); 1054 microsec_ssl = deltime(tv_temp);
1038 elapsed_time_ssl = (double)microsec_ssl / 1.0e6; 1055 elapsed_time_ssl = (double)microsec_ssl / 1.0e6;
@@ -1883,6 +1900,10 @@ void print_help(void) {
1883 1900
1884 printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 1901 printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
1885 1902
1903 printf(" %s\n", "--timeout-result=ok|warning|critical|unknown|0|1|2|3");
1904 printf(" %s\n", _("Timeouts default to returning STATE_CRITICAL."));
1905 printf(" %s\n", _("This argument changes the return state on timeouts."));
1906
1886 printf(UT_VERBOSE); 1907 printf(UT_VERBOSE);
1887 1908
1888 printf("\n"); 1909 printf("\n");