diff options
Diffstat (limited to 'plugins/check_snmp.d/config.h')
-rw-r--r-- | plugins/check_snmp.d/config.h | 52 |
1 files changed, 5 insertions, 47 deletions
diff --git a/plugins/check_snmp.d/config.h b/plugins/check_snmp.d/config.h index e2e1d6c2..ca624a81 100644 --- a/plugins/check_snmp.d/config.h +++ b/plugins/check_snmp.d/config.h | |||
@@ -1,11 +1,11 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include "states.h" | ||
4 | #include "thresholds.h" | 3 | #include "thresholds.h" |
5 | #include "utils_base.h" | 4 | #include "states.h" |
6 | #include <stdlib.h> | 5 | #include <stdlib.h> |
7 | #include <stdbool.h> | 6 | #include <stdbool.h> |
8 | #include <regex.h> | 7 | #include <regex.h> |
8 | #include "../common.h" | ||
9 | 9 | ||
10 | // defines for snmp libs | 10 | // defines for snmp libs |
11 | #define u_char unsigned char | 11 | #define u_char unsigned char |
@@ -18,12 +18,8 @@ | |||
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 | const int DEFAULT_PROTOCOL = SNMP_VERSION_1; | 21 | #define DEFAULT_PORT "161" |
22 | const char DEFAULT_PORT[] = "161"; | 22 | #define DEFAULT_RETRIES 5 |
23 | const char DEFAULT_OUTPUT_DELIMITER[] = " "; | ||
24 | const int DEFAULT_RETRIES = 5; | ||
25 | |||
26 | const int RANDOM_STATE_DATA_LENGTH_PREDICTION = 1024; | ||
27 | 23 | ||
28 | typedef struct eval_method { | 24 | typedef struct eval_method { |
29 | bool crit_string; | 25 | bool crit_string; |
@@ -35,13 +31,9 @@ typedef struct check_snmp_test_unit { | |||
35 | char *label; | 31 | char *label; |
36 | char *unit_value; | 32 | char *unit_value; |
37 | eval_method eval_mthd; | 33 | eval_method eval_mthd; |
34 | mp_thresholds threshold; | ||
38 | } check_snmp_test_unit; | 35 | } check_snmp_test_unit; |
39 | 36 | ||
40 | check_snmp_test_unit check_snmp_test_unit_init() { | ||
41 | check_snmp_test_unit tmp = {}; | ||
42 | return tmp; | ||
43 | } | ||
44 | |||
45 | typedef struct check_snmp_config { | 37 | typedef struct check_snmp_config { |
46 | // SNMP session to use | 38 | // SNMP session to use |
47 | struct snmp_session snmp_session; | 39 | struct snmp_session snmp_session; |
@@ -55,7 +47,6 @@ typedef struct check_snmp_config { | |||
55 | 47 | ||
56 | check_snmp_test_unit *test_units; | 48 | check_snmp_test_unit *test_units; |
57 | size_t num_of_test_units; | 49 | size_t num_of_test_units; |
58 | mp_thresholds thresholds; | ||
59 | 50 | ||
60 | // State if an empty value is encountered | 51 | // State if an empty value is encountered |
61 | mp_state_enum nulloid_result; | 52 | mp_state_enum nulloid_result; |
@@ -72,36 +63,3 @@ typedef struct check_snmp_config { | |||
72 | // Modify output | 63 | // Modify output |
73 | bool use_perf_data_labels_from_input; | 64 | bool use_perf_data_labels_from_input; |
74 | } check_snmp_config; | 65 | } check_snmp_config; |
75 | |||
76 | check_snmp_config check_snmp_config_init() { | ||
77 | check_snmp_config tmp = { | ||
78 | .use_getnext = false, | ||
79 | |||
80 | .ignore_mib_parsing_errors = false, | ||
81 | .need_mibs = false, | ||
82 | |||
83 | .test_units = NULL, | ||
84 | .num_of_test_units = 0, | ||
85 | .thresholds = mp_thresholds_init(), | ||
86 | |||
87 | .nulloid_result = STATE_UNKNOWN, // state to return if no result for query | ||
88 | |||
89 | .invert_search = true, | ||
90 | .regex_cmp_value = {}, | ||
91 | .string_cmp_value = "", | ||
92 | |||
93 | .multiplier = 1.0, | ||
94 | .offset = 0, | ||
95 | |||
96 | .use_perf_data_labels_from_input = false, | ||
97 | }; | ||
98 | |||
99 | snmp_sess_init(&tmp.snmp_session); | ||
100 | |||
101 | tmp.snmp_session.retries = DEFAULT_RETRIES; | ||
102 | tmp.snmp_session.version = DEFAULT_SNMP_VERSION; | ||
103 | tmp.snmp_session.securityLevel = SNMP_SEC_LEVEL_NOAUTH; | ||
104 | tmp.snmp_session.community = (unsigned char *)"public"; | ||
105 | tmp.snmp_session.community_len = strlen("public"); | ||
106 | return tmp; | ||
107 | } | ||