diff --git a/plugins/check_http.c b/plugins/check_http.c
index e140be01bf79f47dc86bf31ead3393dd39d9e44a..5a859f98774bafa8513cbe64d91bb08fdfd277d2 100644 (file)
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
#include <ctype.h>
#define INPUT_DELIMITER ";"
#include <ctype.h>
#define INPUT_DELIMITER ";"
+#define STICKY_NONE 0
+#define STICKY_HOST 1
+#define STICKY_PORT 2
#define HTTP_EXPECT "HTTP/1."
enum {
#define HTTP_EXPECT "HTTP/1."
enum {
char **http_opt_headers;
int http_opt_headers_count = 0;
int onredirect = STATE_OK;
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;
int use_ssl = FALSE;
int verbose = FALSE;
int sd;
server_port = HTTPS_PORT;
break;
case 'f': /* onredirect */
server_port = HTTPS_PORT;
break;
case 'f': /* onredirect */
+ if (!strcmp (optarg, "stickyport"))
+ onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST|STICKY_PORT;
if (!strcmp (optarg, "sticky"))
if (!strcmp (optarg, "sticky"))
- onredirect = STATE_DEPENDENT, followsticky = 1;
+ onredirect = STATE_DEPENDENT, followsticky = STICKY_HOST;
if (!strcmp (optarg, "follow"))
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"))
if (!strcmp (optarg, "unknown"))
onredirect = STATE_UNKNOWN;
if (!strcmp (optarg, "ok"))
}
#endif /* HAVE_SSL */
}
#endif /* HAVE_SSL */
- asprintf (&buf, "%s %s HTTP/1.0\r\n%s\r\n", http_method, server_url, user_agent);
+ asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
/* tell HTTP/1.1 servers not to keep the connection alive */
asprintf (&buf, "%sConnection: close\r\n", buf);
/* tell HTTP/1.1 servers not to keep the connection alive */
asprintf (&buf, "%sConnection: close\r\n", buf);
#endif
if (sd) close(sd);
#endif
if (sd) close(sd);
- /* reset the alarm */
- alarm (0);
-
/* Save check time */
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;
/* Save check time */
microsec = deltime (tv);
elapsed_time = (double)microsec / 1.0e6;
}
/* server errors result in a critical state */
else if (http_status >= 500) {
}
/* server errors result in a critical state */
else if (http_status >= 500) {
- asprintf (&msg, _("%s - "), msg, status_line);
+ asprintf (&msg, _("%s - "), status_line);
result = STATE_CRITICAL;
}
/* client errors result in a warning state */
result = STATE_CRITICAL;
}
/* client errors result in a warning state */
} /* end else (server_expect_yn) */
} /* end else (server_expect_yn) */
+ /* reset the alarm - must be called *after* redir or we'll never die on redirects! */
+ alarm (0);
+
if (maximum_age >= 0) {
result = max_state_alt(check_document_dates(header, &msg), result);
}
if (maximum_age >= 0) {
result = max_state_alt(check_document_dates(header, &msg), result);
}
/* check elapsed time */
asprintf (&msg,
/* check elapsed time */
asprintf (&msg,
- _("%s - %.3f second response time %s|%s %s"),
- msg, elapsed_time,
+ _("%s - %d bytes in %.3f second response time %s|%s %s"),
+ msg, page_len, elapsed_time,
(display_html ? "</A>" : ""),
perfd_time (elapsed_time), perfd_size (page_len));
(display_html ? "</A>" : ""),
perfd_time (elapsed_time), perfd_size (page_len));
free (host_name);
host_name = strdup (addr);
free (host_name);
host_name = strdup (addr);
- if (followsticky == 0) {
+ if (!(followsticky & STICKY_HOST)) {
free (server_address);
server_address = strdup (addr);
}
free (server_address);
server_address = strdup (addr);
}
+ if (!(followsticky & STICKY_PORT)) {
+ server_port = i;
+ }
free (server_url);
server_url = url;
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,
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,
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", _(" 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=<ok|warning|critical|follow|sticky>");
+ printf (" %s\n", "-f, --onredirect=<ok|warning|critical|follow|sticky|stickyport>");
printf (" %s\n", _("How to handle redirected pages. sticky is like follow but stick to the"));
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)"));
printf (" %s\n", "-m, --pagesize=INTEGER<:INTEGER>");
printf (" %s\n", _("Minimum page size required (bytes) : Maximum page size required (bytes)"));