Commit graph

200 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
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
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
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
RincewindsHat
b6d920da55 check_snmp: style + linter fixes 2024-10-31 14:01:12 +01:00
RincewindsHat
04471ba48d check_snmp: update copyright 2024-10-31 13:56:28 +01:00
RincewindsHat
50f6ae2c64 check_snmp: clang-format 2024-10-31 13:56:00 +01:00
RincewindsHat
b1e96a3bf3 check_snmp: Remove unused PP-macros 2024-09-27 11:58:42 +02:00
RincewindsHat
3ba660889a check_snmp: Declare most variables as static 2024-09-27 11:57:38 +02:00
RincewindsHat
26a979284d Fix typos 2024-05-21 14:27:21 +02:00
RincewindsHat
c862f705f3 Add more documentation to the help page of check_snmp regarding authentication and privacy options 2024-05-21 13:59:45 +02:00
RincewindsHat
5275f81e38 check_snmp: Remove unused variable 2023-12-29 00:47:29 +01:00
RincewindsHat
81f3b41651 Fix fallout of the previous changes 2023-10-19 12:20:27 +02:00
RincewindsHat
07f9c438f3 Fixes for -Wsign-compare 2023-10-19 12:10:55 +02:00
RincewindsHat
d4539f8662 check_snmp: Use C99 booleans 2023-10-18 20:22:06 +02:00
Lorenz Kästle
aa76eece10
Merge branch 'master' into compiler_warning_part_5 2023-08-30 09:36:53 +02:00
Lorenz Kästle
9e32be80d6 Remove dead, commented code 2023-08-28 11:15:59 +02:00
RincewindsHat
90cb539595 Implement option to ignore mib file parsing errors 2023-08-27 23:13:17 +02:00
Lorenz Kästle
c47f44d897
Merge branch 'master' into compiler_warning_part_5 2023-07-23 22:19:34 +02:00
Lorenz Kästle
068c124f36 Detect if fmtstr was set in edge cases 2023-07-11 16:39:29 +02:00
RincewindsHat
6d341c40ab Fixes for Waddress
* check_snmp: Fix string comparison
2023-04-18 00:35:41 +02:00
RincewindsHat
f7687d47cb Fixes for -Wimplicit-fallthrough 2023-04-18 00:18:07 +02:00
Jan Wagner
0f3703e641 Fix a lot of typos reported by codespell 2023-04-14 18:35:00 +00:00
Sven Nierlein
6e64973a44 simplify code
if statement is always true at this point, so remove it.
2023-03-27 12:59:53 +02:00
Sven Nierlein
c874f950e8 check_snmp: disable multiplier when unused
- if no multiplier is set, simply return the given string. Otherwise we would strip off the unit.
 - if used, allocate new space to hold the result which might be larger than the initial input

Signed-off-by: Sven Nierlein <sven@consol.de>
2023-03-15 09:51:18 +01:00
Sven Nierlein
f4930aee28 fix check_snmp regex matches
the multiplier function always tried to extract a number, even if the result
is a string because of using a mib.

before:
```
./check_snmp -H hostname -P2c -c public -o IF-MIB::ifAdminStatus.11466 -vvv -r 0
/usr/bin/snmpget -Le -t 10 -r 5 -m ALL -v 2c [context] [authpriv] 10.0.13.11:161 IF-MIB::ifAdminStatus.11466
IF-MIB::ifAdminStatus.11466 = INTEGER: up(1)
Processing oid 1 (line 1)
  oidname: IF-MIB::ifAdminStatus.11466
  response:  = INTEGER: up(1)
SNMP OK - 0 | IF-MIB::ifAdminStatus.11466=0;;
```

the regexp 0 matches, even if the actual result is "up(1)".

after this patch:
```
./check_snmp -H hostname -P2c -c public -o IF-MIB::ifAdminStatus.11466 -vvv -r 0
/usr/bin/snmpget -Le -t 10 -r 5 -m ALL -v 2c [context] [authpriv] 10.0.13.11:161 IF-MIB::ifAdminStatus.11466
IF-MIB::ifAdminStatus.11466 = INTEGER: up(1)
Processing oid 1 (line 1)
  oidname: IF-MIB::ifAdminStatus.11466
  response:  = INTEGER: up(1)
SNMP CRITICAL - *up(1)* |
```
2023-01-20 08:57:56 +01:00
Sven Nierlein
9ba8f5ed66 check_snmp: always apply format when applying multiplier 2022-12-22 12:54:51 +01:00
Wolfgang Nieder
c35bf8966a add 'multiplier' to modify current value 2022-12-22 12:54:51 +01:00
adrb
9f2a9ca3d7
check_snmp: Segfault if number of processed lines is greater than number of thresholds
Segfault at line 489 if number of processed lines is greater than number (#1589) of thresholds

Co-authored-by: Lorenz <12514511+RincewindsHat@users.noreply.github.com>
2022-07-24 16:44:16 +02:00
Ken D
69fed9d083 Updated int state to human readable 2022-01-14 15:52:00 +01:00
Ken D
a1f3289000 Added option for null zero length string exit codes
When using a large distributed network with the same group of checks used against a large number of devices, occationally there are missing cards in a few devices that are present in other devices. Rather than having a large number of unknown results, disable active checking on those large number of result or having to create a unique check configuration for those devices.

This option allows you to select an OK, WARNING, CRITICAL or UNKNOWN status while still retaining the default behavior when not present. This also allows a for the check to immediately start checks as intended should the hardware be added that the check is looking for.
2022-01-14 15:52:00 +01:00
Lorenz Kästle
c46447af65 Fix option description authpassword -> authpasswd 2021-11-19 09:30:20 +01:00
Lorenz Kästle
cf9dccbec2 Revert "Fixed option description authpassword -> authpasswd + whitespaces"
This reverts commit b27e639725.
2021-11-19 09:30:20 +01:00
Lorenz Kästle
a1fe4df6a3 Fixed option description authpassword -> authpasswd + whitespaces 2021-11-19 09:30:20 +01:00
Sven Nierlein
024d268386 check_snmp: fix performance thresholds when using multiple oids
when using check_snmp with multiple oids it simply printed the unparsed content
from -w/-c into the thresholds for each oid. So each oid contained the hole -w
from all oids.

./check_snmp ... -o iso.3.6.1.2.1.25.1.3.0,iso.3.6.1.2.1.25.1.5.0 -w '1,2' -c '3,4'

before:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1,2;3,4 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;1,2;3,4

after:
  SNMP ... | HOST-RESOURCES-MIB::hrSystemInitialLoadDevice.0=393216;1;3 HOST-RESOURCES-MIB::hrSystemNumUsers.0=24;2;4

This also applies to fixed thresholds since check_snmp translates negative infinities from: '~:-1' to '@-1:~'
2021-11-17 14:04:09 +01: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