summaryrefslogtreecommitdiffstats
path: root/plugins/check_fping.c
diff options
context:
space:
mode:
authorSteve Weinreich <steve@weinreich.org>2012-12-20 16:00:19 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-17 21:15:59 (GMT)
commitc9169d1256b9e8a95e4ae2efcf2c2164864f22bd (patch)
tree99ce3f789767d8f8d7c42cf45a3c6a06125d21e2 /plugins/check_fping.c
parentb62f0fb444aae2c6ac31697dcfaa392ce2b85fc7 (diff)
downloadmonitoring-plugins-c9169d1256b9e8a95e4ae2efcf2c2164864f22bd.tar.gz
Added -S und -I parameter to match fping -S and -I parameters.
-S allows to specify the source ip for ICMP pakets -I allows to specify a interface to bind to
Diffstat (limited to 'plugins/check_fping.c')
-rw-r--r--plugins/check_fping.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index 675a547..f5b4332 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -52,6 +52,8 @@ void print_help (void);
52void print_usage (void); 52void print_usage (void);
53 53
54char *server_name = NULL; 54char *server_name = NULL;
55char *sourceip = NULL;
56char *sourceif = NULL;
55int packet_size = PACKET_SIZE; 57int packet_size = PACKET_SIZE;
56int packet_count = PACKET_COUNT; 58int packet_count = PACKET_COUNT;
57int target_timeout = 0; 59int target_timeout = 0;
@@ -95,6 +97,10 @@ main (int argc, char **argv)
95 xasprintf(&option_string, "%s-t %d ", option_string, target_timeout); 97 xasprintf(&option_string, "%s-t %d ", option_string, target_timeout);
96 if (packet_interval) 98 if (packet_interval)
97 xasprintf(&option_string, "%s-p %d ", option_string, packet_interval); 99 xasprintf(&option_string, "%s-p %d ", option_string, packet_interval);
100 if (sourceip)
101 xasprintf(&option_string, "%s-S %s ", option_string, sourceip);
102 if (sourceif)
103 xasprintf(&option_string, "%s-I %s ", option_string, sourceif);
98 104
99 xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING, 105 xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING,
100 option_string, packet_size, packet_count, server); 106 option_string, packet_size, packet_count, server);
@@ -232,6 +238,8 @@ process_arguments (int argc, char **argv)
232 int option = 0; 238 int option = 0;
233 static struct option longopts[] = { 239 static struct option longopts[] = {
234 {"hostname", required_argument, 0, 'H'}, 240 {"hostname", required_argument, 0, 'H'},
241 {"sourceip", required_argument, 0, 'S'},
242 {"sourceif", required_argument, 0, 'I'},
235 {"critical", required_argument, 0, 'c'}, 243 {"critical", required_argument, 0, 'c'},
236 {"warning", required_argument, 0, 'w'}, 244 {"warning", required_argument, 0, 'w'},
237 {"bytes", required_argument, 0, 'b'}, 245 {"bytes", required_argument, 0, 'b'},
@@ -258,7 +266,7 @@ process_arguments (int argc, char **argv)
258 } 266 }
259 267
260 while (1) { 268 while (1) {
261 c = getopt_long (argc, argv, "+hVvH:c:w:b:n:T:i:", longopts, &option); 269 c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:", longopts, &option);
262 270
263 if (c == -1 || c == EOF || c == 1) 271 if (c == -1 || c == EOF || c == 1)
264 break; 272 break;
@@ -281,6 +289,15 @@ process_arguments (int argc, char **argv)
281 } 289 }
282 server_name = strscpy (server_name, optarg); 290 server_name = strscpy (server_name, optarg);
283 break; 291 break;
292 case 'S': /* sourceip */
293 if (is_host (optarg) == FALSE) {
294 usage2 (_("Invalid hostname/address"), optarg);
295 }
296 sourceip = strscpy (sourceip, optarg);
297 break;
298 case 'I': /* sourceip */
299 sourceif = strscpy (sourceif, optarg);
300 break;
284 case 'c': 301 case 'c':
285 get_threshold (optarg, rv); 302 get_threshold (optarg, rv);
286 if (rv[RTA]) { 303 if (rv[RTA]) {
@@ -416,6 +433,10 @@ print_help (void)
416 printf (" %s (default: fping's default for -t)\n", _("Target timeout (ms)"),PACKET_COUNT); 433 printf (" %s (default: fping's default for -t)\n", _("Target timeout (ms)"),PACKET_COUNT);
417 printf (" %s\n", "-i, --interval=INTEGER"); 434 printf (" %s\n", "-i, --interval=INTEGER");
418 printf (" %s (default: fping's default for -p)\n", _("Interval (ms) between sending packets"),PACKET_COUNT); 435 printf (" %s (default: fping's default for -p)\n", _("Interval (ms) between sending packets"),PACKET_COUNT);
436 printf (" %s\n", "-S, --sourceip=HOST");
437 printf (" %s\n", _("name or IP Address of sourceip"));
438 printf (" %s\n", "-I, --sourceif=IF");
439 printf (" %s\n", _("source interface name"));
419 printf (UT_VERBOSE); 440 printf (UT_VERBOSE);
420 printf ("\n"); 441 printf ("\n");
421 printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)")); 442 printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)"));