Commit graph

1892 commits

Author SHA1 Message Date
RincewindsHat
280ae58ed8 Remove spaces from tests 2021-09-26 00:34:44 +02:00
rincewind
4621427ba8 check_swap: Fix perfdata und thresholds for big values and simplify code
The original problem was https://github.com/monitoring-plugins/monitoring-plugins/pull/1705
where the performance data output of check_swap did not conform to
the parser logic of a monitoring system (which decided to go for
"correct" SI or IEC units.
The PR was accompanied by a change to byte values in the performance
data which broke the _perfdata_ helper function which could not handle
values of this size.
The fix for this, was to use _fperfdata_ which could, but would
use float values.

I didn't like that (since all values here are discreet) and this
is my proposal for a fix for the problem.

It introduces some helper functions which do now explicitely work
with (u)int64_t, including a special version of the _perfdata_ helper.

In the process of introducing this to check_swap, I stumbled over
several sections of the check_swap code which I found problematic.
Therefore I tried to simplify the code and make it more readable
and less redundant.

I am kinda sorry about this, but sincerely hope my changes can
be helpful.
2021-09-25 23:24:45 +02:00
rincewind
66e2453759 Introduce new perfdata functions and stuff for using (u)int64_t 2021-09-25 23:24:34 +02:00
Jonny007-MKD
cfc43a3275 Improvements suggested by tobiaswiese 2021-09-02 09:56:39 +02:00
Jonny007-MKD
2056c58531 check_dns: Fix memory leak 2021-09-02 09:56:39 +02:00
Jonny007-MKD
70f55ca9db check_dns: add --expect-nxdomain 2021-09-02 09:56:39 +02:00
Sven Nierlein
e17c1e9ed9
Merge pull request #1388 from waja/check_proc_consumption_1357
check_disk: Fixing the stuff that is broken on btrfs
2021-08-24 09:05:01 +02:00
Andreas Baumann
67088216ab Merge branch 'master' into feature_check_curl 2021-07-28 19:17:46 +02:00
Andreas Baumann
de5503063e check_curl: fixed a potential buffer overflow in retir/uri_string 2021-07-25 18:49:06 +02:00
Andreas Baumann
3f5c54c783 check_curl: fixed DNS caching for SSL hostnames (avoid CURLOPT_RESOLVE entry errors) 2021-07-25 18:39:07 +02:00
Sven Nierlein
e72ff30017
Merge pull request #1690 from xFuture603/change_state_from_infinite_redirect_loop
check_http: changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop
2021-07-08 11:31:56 +02:00
Andreas Baumann
6e696643a5 check_curl: changed to STATE_CRITICAL for infinite loops (-ffollow) 2021-07-04 18:43:42 +02:00
Lorenz Kästle
6e5ee70d07 Let ssh decide if a host is valid, enables usage of ssh .config file 2021-06-25 12:12:48 +02:00
Andreas Baumann
0b6838ffca fix for missing X509_up_ref on old systems with only OpenSSL 1.0 2021-06-24 17:08:20 +00:00
Daniel Uhlmann
a1af8be978 changed 'STATE_CRITICAL' to 'STATE_WARNING' for infinite loop 2021-06-24 11:37:14 +02:00
Andreas Baumann
20e9451fad added option --enable-automatic-decompression 2021-06-24 11:02:28 +02:00
Andreas Baumann
beb609ffcf check_curl:
- added verbose output in verify_callback
- pin refcounting for certs (avoid subject extraction error when checking
  certs in is_openssl_callback mode)
2021-05-27 15:32:08 +02:00
Barak Shohat
63cb7ecfcf check_curl.c: bugfix: verify certificates option should not force SSL to be used 2021-05-24 14:53:58 +03:00
Sven Nierlein
b428cc17f7 tests: ignore sigpipes in https test daemon
check_http closes the connection after checking the certificate with -C. This leads to sigpipe
errors when the ssl daemon wants to send a response and the daemon quits which makes the
subsequent tests fail.
2021-05-20 20:57:59 +02:00
Sven Nierlein
eb75d847ae tests: increase startup sleep
github action might fail from to time otherwise
2021-05-20 18:04:49 +02:00
Jacob Hansen
0bbcb60f02
Refactor check_fping
* Set correct amount of tests based on conditionals.
* When running the test as non-root, we would previously check is the
setuid bit is set. This doesn't seem to be needed, so just check if the
binary is executable for the user running the test.
* Use cmp_ok to check if tests succeeds rather than couting.

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2021-05-19 13:36:04 +02:00
Jacob Hansen
ae2fe683e3
check_curl.t: Adjust test to use -f curl
It appears that `-f follow` doesn't work correctly in `check_curl` at
the moment. Test adjusted to use `-f curl` instead.

Issue for the above created: https://github.com/monitoring-plugins/monitoring-plugins/issues/1685

Signed-off-by: Jacob Hansen <jhansen@op5.com>
2021-05-18 15:19:43 +02:00
Aksel Sjögren
5ab03a7095
Fix conditional tests for check_http, check_curl
Set correct number of tests in skip- blocks to avoid the error "Bad
plan.  You planned 50 tests but ran 55" when run with/without
/usr/bin/faketime and NP_INTERNET_ACCESS=yes/no.
2021-04-30 11:13:59 +02:00
Sven Nierlein
fc71e3f930 migrate travis ci to github actions 2021-04-30 09:56:52 +02:00
Sven Nierlein
444a3579b2 fix fping test
in case of dns errors, fping returns an unknown and thats ok.
2021-04-30 09:56:52 +02:00
Barak Shohat
f0ac7fcc7c check_curl: Fix bug where headers beginning with HTTP_ cause the status line parsing to fail. 2021-04-13 12:06:18 +02:00
Andreas Baumann
cd358cd08a check_curl: backported --show-body/-B to print body (from check_http) 2021-04-08 20:39:48 +02:00
Andreas Baumann
1debd29b57 check_curl: make -C obvious (from check_http, part 2) 2021-04-08 15:14:53 +02:00
Andreas Baumann
a6acea7941 check_curl: make -C obvious (from check_http) 2021-04-08 14:15:54 +02:00
Andreas Baumann
f90aec83cb check_curl: Increase regexp limit (to 1024 as in check_http) 2021-04-08 14:07:20 +02:00
Sven Nierlein
f6fd14e886
Merge pull request #1669 from bazzisoft/verify-cert
Add an option to check_curl to verify the peer certificate & host using the system CA's
2021-04-07 17:51:38 +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
de7effdf06
Merge pull request #1465 from lausser/master
check_snmp: put the "c" (to mark a counter) after the perfdata value
2021-04-07 17:12:38 +02:00
waja
7ac706e894
Merge pull request #1663 from waja/debian_982847_2
Using snprintf which honors the buffers size and guarantees null temination. (Closes: #1601)
2021-04-07 16:45:59 +02:00
Barak Shohat
6993c21695 Add an option to check_curl to verify the peer certificate & host using the system CA's 2021-04-07 15:38:47 +03:00
Sven Nierlein
1033724797
Merge pull request #1668 from bazzisoft/master
Update check_curl.c to display a specific human-readable error message where possible
2021-04-07 11:49:10 +02:00
Barak Shohat
2482950e26 Updated check_curl.c to display a specific human-readable error message where possible 2021-04-07 12:36:55 +03:00
Sven Nierlein
2e5b38cc83
Merge pull request #1666 from sni/check_curl_fix_header_parser
fix check_curl crash if http header contains leading spaces
2021-04-07 10:30:31 +02:00
Sven Nierlein
b820725ee1
Merge pull request #1644 from ghciv6/check_mysql_query_1562
- fix for issue #1562
2021-04-07 09:25:15 +02:00
Sven Nierlein
5cfc93d995 fix check_curl crash if http header contains leading spaces
check_curl crashes when a (broken) http server returns invalid http header with
leading spaces or double colons. This PR adds a fix and a test case for this.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2021-03-11 13:33:16 +01:00
Andreas Baumann
0f926a3566 check_curl: added string_statuscode function for printing HTTP/1.1 and HTTP/2 correctly 2021-03-08 19:46:43 +01:00
Florian Lohoff
dae075e65a Using snprintf which honors the buffers size and guarantees null termination. (Closes: #1601)
As strcpy may overflow the resulting buffer:

flo@p5:~$ /tmp/f/usr/lib/nagios/plugins/check_pgsql -d "$(seq 1 10000)"
*** buffer overflow detected ***: terminated
Aborted

I would propose to change the code rather like this, using snprintf
which honors the buffers size and guarantees null termination.
2021-02-15 15:34:07 +01:00
Andreas Baumann
a260c798de Merge branch 'master' into feature_check_curl 2021-02-08 20:13:47 +01:00
Andreas Baumann
d9a5d1faf0 check_curl: fixed a potential buffer overflow in url buffer 2021-01-19 18:35:41 +01:00
Andreas Baumann
ede8defad4 check_curl: fixed help, usage and errors for TLS 1.3 2021-01-19 18:32:27 +01:00
Wolfgang Karall-Ahlborn
9076ea36f7 check_procs -- update test data too 2021-01-03 12:18:31 +01:00
Wolfgang Karall-Ahlborn
8eaccee190 check_procs -- exchange needle and haystack in strstr() for proper state match 2021-01-03 11:27:44 +01:00
Rolf Eike Beer
ad99755033
check_dns: split multiple IP addresses passed in one -a argument 2020-11-02 20:05:56 +01: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
ghciv6
b8b87b55d6 - fix for issue #1562
1st compare then free up resources
2020-09-15 21:36:27 +02:00
mdavranche
11af74de38 check_swap: Handle cached swap 2020-08-18 15:37:38 -04:00
ghciv6
905b09c38b detect unreachable dns service in nslookup output (from bind-utils-9.8.2)
prevent core if error_scan detects an error in a line without ':'
2020-05-20 23:02:42 +02:00
Sven Nierlein
772fb233b9 check_curl: host_name may be null
for example when using like: ./check_curl localhost
2020-05-18 14:08:45 +02:00
Sven Nierlein
7d2582deb3 update test parameter according to check_http 2020-05-18 14:08:27 +02:00
Sven Nierlein
84fd9ae893 check_curl: use CURLOPT_RESOLVE to fix connecting to the right ip
when using ssl, the composed url contains the hostname instead of the specified
ip. So use CURLOPT_RESOLVE to make curl still connect to the ip.
2020-05-18 13:43:17 +02:00
Sven Nierlein
8a64e47083 check_curl: clean trailing whitespace 2020-05-18 11:30:34 +02:00
Sven Nierlein
d54f14a092 merge test changes from check_http
the example certificate has changed since.
2020-05-15 14:24:18 +02:00
Sven Nierlein
072e97d5de tests: update expired test certificate
the certificate used to test expired http checks is to old to be used
with recent ssl libraries and results in:

> SSL routines:SSL_CTX_use_certificate:ee key too small

unfortunatly the error is only visible when setting $IO::Socket::SSL::DEBUG in
the check_http.t file.
2020-05-15 14:24:18 +02:00
Andreas Baumann
adb9588494 Merge branch 'master' into feature_check_curl 2020-01-09 14:54:12 +01:00
Alexander A. Klimov
f53ea7afd8 check_tcp: add --sni 2020-01-07 21:32:15 +01:00
Christian Tacke
9da7cd7681 Fix timeout_interval declarations
There are different declarations for timeout_interval:

lib/utils_base.c has the definition:
	unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
lib/utils_base.h has the appropiate declaration:
	extern unsigned int timeout_interval;

plugins/popen.h has an extra declaration:
	extern unsigned int timeout_interval;
This doesn't hurt, but it's a dupe. The one in utils_base.h
should be enough, so remove this one.

plugins/popen.c has a WRONG one:
	extern int timeout_interval;
Remove it!
Use #include "utils.h" to get the right one.
This makes the local defines for max/min unnecassary, so
remove them also.
2020-01-07 10:22:39 +01:00
Andreas Baumann
5e0c236d6a increased copyright 2019-12-29 10:23:02 +00:00
Andreas Baumann
1b689dab5e check_curl: NSS, parse more date formats from certificate (in -C cert check) 2019-11-07 15:31:52 +00:00
Andreas Baumann
f7efee5f9c check_curl: more tolerant CN= parsing when checking certificates (hit on Centos 8) 2019-11-07 08:20:17 +00:00
Andreas Baumann
ede43c848d setting no_body to TRUE when we have a HEAD request 2019-10-11 17:22:34 +02:00
Andreas Baumann
04c58e0210 some LIBCURL_VERSION checks around HTTP/2 feature 2019-09-07 16:06:17 +02:00
Andreas Baumann
f546041722 added --http-version option to check_curl to choose HTTP version 2019-09-07 15:58:09 +02:00
Andreas Baumann
95ee6ace09 improved curlhelp_parse_statusline to handle both HTTP/1.x and HTTP/2 2019-09-07 15:31:15 +02:00
Andreas Baumann
fe91deb40c check_curl: updates embedded picohttpparser to newest git version 2019-09-07 14:22:00 +02:00
Andreas Baumann
4d666514f2 setting progname of check_curl plugin to check_curl (at least for now) 2019-09-07 11:20:13 +02:00
Andreas Baumann
34cc70c3c6 Merge branch 'master' into feature_check_curl 2019-07-18 08:40:35 +02:00
Sven Nierlein
e8325b39c4 fix maxfd being zero
If _SC_OPEN_MAX is available then maxfd was zero initialized and never set to the value from sysconf.
This leads to segfaults with free(): invalid size introduced by commit 7cafb0e845.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-05-24 14:51:10 +02:00
Christopher Odenbach
a15d425598 include -P switch in help 2019-04-09 09:49:57 +02:00
Andreas Baumann
2f4d6764d7 Merge branch 'master' into feature_check_curl 2019-04-04 13:09:15 +02:00
Sven Nierlein
5f16ba81c4
Merge pull request #1491 from odenbach/no_swap
check_swap: repaired "-n" behaviour
2019-03-28 16:55:22 +01:00
Sven Nierlein
71582d8bf9
Merge pull request #1586 from computersalat/master
improve command examples for 'at least' processes
2019-03-21 17:43:55 +01:00
ChrisWi
a58ea5ec5d improve command examples for 'at least' processes 2019-03-21 14:18:37 +01:00
Robin Sonefors
2bc4cc99d2 check_mysql: Allow sockets to be specified to -H
The help text says that -H accepts a "unix socket (must be an absolute
path)". Now that actually corresponds to reality.

Signed-off-by: Robin Sonefors <robin.sonefors@op5.com>
2019-03-21 13:54:19 +01:00
Sven Nierlein
97bb142b14
Merge pull request #1506 from sanchezfauste/check_apt_parameters
Adding packages-warning option to check_apt plugin
2019-02-19 22:10:07 +01:00
Sven Nierlein
af8e68d140
Merge pull request #1507 from sanchezfauste/check_load_print_top_procs
Adding print top consuming processes option to check_load
2019-02-19 22:08:04 +01:00
Sven Nierlein
e5823c7ae4
Merge pull request #1527 from m-kraus/master
check_snmp: make calcualtion of timeout value in help output more clear
2019-02-19 21:58:03 +01:00
Sven Nierlein
555559fd30
Merge pull request #1567 from vdanjean/master
[check_disk] add support to display inodes usage in perfdata
2019-02-19 21:49:13 +01:00
Sven Nierlein
931ed78b5d
Merge pull request #1583 from sni/fix_check_by_ssh_timeout_child_leak
check_by_ssh: fix child process leak on timeouts
2019-02-19 21:42:02 +01:00
Sven Nierlein
8442ed5b41 renew test certificates
Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-02-19 16:35:28 +01:00
Rolf Eike Beer
763eb740b3 check_dns: fix typo in parameter description 2019-02-15 17:31:29 +01:00
Sven Nierlein
7cafb0e845 check_by_ssh: fix child process leak on timeouts
When check_by_ssh runs into a timeout it simply exits keeping all child processes running.
Simply adopting the kill loop from runcmd_timeout_alarm_handler() fixes this.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-02-15 10:36:28 +01:00
Sven Nierlein
2962148d8b
Merge pull request #1582 from towolf/show_body_for_http_expect_case
Also support the --show-body/-B flag when --expect is used
2019-02-15 09:02:43 +01:00
Sven Nierlein
8f1d3de0b7
Merge pull request #1545 from DerDakon/dns_order
check_dns: improve support for checking multiple addresses
2019-02-15 09:00:45 +01:00
Tobias Wolf
f7f0f7d467 Also support the --show-body/-B flag when --expect is used 2019-02-12 13:01:23 +01:00
Jan Wagner
2dcfbbcad0 travis-ci: Use RSA keys for SSH tests 2019-02-04 14:24:29 +01:00
Sven Nierlein
22f47fc0c5 tests: make check_snmp test more reliable
The check_snmp rate tests depend on the exact amount of time spend between the
plugin runs and will fail on busy machines, ex. the ci servers. Using faketime
mitigates this issue and also removes all the sleeps.

Signed-off-by: Sven Nierlein <sven@nierlein.de>
2019-01-21 17:41:02 +01:00
Iustin Pop
8520c643dd Simply initializes n before it is used
When SSL is enabled, n is assigned the size of the server's second EHLO
response (I think in bytes), which will usually be significantly higher
than the command passed. As such, no commands are executed and no responses
are checked, which - silently - defeats the desired checks and results in a
success value.
2019-01-18 22:52:54 +01:00
Kostyantyn Hushchyn
f79f016238 check_hpjd: Added -D option to disable warning on 'out of paper'
Signed-off-by: Kostyantyn Hushchyn <kgushtin@op5.com>
2019-01-04 15:01:28 +01:00
Vincent Danjean
270e7cba38 [check_disk] add support to display inodes usage in perfdata
This is not enabled by default
It can be enabled with the -P (--iperfdata) option
2018-12-08 22:44:42 +01:00
Sven Nierlein
ac6f101f05
Merge pull request #1564 from jacobbaungard/check_cluster_arg_validation
check_cluster.c: Added data argument validation.
2018-12-07 17:35:58 +01:00
Tomas Mozes
0a58acc705
plugins: check_http: Increase regexp limit 2018-12-05 12:50:53 +01:00
Sven Nierlein
d7dcca22ae tests: rework test parameters
there were 2 variants of calling getTestParameter:

    - parameter, description, default value
    - parameter, env value, default value, description, scope

While scope was never actually used and having 2 names for the same value led
to having 2 different entries in the cache file for the same configuration.

This commit removes the variants and simplifies tests parameters by only using
the first 3 parameter variant.
2018-12-04 15:20:19 +01:00
Kostyantyn Hushchyn
910894a4e2 check_cluster.c: Added data argument validation.
Signed-off-by: Kostyantyn Hushchyn <kgushtin@op5.com>
2018-11-29 16:37:59 +01:00
Andreas Baumann
faea5899ba set hostname in for CURLOPT_CURL to virtual hostname in case of SSL (for SNI to work) 2018-11-12 10:25:08 -05:00