From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Jul 16 05:10:02 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B6281065676 for ; Wed, 16 Jul 2008 05:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3B5B88FC1A for ; Wed, 16 Jul 2008 05:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m6G5A1RL075805 for ; Wed, 16 Jul 2008 05:10:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m6G5A1GY075804; Wed, 16 Jul 2008 05:10:01 GMT (envelope-from gnats) Resent-Date: Wed, 16 Jul 2008 05:10:01 GMT Resent-Message-Id: <200807160510.m6G5A1GY075804@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Dave Horsfall Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 37F851065672 for ; Wed, 16 Jul 2008 05:01:07 +0000 (UTC) (envelope-from daveh@coreng.com.au) Received: from mippet.ci.com.au (mippet.ci.com.au [192.65.182.30]) by mx1.freebsd.org (Postfix) with ESMTP id AFBCE8FC0C for ; Wed, 16 Jul 2008 05:01:06 +0000 (UTC) (envelope-from daveh@coreng.com.au) Received: from mippet.ci.com.au (localhost [127.0.0.1]) by mippet.ci.com.au (8.14.3/8.14.2/CE070809/cml) with ESMTP id m6G4ZmuC052023; Wed, 16 Jul 2008 14:35:48 +1000 (EST) (envelope-from daveh@mippet.ci.com.au) Received: (from daveh@localhost) by mippet.ci.com.au (8.14.3/8.14.2/Submit) id m6G4ZlEh052022; Wed, 16 Jul 2008 14:35:47 +1000 (EST) (envelope-from daveh) Message-Id: <200807160435.m6G4ZlEh052022@mippet.ci.com.au> Date: Wed, 16 Jul 2008 14:35:47 +1000 (EST) From: Dave Horsfall To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Dave Horsfall Subject: ports/125668: [patch] Extend Nagios check_ping plugin to support source address X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Dave Horsfall List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jul 2008 05:10:02 -0000 >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: