diff options
Diffstat (limited to 'plugins/check_http.c')
-rw-r--r-- | plugins/check_http.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c index 718c8ee7..cdf768c9 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c | |||
@@ -85,6 +85,7 @@ char errbuf[MAX_INPUT_BUFFER]; | |||
85 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; | 85 | int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE; |
86 | int errcode; | 86 | int errcode; |
87 | int invert_regex = 0; | 87 | int invert_regex = 0; |
88 | int state_regex = STATE_CRITICAL; | ||
88 | 89 | ||
89 | struct timeval tv; | 90 | struct timeval tv; |
90 | struct timeval tv_temp; | 91 | struct timeval tv_temp; |
@@ -210,7 +211,8 @@ bool process_arguments (int argc, char **argv) | |||
210 | INVERT_REGEX = CHAR_MAX + 1, | 211 | INVERT_REGEX = CHAR_MAX + 1, |
211 | SNI_OPTION, | 212 | SNI_OPTION, |
212 | MAX_REDIRS_OPTION, | 213 | MAX_REDIRS_OPTION, |
213 | CONTINUE_AFTER_CHECK_CERT | 214 | CONTINUE_AFTER_CHECK_CERT, |
215 | STATE_REGEX | ||
214 | }; | 216 | }; |
215 | 217 | ||
216 | int option = 0; | 218 | int option = 0; |
@@ -246,6 +248,7 @@ bool process_arguments (int argc, char **argv) | |||
246 | {"content-type", required_argument, 0, 'T'}, | 248 | {"content-type", required_argument, 0, 'T'}, |
247 | {"pagesize", required_argument, 0, 'm'}, | 249 | {"pagesize", required_argument, 0, 'm'}, |
248 | {"invert-regex", no_argument, NULL, INVERT_REGEX}, | 250 | {"invert-regex", no_argument, NULL, INVERT_REGEX}, |
251 | {"state-regex", required_argument, 0, STATE_REGEX}, | ||
249 | {"use-ipv4", no_argument, 0, '4'}, | 252 | {"use-ipv4", no_argument, 0, '4'}, |
250 | {"use-ipv6", no_argument, 0, '6'}, | 253 | {"use-ipv6", no_argument, 0, '6'}, |
251 | {"extended-perfdata", no_argument, 0, 'E'}, | 254 | {"extended-perfdata", no_argument, 0, 'E'}, |
@@ -471,10 +474,9 @@ bool process_arguments (int argc, char **argv) | |||
471 | free(http_method); | 474 | free(http_method); |
472 | http_method = strdup (optarg); | 475 | http_method = strdup (optarg); |
473 | char *tmp; | 476 | char *tmp; |
474 | if ((tmp = strstr(http_method, ":")) > 0) { | 477 | if ((tmp = strstr(http_method, ":")) != NULL) { |
475 | tmp[0] = '\0'; | 478 | tmp[0] = '\0'; // set the ":" in the middle to 0 |
476 | http_method = http_method; | 479 | http_method_proxy = ++tmp; // this points to the second part |
477 | http_method_proxy = ++tmp; | ||
478 | } | 480 | } |
479 | break; | 481 | break; |
480 | case 'd': /* string or substring */ | 482 | case 'd': /* string or substring */ |
@@ -512,6 +514,13 @@ bool process_arguments (int argc, char **argv) | |||
512 | case INVERT_REGEX: | 514 | case INVERT_REGEX: |
513 | invert_regex = 1; | 515 | invert_regex = 1; |
514 | break; | 516 | break; |
517 | case STATE_REGEX: | ||
518 | if (!strcmp (optarg, "critical")) | ||
519 | state_regex = STATE_CRITICAL; | ||
520 | else if (!strcmp (optarg, "warning")) | ||
521 | state_regex = STATE_WARNING; | ||
522 | else usage2 (_("Invalid state-regex option"), optarg); | ||
523 | break; | ||
515 | case '4': | 524 | case '4': |
516 | address_family = AF_INET; | 525 | address_family = AF_INET; |
517 | break; | 526 | break; |
@@ -1094,7 +1103,7 @@ check_http (void) | |||
1094 | microsec_firstbyte = deltime (tv_temp); | 1103 | microsec_firstbyte = deltime (tv_temp); |
1095 | elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6; | 1104 | elapsed_time_firstbyte = (double)microsec_firstbyte / 1.0e6; |
1096 | } | 1105 | } |
1097 | while (pos = memchr(buffer, '\0', i)) { | 1106 | while ((pos = memchr(buffer, '\0', i))) { |
1098 | /* replace nul character with a blank */ | 1107 | /* replace nul character with a blank */ |
1099 | *pos = ' '; | 1108 | *pos = ' '; |
1100 | } | 1109 | } |
@@ -1318,7 +1327,7 @@ check_http (void) | |||
1318 | xasprintf (&msg, _("%spattern not found, "), msg); | 1327 | xasprintf (&msg, _("%spattern not found, "), msg); |
1319 | else | 1328 | else |
1320 | xasprintf (&msg, _("%spattern found, "), msg); | 1329 | xasprintf (&msg, _("%spattern found, "), msg); |
1321 | result = STATE_CRITICAL; | 1330 | result = state_regex; |
1322 | } | 1331 | } |
1323 | else { | 1332 | else { |
1324 | /* FIXME: Shouldn't that be UNKNOWN? */ | 1333 | /* FIXME: Shouldn't that be UNKNOWN? */ |
@@ -1775,7 +1784,7 @@ print_help (void) | |||
1775 | printf (" %s\n", "-u, --url=PATH"); | 1784 | printf (" %s\n", "-u, --url=PATH"); |
1776 | printf (" %s\n", _("URL to GET or POST (default: /)")); | 1785 | printf (" %s\n", _("URL to GET or POST (default: /)")); |
1777 | printf (" %s\n", "-P, --post=STRING"); | 1786 | printf (" %s\n", "-P, --post=STRING"); |
1778 | printf (" %s\n", _("URL encoded http POST data")); | 1787 | printf (" %s\n", _("URL decoded http POST data")); |
1779 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT, CONNECT:POST)"); | 1788 | printf (" %s\n", "-j, --method=STRING (for example: HEAD, OPTIONS, TRACE, PUT, DELETE, CONNECT, CONNECT:POST)"); |
1780 | printf (" %s\n", _("Set HTTP method.")); | 1789 | printf (" %s\n", _("Set HTTP method.")); |
1781 | printf (" %s\n", "-N, --no-body"); | 1790 | printf (" %s\n", "-N, --no-body"); |
@@ -1794,7 +1803,10 @@ print_help (void) | |||
1794 | printf (" %s\n", "-R, --eregi=STRING"); | 1803 | printf (" %s\n", "-R, --eregi=STRING"); |
1795 | printf (" %s\n", _("Search page for case-insensitive regex STRING")); | 1804 | printf (" %s\n", _("Search page for case-insensitive regex STRING")); |
1796 | printf (" %s\n", "--invert-regex"); | 1805 | printf (" %s\n", "--invert-regex"); |
1797 | printf (" %s\n", _("Return CRITICAL if found, OK if not\n")); | 1806 | printf (" %s\n", _("Return STATE if found, OK if not (STATE is CRITICAL, per default)")); |
1807 | printf (" %s\n", _("can be changed with --state--regex)")); | ||
1808 | printf (" %s\n", "--regex-state=STATE"); | ||
1809 | printf (" %s\n", _("Return STATE if regex is found, OK if not\n")); | ||
1798 | 1810 | ||
1799 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); | 1811 | printf (" %s\n", "-a, --authorization=AUTH_PAIR"); |
1800 | printf (" %s\n", _("Username:password on sites with basic authentication")); | 1812 | printf (" %s\n", _("Username:password on sites with basic authentication")); |