check_http: new force http 1.0 option
Leandro Piccilli <[email protected]>
| Newsgroups | gmane.network.nagios.plugins.devel |
|---|---|
| Message-ID | <CAMRvqdZ4Gt19LkcRdk6Qga_ni73C2q-H0qZK0Na=LDPC475T0Q@mail.gmail.com> |
Hi, I've upgraded to latest nagios-plugins version and since I noticed issues with check_http on some specific servers. I was able to track down those issues to this patch: https://github.com/nagios-plugins/nagios-plugins/commit/16030bc497668f36b53982192f67a60d0c8d18a4 Basically, I do need to use the -H option due to vhost configuration on the servers, but for some unknown reason the servers are not happy with the request using HTTP 1.1. Thus I created this attached patch in order to give an option to force the old (incorrect) behavior of sending HTTP 1.0 request instead. As more people can suffer from the same issues after an upgrade it might make sense to have it (or something similar) in the main branch. Regards, Leandro ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________________ Nagios Plugin Development Mailing List Nagiosplug-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel ::: Please include plugins version (-v) and OS when reporting any issue. ::: Messages without supporting info will risk being sent to /dev/null
check_http.patch
(application/octet-stream, 2.6 KB)
--- nagios-plugins-nagios-plugins-f091d59/plugins/check_http.c 2012-06-13 03:36:42.000000000 +0200
+++ nagios-plugins-1.4.15.new/plugins/check_http.c 2012-06-13 16:24:02.000000000 +0200
@@ -115,6 +115,7 @@
int use_ssl = FALSE;
int use_sni = FALSE;
int verbose = FALSE;
+int force_http10 = FALSE;
int sd;
int min_page_len = 0;
int max_page_len = 0;
@@ -181,7 +182,8 @@
enum {
INVERT_REGEX = CHAR_MAX + 1,
- SNI_OPTION
+ SNI_OPTION,
+ FORCE_HTTP10
};
int option = 0;
@@ -213,6 +215,7 @@
{"content-type", required_argument, 0, 'T'},
{"pagesize", required_argument, 0, 'm'},
{"invert-regex", no_argument, NULL, INVERT_REGEX},
+ {"force-http-1.0", no_argument, NULL, FORCE_HTTP10},
{"use-ipv4", no_argument, 0, '4'},
{"use-ipv6", no_argument, 0, '6'},
{0, 0, 0, 0}
@@ -401,6 +404,9 @@
case INVERT_REGEX:
invert_regex = 1;
break;
+ case FORCE_HTTP10:
+ force_http10 = 1;
+ break;
case '4':
address_family = AF_INET;
break;
@@ -818,7 +824,10 @@
}
#endif /* HAVE_SSL */
- asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, host_name ? "HTTP/1.1" : "HTTP/1.0", user_agent);
+ if (force_http10)
+ asprintf (&buf, "%s %s %s\r\n%s\r\n", http_method, server_url, "HTTP/1.0", user_agent);
+ else
+ 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);
@@ -1363,7 +1372,9 @@
printf (" %s\n", _("Warn if document is more than SECONDS old. the number can also be of"));
printf (" %s\n", _("the form \"10m\" for minutes, \"10h\" for hours, or \"10d\" for days."));
printf (" %s\n", "-T, --content-type=STRING");
- printf (" %s\n", _("specify Content-Type header media type when POSTing\n"));
+ printf (" %s\n", _("specify Content-Type header media type when POSTing"));
+ printf (" %s\n", "--force-http-1.0");
+ printf (" %s\n", _("Force sending request using HTTP/1.0 (nagios-plugins < 1.4.13 behavior)\n"));
printf (" %s\n", "-l, --linespan");
printf (" %s\n", _("Allow regex to span newlines (must precede -r or -R)"));
@@ -1445,5 +1456,7 @@
printf (" [-e <expect>] [-s string] [-l] [-r <regex> | -R <case-insensitive regex>]\n");
printf (" [-P string] [-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>]\n");
printf (" [-A string] [-k string] [-S <version>] [--sni] [-C <age>] [-T <content-type>]\n");
- printf (" [-j method]\n");
+ printf (" [-j method] [--force-http-1.0] \n");
}
+
+