From 7247fc656a1f475159b7879cc3c3b798e03c1a33 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Thu, 12 Jun 2025 11:13:59 +0200 Subject: Implement new fping options for fping 5.2 and 5.3 fping 5.2 and 5.3 add some new useful command line options which this commit add to check_fping. These are: * --fwmark - sets a firewall mark in the packages to make them identifiable (fping 5.2) * --icmp-timestamp - fping uses ICMP timestamp instead of ICMP Echo (fping 5.2) * --check-source - fping discards replies which originate not from the target address (fping 5.2) The fping release notes describe theses options ( https://github.com/schweikert/fping/releases ) in a little bit more detail. Currently the help display for those options is only shown when fping was available in the appropriate version during compilation. --- plugins/check_fping.d/config.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'plugins/check_fping.d/config.h') diff --git a/plugins/check_fping.d/config.h b/plugins/check_fping.d/config.h index a0697bf3..6d28382a 100644 --- a/plugins/check_fping.d/config.h +++ b/plugins/check_fping.d/config.h @@ -29,6 +29,21 @@ typedef struct { bool cpl_p; int wpl; bool wpl_p; + + // only available with fping version >= 5.2 + // for a given uint _fwmark_ fping sets _fwmark_ as a firewall mark + // in the pakets + unsigned int fwmark; + bool fwmark_set; + + + // only available with fping version >= 5.3 + // Setting icmp_timestamp tells fping to use ICMP Timestamp (ICMP type 13) instead + // of ICMP Echo + bool icmp_timestamp; + + // Setting check_source lets fping discard replies which are not from the target address + bool check_source; } check_fping_config; check_fping_config check_fping_config_init() { @@ -53,6 +68,15 @@ check_fping_config check_fping_config_init() { .cpl_p = false, .wpl = 0, .wpl_p = false, + + // only available with fping version >= 5.2 + .fwmark = 0, + .fwmark_set = false, // just to be deterministic + + // only available with fping version >= 5.3 + .icmp_timestamp = false, + .check_source = false, + }; return tmp; } -- cgit v1.2.3-74-g34f1 From f2c6ce08e3da320d044564352faedd78eb76f1a1 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle Date: Thu, 12 Jun 2025 11:19:42 +0200 Subject: check_fping: small style improvement --- plugins/check_fping.c | 4 ++-- plugins/check_fping.d/config.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins/check_fping.d/config.h') diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 4d328a01..c1e7dd17 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -132,7 +132,7 @@ int main(int argc, char **argv) { char *command_line = NULL; if (config.icmp_timestamp) { - // no paket size settable for ICMP timestamp + // no packet size settable for ICMP timestamp xasprintf(&command_line, "%s %s -c %d %s", fping_prog, option_string, config.packet_count, server); } else { xasprintf(&command_line, "%s %s-b %d -c %d %s", fping_prog, option_string, config.packet_size, config.packet_count, server); @@ -346,7 +346,7 @@ check_fping_config_wrapper process_arguments(int argc, char **argv) { argc--; } - while (1) { + while (true) { int option_index = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option); if (option_index == -1 || option_index == EOF || option_index == 1) { diff --git a/plugins/check_fping.d/config.h b/plugins/check_fping.d/config.h index 6d28382a..d95e9ded 100644 --- a/plugins/check_fping.d/config.h +++ b/plugins/check_fping.d/config.h @@ -32,7 +32,7 @@ typedef struct { // only available with fping version >= 5.2 // for a given uint _fwmark_ fping sets _fwmark_ as a firewall mark - // in the pakets + // in the packets unsigned int fwmark; bool fwmark_set; -- cgit v1.2.3-74-g34f1