diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-08 15:57:06 +0200 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-09-08 15:57:06 +0200 |
commit | 87195f5511bf18db2a64f71ea9783ebbfb33c3a5 (patch) | |
tree | 491157b89647d73ed6acb0e4e2ae7cdf7fffb01c /plugins/check_snmp.d/config.h | |
parent | 1aefb1f9df5268ccbcd3ce38f5527ebca3896db6 (diff) | |
download | monitoring-plugins-87195f5511bf18db2a64f71ea9783ebbfb33c3a5.tar.gz |
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
Diffstat (limited to 'plugins/check_snmp.d/config.h')
-rw-r--r-- | plugins/check_snmp.d/config.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/plugins/check_snmp.d/config.h b/plugins/check_snmp.d/config.h index e68986e2..a5d5aa52 100644 --- a/plugins/check_snmp.d/config.h +++ b/plugins/check_snmp.d/config.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include "thresholds.h" | 3 | #include "../../lib/thresholds.h" |
4 | #include "states.h" | 4 | #include "../../lib/states.h" |
5 | #include <stdlib.h> | 5 | #include <stdlib.h> |
6 | #include <stdbool.h> | 6 | #include <stdbool.h> |
7 | #include <regex.h> | 7 | #include <regex.h> |
@@ -18,7 +18,7 @@ | |||
18 | #include <net-snmp/library/snmp.h> | 18 | #include <net-snmp/library/snmp.h> |
19 | #include <net-snmp/session_api.h> | 19 | #include <net-snmp/session_api.h> |
20 | 20 | ||
21 | #define DEFAULT_PORT "161" | 21 | #define DEFAULT_PORT "161" |
22 | #define DEFAULT_RETRIES 5 | 22 | #define DEFAULT_RETRIES 5 |
23 | 23 | ||
24 | typedef struct eval_method { | 24 | typedef struct eval_method { |
@@ -34,10 +34,8 @@ typedef struct check_snmp_test_unit { | |||
34 | mp_thresholds threshold; | 34 | mp_thresholds threshold; |
35 | } check_snmp_test_unit; | 35 | } check_snmp_test_unit; |
36 | 36 | ||
37 | typedef struct check_snmp_config { | 37 | typedef struct { |
38 | // SNMP session to use | ||
39 | struct snmp_session snmp_session; | 38 | struct snmp_session snmp_session; |
40 | |||
41 | // use getnet instead of get | 39 | // use getnet instead of get |
42 | bool use_getnext; | 40 | bool use_getnext; |
43 | 41 | ||
@@ -47,7 +45,9 @@ typedef struct check_snmp_config { | |||
47 | 45 | ||
48 | check_snmp_test_unit *test_units; | 46 | check_snmp_test_unit *test_units; |
49 | size_t num_of_test_units; | 47 | size_t num_of_test_units; |
48 | } check_snmp_config_snmp_parameters; | ||
50 | 49 | ||
50 | typedef struct { | ||
51 | // State if an empty value is encountered | 51 | // State if an empty value is encountered |
52 | mp_state_enum nulloid_result; | 52 | mp_state_enum nulloid_result; |
53 | 53 | ||
@@ -63,7 +63,18 @@ typedef struct check_snmp_config { | |||
63 | bool offset_set; | 63 | bool offset_set; |
64 | 64 | ||
65 | // Modify output | 65 | // Modify output |
66 | bool use_perf_data_labels_from_input; | 66 | bool use_oid_as_perf_data_label; |
67 | |||
68 | // activate rate calucation | ||
69 | bool calculate_rate; | ||
70 | unsigned int rate_multiplier; | ||
71 | } check_snmp_evaluation_parameters; | ||
72 | |||
73 | typedef struct check_snmp_config { | ||
74 | // SNMP session to use | ||
75 | check_snmp_config_snmp_parameters snmp_params; | ||
76 | |||
77 | check_snmp_evaluation_parameters evaluation_params; | ||
67 | 78 | ||
68 | mp_output_format output_format; | 79 | mp_output_format output_format; |
69 | bool output_format_is_set; | 80 | bool output_format_is_set; |