Commit graph

2829 commits

Author SHA1 Message Date
Lorenz Kästle
cd7698a419 check_mrtgtraf: modern output implementation 2025-11-27 07:35:29 +01:00
Lorenz Kästle
326d399624 check_mrtg: implement modern output 2025-11-26 14:35:21 +01:00
Lorenz Kästle
317ee266a8 Add output formatting option where they were forgotten 2025-11-26 13:57:12 +01:00
Lorenz Kästle
dccc974e45 check_ldap: fix thresholds for number of entries 2025-11-25 13:48:01 +01:00
Lorenz Kästle
94642b3171 check_ldap: add number of entries perfdata 2025-11-25 13:47:47 +01:00
Lorenz Kästle
d6c4b799e3 check_ldap: implement output format selection 2025-11-25 12:42:50 +01:00
Lorenz Kästle
2e3dff775d check_ldap: fix typo 2025-11-25 12:37:42 +01:00
Lorenz Kästle
07d3eb9e2c check_ldap: modern output implementation 2025-11-25 12:31:00 +01:00
Lorenz Kästle
584272e97d check_by_ssh: fix some tests 2025-11-16 15:33:11 +01:00
Lorenz Kästle
c3d931fa1a check_by_ssh: some formatting 2025-11-16 15:27:58 +01:00
Lorenz Kästle
62242ddcf5 check_by_ssh: do not incorrectly assume that ssh (1) succeeded 2025-11-16 15:27:19 +01:00
Lorenz Kästle
463223790c check_by_ssh: handle errrors of ssh (1) directly 2025-11-16 14:52:07 +01:00
Lorenz Kästle
e77ce530c4 check_by_ssh: Implement modern output functionality 2025-11-16 14:36:10 +01:00
Lorenz Kästle
7bfb16e0da Implement replacement functions for executing commands
This commit implements replacement functions for the previous
exec functions.
The replacements are implemented in a more "pure" style, the do no
longer receive pointer arguments which they will write to, but create
the pointers themselves and should therefore be easier to use,
since it is more obvious what goes in and what comes out.

Also a essentialy unused variable was removed with this.
2025-11-16 14:26:41 +01:00
Lorenz Kästle
bc2720abdd check_smtp: certificate check is no longer opt-in
This is a breaking change.
Testing whether a TLS certificate is still valid (expiration wise)
is now the default in check_smtp.
The reasoning is, that in most scenarios an expired certificate
will effectively mean that the service is not working anymore due to
the refusal of other software to talk to it.

There is a new cli parameter though to explicitly ignore that.
2025-11-09 11:46:36 +01:00
Lorenz Kästle
62035adf6c check_smtp: implement output format cli parameter 2025-11-09 11:32:43 +01:00
Lorenz Kästle
4442ea917b small test correction 2025-11-08 02:10:45 +01:00
Lorenz Kästle
034d4ee158 Fix initialisation on old compilers 2025-11-08 00:59:46 +01:00
Lorenz Kästle
e0b1273127 check_smtp: adapt tests 2025-11-08 00:46:37 +01:00
Lorenz Kästle
6bc9e518b2 check_smtp: modern output + some tls cert helper functions 2025-11-08 00:19:25 +01:00
Lorenz Kästle
5bbfd58105 Fix typo 2025-11-07 15:10:39 +01:00
Lorenz Kästle
9d827acbe1 check_mysql_query: implement modern output 2025-11-07 15:01:36 +01:00
Lorenz Kästle
b5e7f4e6cc
Merge pull request #2174 from RincewindsHat/modern_output/check_mysql
Modern output/check mysql
2025-11-07 14:15:26 +01:00
Lorenz Kästle
ca3acbe274
Merge pull request #2168 from RincewindsHat/refactor/check_dbi
check_dbi: new output functionality
2025-11-07 14:14:55 +01:00
Lorenz Kästle
0fb65a3a90 check_mysql: implement modern output 2025-11-07 13:31:42 +01:00
Lorenz Kästle
b6150cded1 check_mysql: replace cpp constant with a proper enum 2025-11-06 10:08:02 +01:00
Lorenz Kästle
36ac312e07 fix typos 2025-11-05 14:01:31 +01:00
Lorenz Kästle
8a71cf947f check_pgsql: implement cli params for output format 2025-11-05 14:01:17 +01:00
Lorenz Kästle
2f0fc05981 check_pgsql: cleanup leftover code 2025-11-05 13:58:48 +01:00
Lorenz Kästle
8e5cb31dc1 Merge branch 'master' into modern_output/check_pgsql 2025-11-05 13:54:43 +01:00
Lorenz Kästle
ba6f903733 check_pgsql: implement modern output 2025-11-05 13:54:04 +01:00
Lorenz Kästle
71e0d5e073 check_ntp_time: add cli option for output format 2025-11-05 12:19:20 +01:00
Lorenz Kästle
8062f83675
Merge pull request #2170 from RincewindsHat/modern_output/check_ntp_peer
Modern output/check ntp peer
2025-11-05 12:14:00 +01:00
Lorenz Kästle
a9b63deedb check_ntp_peer: add cli param to set output format 2025-11-05 12:04:30 +01:00
Lorenz Kästle
99351f0560 check_ntp_peer: fix several missing things and errors 2025-11-05 11:58:59 +01:00
Lorenz Kästle
37536c1af9
Merge pull request #2171 from RincewindsHat/modern_output/check_ntp_time
check_ntp_time: implement modern output
2025-11-05 10:55:10 +01:00
Lorenz Kästle
7b226257b7 check_ntp_time: reduce number of significant bits a bit 2025-11-05 10:42:43 +01:00
Lorenz Kästle
cadcfaecbe check_ntp_time: fix time-offset argument and description 2025-11-05 10:42:12 +01:00
Lorenz Kästle
16daa06e43 check_ntp_time: actually accept offset if known 2025-11-05 10:41:34 +01:00
Lorenz Kästle
4191aa46a2 put includes before any declarations 2025-11-04 12:15:20 +01:00
Lorenz Kästle
b207ac3b0a remove cpp constant and localize that value instead 2025-11-04 12:14:36 +01:00
Lorenz Kästle
697374af93 Forgot to actually set thresholds 2025-11-04 12:11:24 +01:00
Lorenz Kästle
b35853ee4e check_ntp_time: implement modern output 2025-11-04 12:08:59 +01:00
Lorenz Kästle
6392a0f776 check_ntp_peer: implement new output functionality 2025-11-04 10:13:39 +01:00
Lorenz Kästle
e867c2ebd3 check_ntp_peer: small refactoring 2025-10-31 18:13:32 +01:00
Lorenz Kästle
0c70af5fef check_dbi: more refactoring for coherence and simplification 2025-10-30 23:58:38 +01:00
Lorenz Kästle
6abf609ed9 add some comments to explain changed code 2025-10-30 22:23:51 +01:00
Lorenz Kästle
669edf2afc check_curl: accept non standard compliant status line
If the status line from a server ended with '\n' instead
of '\r\n' (defined by RFC 9112), check_curl failed to parse it
and exited with an alarm.
The RFC recommends to be lenient here and this change follows that
suggestion.
2025-10-30 21:34:50 +01:00
Lorenz Kästle
408783f53d check_dbi: add output format parameter 2025-10-29 23:27:31 +01:00
Lorenz Kästle
071de8a73a check_dbi: more refactoring for sanities sake 2025-10-29 23:27:12 +01:00
Lorenz Kästle
b504a6284e Fix spelling errors 2025-10-29 13:08:23 +01:00
Lorenz Kästle
ec5fd11c1d check_dbi: new output functionality 2025-10-29 13:05:55 +01:00
Lorenz Kästle
fafaee5813 Fix some bugs after refactoring 2025-10-18 12:25:44 +02:00
Lorenz Kästle
ce10a6ff37
Merge pull request #2159 from RincewindsHat/check_snmp_remove_useless_headers
check_snmp: remove useless headers
2025-10-06 22:46:59 +02:00
Lorenz Kästle
392c945966 More renaming due to MySQL name chances
Due to MySQL changing several term in Version 8.0.22 the way to
determine the status of replicas has changed.
To adapt to these changes in a517dc614e
check_mysql was modified to adapt to different versions.
Some parts were missed though which results in failures to detect
the replica status properly.

This parts should be contained in this commit.
2025-09-30 14:51:45 +02:00
Lorenz Kästle
5cd31ffa6b check_snmp: remove useless headers 2025-09-26 18:14:44 +02:00
Stuart Henderson
5fb0c08cec fixes check_users build on OpenBSD (without utmpx) 2025-09-26 12:51:42 +01:00
Lorenz Kästle
dbe417bdf9 check_mysql: Assume MySQL server by default (in replica check)
In the Debian Bug tracker (and then Github) a person pointed out,
that a MySQL server does not respond with a hint that is indeed the
MySQL software but only with the version string.
Which makes sense if one assumes to be the only implementation.

This commit changes the behaviour of the Replica check to assume
that the counterpart is a MySQL server if there are not hints that
it is a MariaDB server.
2025-09-26 09:07:18 +02:00
Lorenz Kästle
88f316bb27 check_cluster: new output functionality 2025-09-17 11:25:13 +02:00
Lorenz Kästle
5ce7b57c74
Merge pull request #2151 from oxzi/check_by_ssh-ignore-stderr
check_by_ssh: Ignore output on stderr by default
2025-09-17 11:00:01 +02:00
Lorenz Kästle
e4a32bfb39 Refactoring check_dbi 2025-09-16 14:34:17 +02:00
Lorenz Kästle
1f20998d0c
Merge pull request #2148 from RincewindsHat/refactor/check_apt
Refactor/check apt: implement new output functionality
2025-09-16 14:31:19 +02:00
Lorenz Kästle
dab009654c fix default check state 2025-09-16 14:11:29 +02:00
Lorenz Kästle
c4716ad8d8 Fix check_apt tests 2025-09-16 14:11:13 +02:00
Alvar Penning
88036425d5
check_swap: Fix Build At Least For OpenBSD
Fix build of check_swap for both CHECK_SWAP_SWAPCTL_SVR4 and
CHECK_SWAP_SWAPCTL_BSD build guards.

> $ make check_swap
>   CC       check_swap.d/swap.o
> check_swap.d/swap.c:58:32: error: too few arguments to function call, single argument 'config' was not specified
>    58 |         return getSwapFromSwapctl_BSD();
>       |                ~~~~~~~~~~~~~~~~~~~~~~ ^
> ././check_swap.d/check_swap.h:48:13: note: 'getSwapFromSwapctl_BSD' declared here
>    48 | swap_result getSwapFromSwapctl_BSD(swap_config config);
>       |             ^                      ~~~~~~~~~~~~~~~~~~
> 1 error generated.
> *** Error 1 in [...]/monitoring-plugins/plugins (Makefile:2869 'check_swap.d/swap.o': @echo "  CC   ...)
2025-09-16 00:19:04 +02:00
Alvar Penning
4b3f684d33
check_by_ssh: Ignore output on stderr by default
check_by_ssh no longer returns UNKNOWN if ssh(1) returns data on stderr.
But it can be enforced again by the new "--unknown-on-stderr" option.

---

The default logic of check_by_ssh results in an UNKNOWN state if the
ssh(1) process produces output on stderr. Using the "--skip-stderr=[n]"
option allows ignoring a certain amount of lines or disabling this check
altogether. Furthermore, passing the "--warn-on-stderr" option reduces
the exit code to WARNING.

The "--help" output does not document this behavior, only states that
"--warn-on-stderr" will result in the WARNING, but does not mention the
UNKNOWN by default.

The man page of ssh(1) mentions that debug information is logged to
stderr. This conflicts with the described logic, resulting in
check_by_ssh to go UNKNOWN, unless additional options are set.

Starting with OpenSSH version 10.1, ssh(1) will report warnings to
stderr if the opposite server does not support post-quantum
cryptography, <https://www.openssh.com/pq.html>.

This change, slowly being rolled out throughout the next months/years,
might result in mass-breakages of check_by_ssh.

By introducing a new "--unknown-on-stderr" option, enforcing the prior
default logic of an UNKNOWN state for data on stderr, and ignoring
output on stderr by default, check_by_ssh will continue to work. One
might even argue that this change converges actual implementation and
the documented behavior, as argued above.

---

$ ssh example '/usr/lib/nagios/plugins/check_dummy 0 demo'
** WARNING: connection is not using a post-quantum key exchange algorithm.
** This session may be vulnerable to "store now, decrypt later" attacks.
** The server may need to be upgraded. See https://openssh.com/pq.html
OK: demo

$ echo $?
0

$ ./check_by_ssh -H example -C '/usr/lib/nagios/plugins/check_dummy 0 demo'
OK: demo

$ echo $?
0

$ ./check_by_ssh -H example -C '/usr/lib/nagios/plugins/check_dummy 0 demo' --warn-on-stderr
Remote command execution failed: ** WARNING: connection is not using a post-quantum key exchange algorithm.

$ echo $?
1

$ ./check_by_ssh -H example -C '/usr/lib/nagios/plugins/check_dummy 0 demo' --unknown-on-stderr
Remote command execution failed: ** WARNING: connection is not using a post-quantum key exchange algorithm.

$ echo $?
3

---

Fixes #2147.
2025-09-15 22:20:08 +02:00
Lorenz Kästle
ff7305bdfe Merge branch 'master' into refactor/check_apt 2025-09-15 16:16:14 +02:00
Lorenz Kästle
15ecdb73ce Fix types in check_apt 2025-09-15 16:00:35 +02:00
Lorenz Kästle
811da10fda More refactoring 2025-09-15 15:49:26 +02:00
Lorenz Kästle
802e46f8ea Run clang-format again 2025-09-15 12:59:37 +02:00
Lorenz Kästle
f07f96c3cf check_apt: implement new output 2025-09-15 12:40:24 +02:00
Lorenz Kästle
67c1aae749 check_apt: improve some variable types to make the linter happy 2025-09-15 10:46:22 +02:00
Lorenz Kästle
5a2c1b2c3a Add output formatting option 2025-09-15 02:30:42 +02:00
Lorenz Kästle
eca9eaf9f5 fix number of tests 2025-09-15 02:17:44 +02:00
Lorenz Kästle
c07dd02bee Adapt test to new error message 2025-09-15 02:09:04 +02:00
Lorenz Kästle
43c6332322 Fix typo in error message 2025-09-15 02:08:46 +02:00
Lorenz Kästle
c892db9ae1 Fix typos 2025-09-15 02:02:04 +02:00
Lorenz Kästle
404d52efb9 Fix/adapt tests 2025-09-15 01:58:26 +02:00
Lorenz Kästle
afa81204dc check_curl: use new cert check function 2025-09-15 01:58:07 +02:00
Lorenz Kästle
f5f4a021a2 Add new cert check function 2025-09-15 01:57:40 +02:00
Lorenz Kästle
c15d12cbd5 check_curl: fix perfdata label 2025-09-15 01:57:08 +02:00
Lorenz Kästle
0bf5fdf41e check_curl: finish after cert without continue param 2025-09-15 01:56:46 +02:00
Lorenz Kästle
166ce184c6 Fix regex matching 2025-09-15 00:22:35 +02:00
Lorenz Kästle
def42dc686 Improve error message 2025-09-15 00:22:08 +02:00
Lorenz Kästle
6ae8ba9110 check_curl: test adaption and output adaption 2025-09-13 12:49:06 +02:00
Lorenz Kästle
9afb5e2a69 check_curl: remove display-html option 2025-09-13 12:28:49 +02:00
Lorenz Kästle
44b2a25a6b check_curl: implement new output mechanism 2025-09-12 16:37:24 +02:00
Lorenz Kästle
9c2ae47d44 check_curl: fix default redirect setting 2025-09-12 12:36:00 +02:00
Lorenz Kästle
ad4faf1a9a Fix struct access 2025-09-12 01:59:05 +02:00
Lorenz Kästle
ab66b41d23 check_curl: create outsourced helpers in extra files 2025-09-12 01:14:14 +02:00
Lorenz Kästle
684602ddec check_curl: http3 is only available with libcurl 7.66 or later 2025-09-11 14:44:17 +02:00
Lorenz Kästle
99206dab7a check_curl: refactoring to modularize code 2025-09-11 13:44:55 +02:00
Lorenz Kästle
6969f57192 check_curl: improve option handling a bit 2025-09-11 11:24:16 +02:00
Lorenz Kästle
977e0a7f8b check_curl: fix function signature 2025-09-11 11:14:29 +02:00
Lorenz Kästle
b44cbae7fb check_curl: less global state 2025-09-11 11:11:44 +02:00
Lorenz Kästle
a2ca373e2d sslutils: some refactoring to improve readability 2025-09-10 13:41:46 +02:00
Lorenz Kästle
572ad994b1 plugins-netutils: return proper state from test functions 2025-09-10 13:41:22 +02:00
Lorenz Kästle
c7274d5627 netutils.h: clang-format 2025-09-10 13:40:21 +02:00
Lorenz Kästle
0926e73e0e sslutils.c: clang-format 2025-09-10 13:32:50 +02:00
Lorenz Kästle
4b19852dcc check_curl: remove the other gotos 2025-09-10 12:22:46 +02:00