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.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 6370e32..433c28e 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -101,10 +101,9 @@ int server_expect_yn = 0;
101char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT; 101char server_expect[MAX_INPUT_BUFFER] = HTTP_EXPECT;
102char string_expect[MAX_INPUT_BUFFER] = ""; 102char string_expect[MAX_INPUT_BUFFER] = "";
103char output_string_search[30] = ""; 103char output_string_search[30] = "";
104double warning_time = 0; 104char *warning_thresholds = NULL;
105int check_warning_time = FALSE; 105char *critical_thresholds = NULL;
106double critical_time = 0; 106thresholds *thlds;
107int check_critical_time = FALSE;
108char user_auth[MAX_INPUT_BUFFER] = ""; 107char user_auth[MAX_INPUT_BUFFER] = "";
109char proxy_auth[MAX_INPUT_BUFFER] = ""; 108char proxy_auth[MAX_INPUT_BUFFER] = "";
110int display_html = FALSE; 109int display_html = FALSE;
@@ -258,20 +257,10 @@ process_arguments (int argc, char **argv)
258 socket_timeout = atoi (optarg); 257 socket_timeout = atoi (optarg);
259 break; 258 break;
260 case 'c': /* critical time threshold */ 259 case 'c': /* critical time threshold */
261 if (!is_nonnegative (optarg)) 260 critical_thresholds = optarg;
262 usage2 (_("Critical threshold must be integer"), optarg);
263 else {
264 critical_time = strtod (optarg, NULL);
265 check_critical_time = TRUE;
266 }
267 break; 261 break;
268 case 'w': /* warning time threshold */ 262 case 'w': /* warning time threshold */
269 if (!is_nonnegative (optarg)) 263 warning_thresholds = optarg;
270 usage2 (_("Warning threshold must be integer"), optarg);
271 else {
272 warning_time = strtod (optarg, NULL);
273 check_warning_time = TRUE;
274 }
275 break; 264 break;
276 case 'A': /* User Agent String */ 265 case 'A': /* User Agent String */
277 asprintf (&user_agent, "User-Agent: %s", optarg); 266 asprintf (&user_agent, "User-Agent: %s", optarg);
@@ -478,8 +467,10 @@ process_arguments (int argc, char **argv)
478 server_address = strdup (host_name); 467 server_address = strdup (host_name);
479 } 468 }
480 469
481 if (check_critical_time && critical_time>(double)socket_timeout) 470 set_thresholds(&thlds, warning_thresholds, critical_thresholds);
482 socket_timeout = (int)critical_time + 1; 471
472 if (critical_thresholds && thlds->critical->end>(double)socket_timeout)
473 socket_timeout = (int)thlds->critical->end + 1;
483 474
484 if (http_method == NULL) 475 if (http_method == NULL)
485 http_method = strdup ("GET"); 476 http_method = strdup ("GET");
@@ -1099,10 +1090,7 @@ check_http (void)
1099 (display_html ? "</A>" : ""), 1090 (display_html ? "</A>" : ""),
1100 perfd_time (elapsed_time), perfd_size (page_len)); 1091 perfd_time (elapsed_time), perfd_size (page_len));
1101 1092
1102 if (check_critical_time == TRUE && elapsed_time > critical_time) 1093 result = max_state_alt(get_status(elapsed_time, thlds), result);
1103 result = STATE_CRITICAL;
1104 if (check_warning_time == TRUE && elapsed_time > warning_time)
1105 result = max_state_alt(STATE_WARNING, result);
1106 1094
1107 die (result, "HTTP %s: %s\n", state_text(result), msg); 1095 die (result, "HTTP %s: %s\n", state_text(result), msg);
1108 /* die failed? */ 1096 /* die failed? */
@@ -1284,8 +1272,8 @@ server_port_check (int ssl_flag)
1284char *perfd_time (double elapsed_time) 1272char *perfd_time (double elapsed_time)
1285{ 1273{
1286 return fperfdata ("time", elapsed_time, "s", 1274 return fperfdata ("time", elapsed_time, "s",
1287 check_warning_time, warning_time, 1275 thlds->warning?TRUE:FALSE, thlds->warning?thlds->warning->end:0,
1288 check_critical_time, critical_time, 1276 thlds->critical?TRUE:FALSE, thlds->critical?thlds->critical->end:0,
1289 TRUE, 0, FALSE, 0); 1277 TRUE, 0, FALSE, 0);
1290} 1278}
1291 1279
@@ -1336,12 +1324,12 @@ print_help (void)
1336 1324
1337#ifdef HAVE_SSL 1325#ifdef HAVE_SSL
1338 printf (" %s\n", "-S, --ssl"); 1326 printf (" %s\n", "-S, --ssl");
1339 printf (" %s\n", _("Connect via SSL. Port defaults to 443")); 1327 printf (" %s\n", _("Connect via SSL. Port defaults to 443"));
1340 printf (" %s\n", "--sni"); 1328 printf (" %s\n", "--sni");
1341 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)")); 1329 printf (" %s\n", _("Enable SSL/TLS hostname extension support (SNI)"));
1342 printf (" %s\n", "-C, --certificate=INTEGER"); 1330 printf (" %s\n", "-C, --certificate=INTEGER");
1343 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443")); 1331 printf (" %s\n", _("Minimum number of days a certificate has to be valid. Port defaults to 443"));
1344 printf (" %s\n", _("(when this option is used the URL is not checked.)\n")); 1332 printf (" %s\n", _("(when this option is used the URL is not checked.)\n"));
1345#endif 1333#endif
1346 1334
1347 printf (" %s\n", "-e, --expect=STRING"); 1335 printf (" %s\n", "-e, --expect=STRING");
@@ -1378,11 +1366,11 @@ print_help (void)
1378 printf (" %s\n", "-a, --authorization=AUTH_PAIR"); 1366 printf (" %s\n", "-a, --authorization=AUTH_PAIR");
1379 printf (" %s\n", _("Username:password on sites with basic authentication")); 1367 printf (" %s\n", _("Username:password on sites with basic authentication"));
1380 printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR"); 1368 printf (" %s\n", "-b, --proxy-authorization=AUTH_PAIR");
1381 printf (" %s\n", _("Username:password on proxy-servers with basic authentication")); 1369 printf (" %s\n", _("Username:password on proxy-servers with basic authentication"));
1382 printf (" %s\n", "-A, --useragent=STRING"); 1370 printf (" %s\n", "-A, --useragent=STRING");
1383 printf (" %s\n", _("String to be sent in http header as \"User Agent\"")); 1371 printf (" %s\n", _("String to be sent in http header as \"User Agent\""));
1384 printf (" %s\n", "-k, --header=STRING"); 1372 printf (" %s\n", "-k, --header=STRING");
1385 printf (" %s\n", _(" Any other tags to be sent in http header. Use multiple times for additional headers")); 1373 printf (" %s\n", _("Any other tags to be sent in http header. Use multiple times for additional headers"));
1386 printf (" %s\n", "-L, --link"); 1374 printf (" %s\n", "-L, --link");
1387 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); 1375 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)"));
1388 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>"); 1376 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");