X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fcheck_http.c;h=5a859f98774bafa8513cbe64d91bb08fdfd277d2;hb=e7cdcfee2a6025b41f67ead5020df3965ef05a98;hp=72d0a2b6d52e00548a2a584f2a38414436b33d35;hpb=3dd27fb0637cb13c9de09b976765f7a2ba770ac7;p=nagiosplug.git diff --git a/plugins/check_http.c b/plugins/check_http.c index 72d0a2b..5a859f9 100644 --- a/plugins/check_http.c +++ b/plugins/check_http.c @@ -44,6 +44,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; #include #define INPUT_DELIMITER ";" +#define STICKY_NONE 0 +#define STICKY_HOST 1 +#define STICKY_PORT 2 #define HTTP_EXPECT "HTTP/1." enum { @@ -106,7 +109,7 @@ int display_html = FALSE; char **http_opt_headers; int http_opt_headers_count = 0; int onredirect = STATE_OK; -int followsticky = 0; +int followsticky = STICKY_NONE; int use_ssl = FALSE; int verbose = FALSE; int sd; @@ -300,10 +303,12 @@ process_arguments (int argc, char **argv) server_port = HTTPS_PORT; break; case 'f': /* onredirect */ + if (!strcmp (optarg, "stickyport")) + onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT; if (!strcmp (optarg, "sticky")) - onredirect = STATE_DEPENDENT, followsticky = 1; + onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST; if (!strcmp (optarg, "follow")) - onredirect = STATE_DEPENDENT, followsticky = 0; + onredirect = STATE_DEPENDENT, followsticky = STICKY_NONE; if (!strcmp (optarg, "unknown")) onredirect = STATE_UNKNOWN; if (!strcmp (optarg, "ok")) @@ -1203,15 +1208,18 @@ redir (char *pos, char *status_line) free (host_name); host_name = strdup (addr); - if (followsticky == 0) { + if (!(followsticky & STICKY_HOST)) { free (server_address); server_address = strdup (addr); } + if (!(followsticky & STICKY_PORT)) { + server_port = i; + } free (server_url); server_url = url; - if ((server_port = i) > MAX_PORT) + if (server_port > MAX_PORT) die (STATE_UNKNOWN, _("HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"), MAX_PORT, server_type, server_address, server_port, server_url, @@ -1343,9 +1351,9 @@ print_help (void) printf (" %s\n", _(" Any other tags to be sent in http header. Use multiple times for additional headers")); printf (" %s\n", "-L, --link"); printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); - printf (" %s\n", "-f, --onredirect="); + printf (" %s\n", "-f, --onredirect="); printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the")); - printf (" %s\n", _("specified IP address")); + printf (" %s\n", _("specified IP address. stickyport also ensure post stays the same.")); printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));