Commit graph

249 commits

Author SHA1 Message Date
Alvar Penning
8bc1d57a73
check_http: Abort invalid SSL w/ error
If a SSL connection cannot be established, check_http bailed out with a
die function call with a NULL fmt string. This adds a more meaningful
message.

The motivation for this patch was to get everything from the OpenBSD
ports upstream. It seems like in the old days, this would have resulted
in a segfault.

b8a6b3cae5

However, even if "die" now checks for NULL, a human readable error is
nice to have.
2025-12-11 22:27:12 +01:00
Lorenz Kästle
75f04ab4b0 check_http: formatting + no-brainer linter fixes 2025-09-09 15:20:29 +02:00
Jan Wagner
14169fe5a1 check_http: Adding deprecation text 2025-04-21 10:55:23 +02:00
Andreas Baumann
e445a386f8 check_http: fix documentation for --state-regex 2024-12-27 15:32:24 +01:00
Lorenz Kästle
8955f56de3 check_http: update copyright 2024-10-31 14:48:54 +01:00
Andreas Baumann
f29785f503 check_http/check_curl: added a --regex-state option to change the state of a regex check
from the default CRITICAL to something else (#1213)
2024-04-07 20:01:54 +02:00
Andreas Baumann
4c4031100a check_curl/check_http: clarified format of POST data (#1978) 2024-04-07 19:30:26 +02:00
RincewindsHat
ad864430b0 check_http: Remove self assignment of a variable and add some comments 2023-12-29 00:45:54 +01:00
RincewindsHat
81f3b41651 Fix fallout of the previous changes 2023-10-19 12:20:27 +02:00
RincewindsHat
6972242126 Fixes for compiler warning -Wparentheses 2023-10-16 00:45:33 +02:00
Thoralf Rickert-Wendt
a6802bd5f5
Fix issue #1872 2023-08-08 10:22:53 +02:00
waja
265a7c0ed8
Merge branch 'master' into compiler_warning_part_2 2023-06-28 16:39:27 +02:00
RincewindsHat
f7687d47cb Fixes for -Wimplicit-fallthrough 2023-04-18 00:18:07 +02:00
RincewindsHat
cee364f219 Remove unused variable from check_http 2023-04-18 00:12:58 +02:00
Jan Wagner
0f3703e641 Fix a lot of typos reported by codespell 2023-04-14 18:35:00 +00:00
RincewindsHat
6d3e44d2d8 check_http: Handle chunked encoding without actual content correctly 2023-02-06 11:39:44 +01:00
Lorenz Kästle
d3fbcd1220 check_http: Add space for ending NULL byte in array for chunked encoding 2023-01-30 13:33:46 +01:00
Lorenz Kästle
d9528c265b check_http: Fix memory reallocation error in chunk decoding logic
This patch should fix an error with the way memory reallocation was
used, which resulted in "realloc(): invalid next size".
It is not completely clear to me as to what caused this problem, but
apparently one can not depend handing a pointer to "realloc(3)" and
expect that it still works afterwards, but one should/must use the one
returned by the function.

Also this patch replaces a variable which was used to remember the
position in the array by just computing that from the current values.
2023-01-30 12:45:20 +01:00
RincewindsHat
6ed7a75c3b Reformat a part to increase readability 2023-01-07 18:34:46 +01:00
RincewindsHat
67d1062530 Undo clang formatting 2023-01-07 18:34:46 +01:00
RincewindsHat
029168276f Fix several bug in the implementation of unchunking 2023-01-07 18:34:46 +01:00
RincewindsHat
3e63e61f6a Fix chunked header detection regex 2023-01-07 18:34:46 +01:00
RincewindsHat
1ac8f35301 Fix type of unchunk_content function declaration 2023-01-07 18:34:46 +01:00
RincewindsHat
48d6ef2557 Undo sorting of header file includes, it breaks the build 2023-01-07 18:34:46 +01:00
RincewindsHat
afe92468a5 Implement chunked encoding decoding 2023-01-07 18:34:46 +01:00
RincewindsHat
2c658383d5 Restructure code a bit to put things where they are actually needed 2023-01-07 18:34:46 +01:00
RincewindsHat
d4502f246f Remove legacy comments and add some new ones 2023-01-07 18:34:46 +01:00
RincewindsHat
c0c096d2ef Remove dead code 2023-01-07 18:34:46 +01:00
RincewindsHat
2315f59835 clang format 2023-01-07 18:34:46 +01:00
RincewindsHat
d2a05e0d12 Document process_arguments a little bit better 2023-01-07 18:34:46 +01:00
RincewindsHat
2752f91099 Update copyright 2023-01-07 18:34:46 +01:00
RincewindsHat
698eed58f8 Use real booleans instead of ints 2023-01-07 18:34:46 +01:00
Danijel Tasov
763862a61c make check_http faster with larger files
The current implementation becomes exponentially slower with growing
response size.

See also:

https://github.com/nagios-plugins/nagios-plugins/blob/release-2.4.2/plugins/check_http.c#L1199-L1204

Test:

    $ mkdir web
    $ nohup python3 -m http.server -d web 5080 &
    $ perl -E 'say "0123456789" for (1..2_000_000)' >| web/file.txt
    $ ./check_http.orig  -t 200 -v  -I localhost -p 5080 -u /file.txt > test1.txt
    real    0m26.893s
    user    0m12.661s
    sys     0m14.221s
    $ time ./check_http -t 200 -v  -I localhost -p 5080 -u /file.txt > test2.txt
    real    0m0.038s
    user    0m0.011s
    sys     0m0.027s
    $ diff -u test[12].txt
    --- test1.txt   2022-12-21 14:58:28.720260811 +0100
    +++ test2.txt   2022-12-21 14:58:42.640008604 +0100
    @@ -7,7 +7,7 @@
     STATUS: HTTP/1.0 200 OK
     **** HEADER ****
     Server: SimpleHTTP/0.6 Python/3.9.2
    -Date: Wed, 21 Dec 2022 13:58:01 GMT
    +Date: Wed, 21 Dec 2022 13:58:42 GMT
     Content-type: text/plain
     Content-Length: 22000000
     Last-Modified: Wed, 21 Dec 2022 13:57:58 GMT
    @@ -2000013,4 +2000013,4 @@
     0123456789
     0123456789

    -HTTP OK: HTTP/1.0 200 OK - 22000191 bytes in 26.860 second response time |time=26.860182s;;;0.000000;200.000000 size=22000191B;;;0;
    +HTTP OK: HTTP/1.0 200 OK - 22000191 bytes in 0.016 second response time |time=0.016412s;;;0.000000;200.000000 size=22000191B;;;0;
2022-12-22 10:15:59 +01:00
Lorenz
edc84e5d66
Remove superflous CRLF in HTTP-Requests in check_http (#1798)
* Remove superflous CRLF in HTTP-Requests in check_http
2022-11-05 13:59:45 +01:00
Jan Wagner
8087291729 check_http: Fix HD6 definition 2022-09-18 20:42:26 +02:00
John C. Frickson
e2e405596a I had to make a couple of small changes. 2022-09-18 20:42:26 +02:00
Eric Wunderlin
d57d2b0bdd Remove unused code 2022-09-18 20:42:26 +02:00
Eric Wunderlin
8f54442c68 Added ability to correctly check redirects with reference format //test.server.com/folder
Referenced redirect of the format //www.server.com/folder would result
in check_http trying to contact http://hostname:80//www.server.com/folder
instead of http://www.server.com/folder. Referenced redirect of this format
is listed in rfc3986 ( https://tools.ietf.org/html/rfc3986 ). It should
work as expected now.
2022-09-18 20:42:26 +02:00
Andreas Baumann
455fdc1072 check_http: added option --continue-after-certificate (#1761) 2022-04-10 16:31:47 +02:00
Andreas Baumann
737412f739 check_http and check_curl: added --max-redirs=N option (feature #1684) 2022-01-29 12:15:12 +01:00
Daniel Uhlmann
a1af8be978 changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop 2021-06-24 11:37:14 +02:00
Sven Nierlein
b145ea1998
Merge pull request #1554 from stblassitude/master
Docs check_http: make -C obvious
2021-04-07 17:16:12 +02:00
Sven Nierlein
4ad33d9f27
Merge pull request #1566 from hydrapolic/master
plugins: check_http: Increase regexp limit
2021-04-07 17:15:20 +02:00
Sven Nierlein
739a7bbe7c
Merge pull request #1514 from Rasp8e/master
Proxy authorization is now kept when using PROXY + CONNECT to HTTPS
2020-09-23 17:19:23 +02:00
Tobias Wolf
f7f0f7d467 Also support the --show-body/-B flag when --expect is used 2019-02-12 13:01:23 +01:00
Tomas Mozes
0a58acc705
plugins: check_http: Increase regexp limit 2018-12-05 12:50:53 +01:00
Tobias Wolf
9966ebcd84 Add new flag --show-body/-B to print body
This should help with figuring out ia problem at a glance when enabled for
healthz endpoints on web APIs, for example.

The content of the body can point to what the problem is and help with
diagnostics.

Fixes #1559
2018-11-09 23:48:56 +01:00
Markus Frosch
d659f8d99f Allow user to specify HTTP method after proxy CONNECT
Simple format, avoids refactoring the CONNECT feature.
2018-11-06 11:32:27 +01:00
Stefan Bethke
22c00bbe47 Docs check_http: make -C obvious
You need to read the docs carefully to realize that check_http has two 
modes of operation: the regular HTTP checks, and a TLS certificate 
check. Only one of these can be run in a single invocation.

Fixes #1553
2018-10-10 00:40:07 +02:00
Rasp8e
09a2210c47 Adding Proxy-Authorization and extra headers in the case of connection through PROXY to HTTPS 2017-10-17 15:19:43 +02:00