[monitoring-plugins] check_icmp: trigger help before anything important
Lorenz Kästle
git at monitoring-plugins.org
Mon Jun 23 12:10:12 CEST 2025
Module: monitoring-plugins
Branch: master
Commit: 8626d22fc5df98d73b36eedb01cb4ed02908ea18
Author: Lorenz Kästle <12514511+RincewindsHat at users.noreply.github.com>
Date: Mon Jun 23 11:44:46 2025 +0200
URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=8626d22f
check_icmp: trigger help before anything important
---
plugins-root/check_icmp.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 8feeb853..03924a7e 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -353,6 +353,7 @@ check_icmp_config_wrapper process_arguments(int argc, char **argv) {
long int arg;
while ((arg = getopt_long(argc, argv, opts_str, longopts, NULL)) != EOF) {
switch (arg) {
+
case '4':
if (enforced_ai_family != AF_UNSPEC) {
crash("Multiple protocol versions not supported");
@@ -369,6 +370,11 @@ check_icmp_config_wrapper process_arguments(int argc, char **argv) {
result.config.number_of_hosts++;
break;
}
+ case 'h': /* help */
+ // Trigger help here to avoid adding hosts before that (and doing DNS queries)
+ print_help();
+ exit(STATE_UNKNOWN);
+ break;
case 'v':
debug++;
break;
@@ -490,10 +496,6 @@ check_icmp_config_wrapper process_arguments(int argc, char **argv) {
case 'V': /* version */
print_revision(progname, NP_VERSION);
exit(STATE_UNKNOWN);
- case 'h': /* help */
- print_help();
- exit(STATE_UNKNOWN);
- break;
case 'R': /* RTA mode */ {
get_threshold2_wrapper rta_th = get_threshold2(
optarg, strlen(optarg), result.config.warn, result.config.crit, const_rta_mode);
More information about the Commits
mailing list