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.c22
1 files changed, 15 insertions, 7 deletions
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";
44#include <ctype.h> 44#include <ctype.h>
45 45
46#define INPUT_DELIMITER ";" 46#define INPUT_DELIMITER ";"
47#define STICKY_NONE 0
48#define STICKY_HOST 1
49#define STICKY_PORT 2
47 50
48#define HTTP_EXPECT "HTTP/1." 51#define HTTP_EXPECT "HTTP/1."
49enum { 52enum {
@@ -106,7 +109,7 @@ int display_html = FALSE;
106char **http_opt_headers; 109char **http_opt_headers;
107int http_opt_headers_count = 0; 110int http_opt_headers_count = 0;
108int onredirect = STATE_OK; 111int onredirect = STATE_OK;
109int followsticky = 0; 112int followsticky = STICKY_NONE;
110int use_ssl = FALSE; 113int use_ssl = FALSE;
111int verbose = FALSE; 114int verbose = FALSE;
112int sd; 115int sd;
@@ -300,10 +303,12 @@ process_arguments (int argc, char **argv)
300 server_port = HTTPS_PORT; 303 server_port = HTTPS_PORT;
301 break; 304 break;
302 case 'f': /* onredirect */ 305 case 'f': /* onredirect */
306 if (!strcmp (optarg, "stickyport"))
307 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT;
303 if (!strcmp (optarg, "sticky")) 308 if (!strcmp (optarg, "sticky"))
304 onredirect = STATE_DEPENDENT, followsticky = 1; 309 onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST;
305 if (!strcmp (optarg, "follow")) 310 if (!strcmp (optarg, "follow"))
306 onredirect = STATE_DEPENDENT, followsticky = 0; 311 onredirect = STATE_DEPENDENT, followsticky = STICKY_NONE;
307 if (!strcmp (optarg, "unknown")) 312 if (!strcmp (optarg, "unknown"))
308 onredirect = STATE_UNKNOWN; 313 onredirect = STATE_UNKNOWN;
309 if (!strcmp (optarg, "ok")) 314 if (!strcmp (optarg, "ok"))
@@ -1203,15 +1208,18 @@ redir (char *pos, char *status_line)
1203 free (host_name); 1208 free (host_name);
1204 host_name = strdup (addr); 1209 host_name = strdup (addr);
1205 1210
1206 if (followsticky == 0) { 1211 if (!(followsticky & STICKY_HOST)) {
1207 free (server_address); 1212 free (server_address);
1208 server_address = strdup (addr); 1213 server_address = strdup (addr);
1209 } 1214 }
1215 if (!(followsticky & STICKY_PORT)) {
1216 server_port = i;
1217 }
1210 1218
1211 free (server_url); 1219 free (server_url);
1212 server_url = url; 1220 server_url = url;
1213 1221
1214 if ((server_port = i) > MAX_PORT) 1222 if (server_port > MAX_PORT)
1215 die (STATE_UNKNOWN, 1223 die (STATE_UNKNOWN,
1216 _("HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"), 1224 _("HTTP UNKNOWN - Redirection to port above %d - %s://%s:%d%s%s\n"),
1217 MAX_PORT, server_type, server_address, server_port, server_url, 1225 MAX_PORT, server_type, server_address, server_port, server_url,
@@ -1343,9 +1351,9 @@ print_help (void)
1343 printf (" %s\n", _(" Any other tags to be sent in http header. Use multiple times for additional headers")); 1351 printf (" %s\n", _(" Any other tags to be sent in http header. Use multiple times for additional headers"));
1344 printf (" %s\n", "-L, --link"); 1352 printf (" %s\n", "-L, --link");
1345 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)")); 1353 printf (" %s\n", _("Wrap output in HTML link (obsoleted by urlize)"));
1346 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky>"); 1354 printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");
1347 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the")); 1355 printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the"));
1348 printf (" %s\n", _("specified IP address")); 1356 printf (" %s\n", _("specified IP address. stickyport also ensure post stays the same."));
1349 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>"); 1357 printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
1350 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)")); 1358 printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));
1351 1359