diff options
Diffstat (limited to 'plugins/check_fping.c')
| -rw-r--r-- | plugins/check_fping.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c index f4792f0a..1c227cdb 100644 --- a/plugins/check_fping.c +++ b/plugins/check_fping.c | |||
| @@ -52,6 +52,8 @@ void print_help (void); | |||
| 52 | void print_usage (void); | 52 | void print_usage (void); |
| 53 | 53 | ||
| 54 | char *server_name = NULL; | 54 | char *server_name = NULL; |
| 55 | char *sourceip = NULL; | ||
| 56 | char *sourceif = NULL; | ||
| 55 | int packet_size = PACKET_SIZE; | 57 | int packet_size = PACKET_SIZE; |
| 56 | int packet_count = PACKET_COUNT; | 58 | int packet_count = PACKET_COUNT; |
| 57 | int target_timeout = 0; | 59 | int target_timeout = 0; |
| @@ -96,6 +98,10 @@ main (int argc, char **argv) | |||
| 96 | xasprintf(&option_string, "%s-t %d ", option_string, target_timeout); | 98 | xasprintf(&option_string, "%s-t %d ", option_string, target_timeout); |
| 97 | if (packet_interval) | 99 | if (packet_interval) |
| 98 | xasprintf(&option_string, "%s-p %d ", option_string, packet_interval); | 100 | xasprintf(&option_string, "%s-p %d ", option_string, packet_interval); |
| 101 | if (sourceip) | ||
| 102 | xasprintf(&option_string, "%s-S %s ", option_string, sourceip); | ||
| 103 | if (sourceif) | ||
| 104 | xasprintf(&option_string, "%s-I %s ", option_string, sourceif); | ||
| 99 | 105 | ||
| 100 | #ifdef USE_IPV6 | 106 | #ifdef USE_IPV6 |
| 101 | if (address_family == AF_INET6) | 107 | if (address_family == AF_INET6) |
| @@ -242,6 +248,8 @@ process_arguments (int argc, char **argv) | |||
| 242 | int option = 0; | 248 | int option = 0; |
| 243 | static struct option longopts[] = { | 249 | static struct option longopts[] = { |
| 244 | {"hostname", required_argument, 0, 'H'}, | 250 | {"hostname", required_argument, 0, 'H'}, |
| 251 | {"sourceip", required_argument, 0, 'S'}, | ||
| 252 | {"sourceif", required_argument, 0, 'I'}, | ||
| 245 | {"critical", required_argument, 0, 'c'}, | 253 | {"critical", required_argument, 0, 'c'}, |
| 246 | {"warning", required_argument, 0, 'w'}, | 254 | {"warning", required_argument, 0, 'w'}, |
| 247 | {"bytes", required_argument, 0, 'b'}, | 255 | {"bytes", required_argument, 0, 'b'}, |
| @@ -270,7 +278,7 @@ process_arguments (int argc, char **argv) | |||
| 270 | } | 278 | } |
| 271 | 279 | ||
| 272 | while (1) { | 280 | while (1) { |
| 273 | c = getopt_long (argc, argv, "+hVvH:c:w:b:n:T:i:46", longopts, &option); | 281 | c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:46", longopts, &option); |
| 274 | 282 | ||
| 275 | if (c == -1 || c == EOF || c == 1) | 283 | if (c == -1 || c == EOF || c == 1) |
| 276 | break; | 284 | break; |
| @@ -293,6 +301,14 @@ process_arguments (int argc, char **argv) | |||
| 293 | } | 301 | } |
| 294 | server_name = strscpy (server_name, optarg); | 302 | server_name = strscpy (server_name, optarg); |
| 295 | break; | 303 | break; |
| 304 | case 'S': /* sourceip */ | ||
| 305 | if (is_host (optarg) == FALSE) { | ||
| 306 | usage2 (_("Invalid hostname/address"), optarg); | ||
| 307 | } | ||
| 308 | sourceip = strscpy (sourceip, optarg); | ||
| 309 | break; | ||
| 310 | case 'I': /* sourceip */ | ||
| 311 | sourceif = strscpy (sourceif, optarg); | ||
| 296 | case '4': /* IPv4 only */ | 312 | case '4': /* IPv4 only */ |
| 297 | address_family = AF_INET; | 313 | address_family = AF_INET; |
| 298 | break; | 314 | break; |
| @@ -437,9 +453,13 @@ print_help (void) | |||
| 437 | printf (" %s\n", "-n, --number=INTEGER"); | 453 | printf (" %s\n", "-n, --number=INTEGER"); |
| 438 | printf (" %s (default: %d)\n", _("number of ICMP packets to send"),PACKET_COUNT); | 454 | printf (" %s (default: %d)\n", _("number of ICMP packets to send"),PACKET_COUNT); |
| 439 | printf (" %s\n", "-T, --target-timeout=INTEGER"); | 455 | printf (" %s\n", "-T, --target-timeout=INTEGER"); |
| 440 | printf (" %s (default: fping's default for -t)\n", _("Target timeout (ms)"),PACKET_COUNT); | 456 | printf (" %s (default: fping's default for -t)\n", _("Target timeout (ms)")); |
| 441 | printf (" %s\n", "-i, --interval=INTEGER"); | 457 | printf (" %s\n", "-i, --interval=INTEGER"); |
| 442 | printf (" %s (default: fping's default for -p)\n", _("Interval (ms) between sending packets"),PACKET_COUNT); | 458 | printf (" %s (default: fping's default for -p)\n", _("Interval (ms) between sending packets")); |
| 459 | printf (" %s\n", "-S, --sourceip=HOST"); | ||
| 460 | printf (" %s\n", _("name or IP Address of sourceip")); | ||
| 461 | printf (" %s\n", "-I, --sourceif=IF"); | ||
| 462 | printf (" %s\n", _("source interface name")); | ||
| 443 | printf (UT_VERBOSE); | 463 | printf (UT_VERBOSE); |
| 444 | printf ("\n"); | 464 | printf ("\n"); |
| 445 | printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)")); | 465 | printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)")); |
