diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-08-27 12:17:46 +0200 |
---|---|---|
committer | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-08-27 12:17:46 +0200 |
commit | a27862a9c774d3fc4a608f8593c83b11357cc6dc (patch) | |
tree | d0b86f8a6174a16ee102a1b5c37fba2f74e2882c /plugins/check_snmp.c | |
parent | babeb765e5725610dbf7673c91a3a5a4e5a8810f (diff) | |
download | monitoring-plugins-a27862a9c774d3fc4a608f8593c83b11357cc6dc.tar.gz |
check_snmp: rebuild threshold parsing
Diffstat (limited to 'plugins/check_snmp.c')
-rw-r--r-- | plugins/check_snmp.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c index 6c9ed959..b71ee4fd 100644 --- a/plugins/check_snmp.c +++ b/plugins/check_snmp.c | |||
@@ -41,6 +41,7 @@ const char *email = "devel@monitoring-plugins.org"; | |||
41 | #include "../lib/utils_base.h" | 41 | #include "../lib/utils_base.h" |
42 | #include "../lib/output.h" | 42 | #include "../lib/output.h" |
43 | #include "../lib/perfdata.h" | 43 | #include "../lib/perfdata.h" |
44 | #include "check_snmp.d/check_snmp_helpers.h" | ||
44 | 45 | ||
45 | #include <bits/getopt_core.h> | 46 | #include <bits/getopt_core.h> |
46 | #include <bits/getopt_ext.h> | 47 | #include <bits/getopt_ext.h> |
@@ -366,8 +367,9 @@ int main(int argc, char **argv) { | |||
366 | config.test_units[loop_index].unit_value); | 367 | config.test_units[loop_index].unit_value); |
367 | } | 368 | } |
368 | 369 | ||
369 | if (config.thresholds.warning_is_set || config.thresholds.critical_is_set) { | 370 | if (config.test_units[loop_index].threshold.warning_is_set || |
370 | pd_num_val = mp_pd_set_thresholds(pd_num_val, config.thresholds); | 371 | config.test_units[loop_index].threshold.critical_is_set) { |
372 | pd_num_val = mp_pd_set_thresholds(pd_num_val, config.test_units[loop_index].threshold); | ||
371 | mp_state_enum tmp_state = mp_get_pd_status(pd_num_val); | 373 | mp_state_enum tmp_state = mp_get_pd_status(pd_num_val); |
372 | 374 | ||
373 | if (tmp_state == STATE_WARNING) { | 375 | if (tmp_state == STATE_WARNING) { |
@@ -660,23 +662,11 @@ static process_arguments_wrapper process_arguments(int argc, char **argv) { | |||
660 | 662 | ||
661 | /* Test parameters */ | 663 | /* Test parameters */ |
662 | case 'c': /* critical threshold */ | 664 | case 'c': /* critical threshold */ |
663 | { | 665 | check_snmp_set_thresholds(optarg, config.test_units, oid_counter, true); |
664 | mp_range_parsed tmp = mp_parse_range_string(optarg); | 666 | break; |
665 | if (tmp.error != MP_PARSING_SUCCES) { | ||
666 | die(STATE_UNKNOWN, "Unable to parse critical threshold range: %s", optarg); | ||
667 | } | ||
668 | config.thresholds.critical = tmp.range; | ||
669 | config.thresholds.critical_is_set = true; | ||
670 | } break; | ||
671 | case 'w': /* warning threshold */ | 667 | case 'w': /* warning threshold */ |
672 | { | 668 | check_snmp_set_thresholds(optarg, config.test_units, oid_counter, false); |
673 | mp_range_parsed tmp = mp_parse_range_string(optarg); | 669 | break; |
674 | if (tmp.error != MP_PARSING_SUCCES) { | ||
675 | die(STATE_UNKNOWN, "Unable to parse warning threshold range: %s", optarg); | ||
676 | } | ||
677 | config.thresholds.warning = tmp.range; | ||
678 | config.thresholds.warning_is_set = true; | ||
679 | } break; | ||
680 | case 'o': /* object identifier */ | 670 | case 'o': /* object identifier */ |
681 | if (strspn(optarg, "0123456789.,") != strlen(optarg)) { | 671 | if (strspn(optarg, "0123456789.,") != strlen(optarg)) { |
682 | /* | 672 | /* |