[nagiosplug] Added -S und -I parameter to match fping -S and ...

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Sat Aug 17 23:20:15 CEST 2013


    Module: nagiosplug
    Branch: master
    Commit: c9169d1256b9e8a95e4ae2efcf2c2164864f22bd
    Author: Steve Weinreich <steve at weinreich.org>
 Committer: Holger Weiss <holger at zedat.fu-berlin.de>
      Date: Thu Dec 20 17:00:19 2012 +0100
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=c9169d1

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

---

 plugins/check_fping.c |   23 ++++++++++++++++++++++-
 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);
 void print_usage (void);
 
 char *server_name = NULL;
+char *sourceip = NULL;
+char *sourceif = NULL;
 int packet_size = PACKET_SIZE;
 int packet_count = PACKET_COUNT;
 int target_timeout = 0;
@@ -95,6 +97,10 @@ main (int argc, char **argv)
     xasprintf(&option_string, "%s-t %d ", option_string, target_timeout);
   if (packet_interval)
     xasprintf(&option_string, "%s-p %d ", option_string, packet_interval);
+  if (sourceip)
+    xasprintf(&option_string, "%s-S %s ", option_string, sourceip);
+  if (sourceif)
+    xasprintf(&option_string, "%s-I %s ", option_string, sourceif);
 
   xasprintf (&command_line, "%s %s-b %d -c %d %s", PATH_TO_FPING,
             option_string, packet_size, packet_count, server);
@@ -232,6 +238,8 @@ process_arguments (int argc, char **argv)
   int option = 0;
   static struct option longopts[] = {
     {"hostname", required_argument, 0, 'H'},
+    {"sourceip", required_argument, 0, 'S'},
+    {"sourceif", required_argument, 0, 'I'},
     {"critical", required_argument, 0, 'c'},
     {"warning", required_argument, 0, 'w'},
     {"bytes", required_argument, 0, 'b'},
@@ -258,7 +266,7 @@ process_arguments (int argc, char **argv)
   }
 
   while (1) {
-    c = getopt_long (argc, argv, "+hVvH:c:w:b:n:T:i:", longopts, &option);
+    c = getopt_long (argc, argv, "+hVvH:S:c:w:b:n:T:i:I:", longopts, &option);
 
     if (c == -1 || c == EOF || c == 1)
       break;
@@ -281,6 +289,15 @@ process_arguments (int argc, char **argv)
       }
       server_name = strscpy (server_name, optarg);
       break;
+    case 'S':                 /* sourceip */
+      if (is_host (optarg) == FALSE) {
+        usage2 (_("Invalid hostname/address"), optarg);
+      }
+      sourceip = strscpy (sourceip, optarg);
+      break;
+    case 'I':                 /* sourceip */
+      sourceif = strscpy (sourceif, optarg);
+      break;
     case 'c':
       get_threshold (optarg, rv);
       if (rv[RTA]) {
@@ -416,6 +433,10 @@ print_help (void)
   printf ("    %s (default: fping's default for -t)\n", _("Target timeout (ms)"),PACKET_COUNT);
   printf (" %s\n", "-i, --interval=INTEGER");
   printf ("    %s (default: fping's default for -p)\n", _("Interval (ms) between sending packets"),PACKET_COUNT);
+  printf (" %s\n", "-S, --sourceip=HOST");
+  printf ("    %s\n", _("name or IP Address of sourceip"));
+  printf (" %s\n", "-I, --sourceif=IF");
+  printf ("    %s\n", _("source interface name"));
   printf (UT_VERBOSE);
   printf ("\n");
   printf (" %s\n", _("THRESHOLD is <rta>,<pl>%% where <rta> is the round trip average travel time (ms)"));





More information about the Commits mailing list