Date: Wed, 16 Jul 2008 14:35:47 +1000 (EST) From: Dave Horsfall <daveh@coreng.com.au> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Dave Horsfall <daveh@coreng.com.au> Subject: ports/125668: [patch] Extend Nagios check_ping plugin to support source address Message-ID: <200807160435.m6G4ZlEh052022@mippet.ci.com.au> Resent-Message-ID: <200807160510.m6G5A1GY075804@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 125668 >Category: ports >Synopsis: [patch] Extend Nagios check_ping plugin to support source address >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jul 16 05:10:01 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Dave Horsfall >Release: FreeBSD 7.0-STABLE i386 >Organization: Corinthian Engineering P/L >Environment: System: FreeBSD mippet.ci.com.au 7.0-STABLE FreeBSD 7.0-STABLE #2: Wed Mar 5 09:21:55 EST 2008 rpp@mippet.ci.com.au:/usr/obj/usr/src/sys/LOCAL i386 >Description: We need to specify a source address to the "ping" command called by the Nagios plugin "check_ping". >How-To-Repeat: >Fix: Included is a patch against "check_ping.c 1810 2007-10-25 20:43:04Z" that accepts a new option "-S src-addr" (or "--src-addr addr"); it no doubt needs improvement e.g. support in "configure" etc. --- check_ping.patch begins here --- --- /usr/users/daveh/check_ping.c 2008-07-16 13:28:14.000000000 +1000 +++ check_ping.c 2008-07-16 14:09:49.000000000 +1000 @@ -70,6 +70,7 @@ int max_addr = 1; int max_packets = -1; int verbose = 0; +char *srcaddr = NULL; float rta = UNKNOWN_TRIP_TIME; int pl = UNKNOWN_PACKET_LOSS; @@ -115,19 +116,25 @@ #ifdef PING6_COMMAND if (address_family != AF_INET && is_inet6_addr(addresses[i])) - rawcmd = strdup(PING6_COMMAND); + rawcmd = strdup(srcaddr ? "/sbin/ping6 -n -s %d -S %s %s" : PING6_COMMAND); else - rawcmd = strdup(PING_COMMAND); + rawcmd = strdup(srcaddr ? "/sbin/ping -n -s %d -S %s %s" : PING_COMMAND); #else - rawcmd = strdup(PING_COMMAND); + rawcmd = strdup(srcaddr ? "/sbin/ping -n -s %d -S %s %s" : PING_COMMAND); #endif /* does the host address of number of packets argument come first? */ #ifdef PING_PACKETS_FIRST # ifdef PING_HAS_TIMEOUT - asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]); + if (srcaddr) + asprintf (&cmd, rawcmd, timeout_interval, max_packets, srcaddr, addresses[i]); + else + asprintf (&cmd, rawcmd, timeout_interval, max_packets, addresses[i]); # else - asprintf (&cmd, rawcmd, max_packets, addresses[i]); + if (srcaddr) + asprintf (&cmd, rawcmd, max_packets, srcaddr, addresses[i]); + else + asprintf (&cmd, rawcmd, max_packets, addresses[i]); # endif #else asprintf (&cmd, rawcmd, addresses[i], max_packets); @@ -195,6 +202,7 @@ {"link", no_argument, 0, 'L'}, {"use-ipv4", no_argument, 0, '4'}, {"use-ipv6", no_argument, 0, '6'}, + {"src-addr", required_argument, 0, 'S'}, {0, 0, 0, 0} }; @@ -209,7 +217,7 @@ } while (1) { - c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:", longopts, &option); + c = getopt_long (argc, argv, "VvhnL46t:c:w:H:p:S:", longopts, &option); if (c == -1 || c == EOF) break; @@ -278,6 +286,9 @@ case 'w': get_threshold (optarg, &wrta, &wpl); break; + case 'S': + srcaddr = optarg; + break; } } --- check_ping.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807160435.m6G4ZlEh052022>