Commit graph

2655 commits

Author SHA1 Message Date
Lorenz Kästle
87195f5511 check_snmp: refactoring + fixes
This commit moves the state retention logic to check_snmp as it is only
used there and I do not want it to be used at all, so it doesn't get a
place in the lib.

Otherwise this adapts tests and fixes the rate computing in the
refactored version of check_snmp.
Also fixes some bugs detected with the tests
2025-09-08 15:57:06 +02:00
Lorenz Kästle
1aefb1f9df snmp: fix complaint of snmpd about paths 2025-09-08 15:54:08 +02:00
Lorenz Kästle
41d309d438 check_snmp: improve string quoting in result 2025-09-01 11:22:58 +02:00
Lorenz Kästle
a7c6760cfe check_snmp: Small improvements + fix dereference bug 2025-08-30 14:19:06 +02:00
Lorenz Kästle
7f1877f760 check_snmp: Fix number processing (offset + multiplier) 2025-08-30 14:18:42 +02:00
Lorenz Kästle
77a5db04d7 check_snmp: implement output format setting 2025-08-30 14:16:36 +02:00
Lorenz Kästle
1ca5a6040a check_snmp: Make linter happy 2025-08-29 10:50:53 +02:00
Lorenz Kästle
b4d84ebfee check_snmp: Remove options description for input delimiter 2025-08-29 10:42:19 +02:00
Lorenz Kästle
e4c59440f0 Build check_snmp unconditionally 2025-08-28 15:22:04 +02:00
Lorenz Kästle
ebc2415330 check_snmp: fix DES availability detection(?) 2025-08-28 13:14:29 +02:00
Lorenz Kästle
553a230a28 check_snmp: formatting 2025-08-28 11:52:15 +02:00
Lorenz Kästle
f5ad4275ff check_snmp: Test for availability of DES privacy protocol 2025-08-28 11:52:03 +02:00
Lorenz Kästle
bd6cff7f9c check_snmp: use snmp v2c if community is given 2025-08-27 19:54:09 +02:00
Lorenz Kästle
f1104f49a4 Fix one more typo 2025-08-27 19:20:41 +02:00
Lorenz Kästle
78cb7b2288 check_snmp: fix typos 2025-08-27 19:12:56 +02:00
Lorenz Kästle
75f792bc6b check_snmp: declare internal functions static 2025-08-27 16:43:32 +02:00
Lorenz Kästle
faf794b401 check_snmp: remove leftover multiply function 2025-08-27 16:43:11 +02:00
Lorenz Kästle
015e4c0986 check_snmp: fix/adapt tests 2025-08-27 16:42:06 +02:00
Lorenz Kästle
e490c5f969 check_snmp: hopefully fix helpers 2025-08-27 16:41:46 +02:00
Lorenz Kästle
f976155863 check_snmp: Improve error handling 2025-08-27 16:41:02 +02:00
Lorenz Kästle
a27862a9c7 check_snmp: rebuild threshold parsing 2025-08-27 12:17:46 +02:00
Lorenz Kästle
7fe6ac8d08 rebuild check_snmp 2025-08-25 15:28:04 +02:00
Lorenz Kästle
7382fa90f8 Merge branch 'master' into refactor/check_users 2025-08-11 21:54:05 +02:00
Lorenz Kästle
fb39f96ac6 check_users: Use sd_get_uids instead of sd_get_session
Previously check_users in combination with systemd used
sd_get_sessions (3) to aquire the number of users, probably
with the idea that every users opens a session.
Turns out, that a user can have multiple sessions and we only really
want to know how many users there are.

This commit changes to sd_get_uids (3) to achieve that target.
2025-08-11 21:49:20 +02:00
Lorenz Kästle
2757550558 clang-format 2025-08-01 14:35:23 +02:00
Lorenz Kästle
a69dff1522 check_ssh: Put variable in the correct scope 2025-08-01 14:35:13 +02:00
Lorenz Kästle
3c53bf623d check_ssh: Fix format expression 2025-08-01 14:34:29 +02:00
Lorenz Kästle
69925c782b check_ssh: fix data type to allow for error checking 2025-08-01 14:34:01 +02:00
Lorenz Kästle
b05087d9aa
Merge pull request #2133 from rlaager/fix-check_ssh-buffer-overflow
Fix check ssh buffer overflow
2025-08-01 14:27:48 +02:00
Lorenz Kästle
c43135a5e5 check_ntp_peer: fix invalid conversion in printf 2025-07-14 09:37:51 +02:00
Richard Laager
1f2acfd1c6 check_ssh: Correct type on len variable
strlen() returns a size_t.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2025-07-11 18:44:03 -05:00
Richard Laager
661ecff45c check_ssh: Fix buffer overflow
A buffer overflow was occurring when the server responded with:
Exceeded MaxStartups\r\n

glibc would then abort() with the following output:
*** buffer overflow detected ***: terminated

It was the memset() that was overflowing the buffer.  But the memmove()
needed fixing too.

First off, there was an off-by-one error in both the memmove() and
memset().  byte_offset was already set to the start of the data _past_
the newline (i.e. len + 1).  For the memmove(), incrementing that by 1
again lost the first character of the additional output.  For the
memset(), this causes a buffer overflow.

Second, the memset() has multiple issues.  The comment claims that it
was NULing (sic "null") the "rest".  However, it has no idea how long
the "rest" is, at this point.  It was NULing BUFF_SZ - byte_offset + 1.
After fixing the off-by-one / buffer overflow, it would be NULing
BUFF_SZ - byte_offset.  But that doesn't make any sense.  The length of
the first line has no relation to the length of the second line.

For a quick-and-dirty test, add something like this just inside the
while loop:
memcpy(output,
  "Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0",
  sizeof("Exceeded MaxStartups\r\nnext blah1 blah2 blah3 blah4\0"));

And, after the memmove(), add:
  printf("output='%s'\n", output);

If you fix the memset() buffer overflow, it will output:
output='ext blah1 blah2 blah3 '

As you can see, the first character is lost.

If you then fix the memmove(), it will output:
output='next blah1 blah2 blah3'

Note that this is still losing the "blah4".

After moving the memset() after byte_offset is set to the new strlen()
of output, then it works correctly:
output='next blah1 blah2 blah3 blah4'

Signed-off-by: Richard Laager <rlaager@wiktel.com>
2025-07-11 18:43:59 -05:00
Lorenz Kästle
b191a8a055 check_load: fix tests 2025-07-06 23:16:34 +02:00
Lorenz Kästle
92c7b91002 Merge branch 'master' into refactor/check_load 2025-07-06 22:49:04 +02:00
Lorenz Kästle
351b104894 check_load some number type fixes 2025-07-06 22:46:41 +02:00
Lorenz Kästle
b002a6870b check_load: Add top x functionality to output 2025-07-06 21:58:55 +02:00
Lorenz Kästle
4ef8af0d9a check_load: remove useless code and do some formatting 2025-07-06 21:46:54 +02:00
Lorenz Kästle
882ef5015f Merge branch 'master' into refactor/check_procs 2025-06-28 09:53:59 +02:00
Lorenz Kästle
b8580c18e3
Merge pull request #2125 from RincewindsHat/refactor/check_icmp
Refactor check_icmp:

 - Far less global variables
 - Proper IPv6/legacy IP dual stack functionality (allowed mixed v4/v6 hosts)
 - Improved readability/understandability
 - General cleanup
2025-06-20 11:29:07 +02:00
Lorenz Kästle
a669b2531d Remove options if fping version is too low and die directly 2025-06-12 13:33:50 +02:00
Lorenz Kästle
19f409ac55 Remove unnecessary newline 2025-06-12 13:26:55 +02:00
Lorenz Kästle
f2c6ce08e3 check_fping: small style improvement 2025-06-12 11:53:06 +02:00
Lorenz Kästle
7247fc656a Implement new fping options for fping 5.2 and 5.3
fping 5.2 and 5.3 add some new useful command line options
which this commit add to check_fping.

These are:

 * --fwmark - sets a firewall mark in the packages to make them
   identifiable (fping 5.2)
 * --icmp-timestamp - fping uses ICMP timestamp instead of ICMP
   Echo (fping 5.2)
 * --check-source - fping discards replies which originate not from
   the target address (fping 5.2)

The fping release notes describe theses options ( https://github.com/schweikert/fping/releases )
in a little bit more detail.
Currently the help display for those options is only shown
when fping was available in the appropriate version during
compilation.
2025-06-12 11:13:59 +02:00
Lorenz Kästle
dd93b1403a utils: Make fmt function for compiler 2025-05-18 19:19:23 +02:00
William
1fb9300a2f Remove un-needed flags 2025-05-07 13:17:47 +10:00
William
58a3424511 Improve logic 2025-05-07 13:15:51 +10:00
William
a1472be883 Harden check with unspec 2025-05-07 13:15:51 +10:00
William
4acba2b3ec Improve handling of -4/-6
If fping is used with a target that has dual stack v4/v6, then due to
the logic during command construction, ipv4 will never be checked as v6
is preferred by fping.

This explicitly flags -4/-6 when it is requested by the user.
2025-05-07 13:15:51 +10:00
Jan Wagner
14169fe5a1 check_http: Adding deprecation text 2025-04-21 10:55:23 +02:00
Lorenz Kästle
4924bc877f
Merge pull request #2113 from RincewindsHat/refactor/check_disk
Refactor/check disk
2025-03-31 23:58:02 +02:00