From 88d991773b6d8ac416ad2931ea8debc949555c7a Mon Sep 17 00:00:00 2001 From: William Date: Wed, 6 Nov 2024 14:00:23 +1000 Subject: Add dontfrag/random for fping Support the dont fragment and randomise packet data options for check_fping --- plugins/check_fping.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'plugins/check_fping.c') diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 49235e28..67fa2363 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -60,6 +60,8 @@ static int packet_count = PACKET_COUNT; static int target_timeout = 0; static int packet_interval = 0; static bool verbose = false; +static bool dontfrag = false; +static bool randomize_packet_data = false; static int cpl; static int wpl; static double crta; @@ -103,6 +105,11 @@ int main(int argc, char **argv) { xasprintf(&option_string, "%s-S %s ", option_string, sourceip); if (sourceif) xasprintf(&option_string, "%s-I %s ", option_string, sourceif); + if (dontfrag) + xasprintf(&option_string, "%s-M ", option_string); + if (randomize_packet_data) + xasprintf(&option_string, "%s-R ", option_string); + #ifdef PATH_TO_FPING6 if (address_family != AF_INET && is_inet6_addr(server)) @@ -279,6 +286,8 @@ int process_arguments(int argc, char **argv) { {"help", no_argument, 0, 'h'}, {"use-ipv4", no_argument, 0, '4'}, {"use-ipv6", no_argument, 0, '6'}, + {"dontfrag", no_argument, 0, 'M'}, + {"random", no_argument, 0, 'R'}, {0, 0, 0, 0}}; rv[PL] = NULL; @@ -390,6 +399,12 @@ int process_arguments(int argc, char **argv) { else usage(_("Interval must be a positive integer")); break; + case 'R': + randomize_packet_data = true; + break; + case 'M': + dontfrag = true; + break; } } @@ -470,6 +485,10 @@ void print_help(void) { printf(" %s\n", _("name or IP Address of sourceip")); printf(" %s\n", "-I, --sourceif=IF"); printf(" %s\n", _("source interface name")); + printf(" %s\n", "-M, --dontfrag"); + printf(" %s\n", _("set the Don't Fragment flag")); + printf(" %s\n", "-R, --random"); + printf(" %s\n", _("random packet data (to foil link data compression)")); printf(UT_VERBOSE); printf("\n"); printf(" %s\n", _("THRESHOLD is ,%% where is the round trip average travel time (ms)")); -- cgit v1.2.3-74-g34f1 From d5ed947e312bcb8f0c4e46c4ea9f39918387efc3 Mon Sep 17 00:00:00 2001 From: William Date: Fri, 8 Nov 2024 14:07:29 +1000 Subject: Add missed changes for dontfrag Due to a mistake with git the command line args were not properly updated. --- plugins/check_fping.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/check_fping.c') diff --git a/plugins/check_fping.c b/plugins/check_fping.c index 67fa2363..c1d03ece 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c @@ -7,7 +7,7 @@ * * Description: * - * This file contains the check_disk plugin + * This file contains the check_fping plugin * * This plugin will use the fping command to ping the specified host for a * fast check @@ -304,7 +304,7 @@ int process_arguments(int argc, char **argv) { } while (1) { - c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:46", longopts, &option); + c = getopt_long(argc, argv, "+hVvaH:S:c:w:b:n:T:i:I:M:R:46", longopts, &option); if (c == -1 || c == EOF || c == 1) break; -- cgit v1.2.3-74-g34f1