File: 17_check_fping_dontfrag_random

package info (click to toggle)
monitoring-plugins 2.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 11,704 kB
  • sloc: ansic: 76,177; sh: 13,717; perl: 7,655; makefile: 489
file content (83 lines) | stat: -rw-r--r-- 2,528 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
From 88d991773b6d8ac416ad2931ea8debc949555c7a Mon Sep 17 00:00:00 2001
From: William <william@blackhats.net.au>
Date: Wed, 6 Nov 2024 14:00:23 +1000
Subject: [PATCH] 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(+)

--- 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
@@ -60,6 +60,8 @@
 int target_timeout = 0;
 int packet_interval = 0;
 bool verbose = false;
+bool dontfrag = false;
+bool randomize_packet_data = false;
 int cpl;
 int wpl;
 double crta;
@@ -105,6 +107,10 @@
     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))
@@ -303,6 +309,8 @@
     {"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}
   };
 
@@ -320,7 +328,7 @@
   }
 
   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;
@@ -415,6 +423,12 @@
       else
         usage (_("Interval must be a positive integer"));
       break;
+    case 'R':
+      randomize_packet_data = true;
+      break;
+    case 'M':
+      dontfrag = true;
+      break;
     }
   }
 
@@ -506,6 +520,10 @@
   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 <rta>,<pl>%% where <rta> is the round trip average travel time (ms)"));