From owner-svn-ports-all@FreeBSD.ORG Mon Mar 30 15:43:15 2015 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A9073B5C; Mon, 30 Mar 2015 15:43:15 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 94559391; Mon, 30 Mar 2015 15:43:15 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2UFhFgr061614; Mon, 30 Mar 2015 15:43:15 GMT (envelope-from demon@FreeBSD.org) Received: (from demon@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2UFhF2S061612; Mon, 30 Mar 2015 15:43:15 GMT (envelope-from demon@FreeBSD.org) Message-Id: <201503301543.t2UFhF2S061612@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: demon set sender to demon@FreeBSD.org using -f From: Dmitry Sivachenko Date: Mon, 30 Mar 2015 15:43:15 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r382678 - in head/net-mgmt/nagios-check_netsnmp: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2015 15:43:15 -0000 Author: demon Date: Mon Mar 30 15:43:14 2015 New Revision: 382678 URL: https://svnweb.freebsd.org/changeset/ports/382678 QAT: https://qat.redports.org/buildarchive/r382678/ Log: Add "-d" option to specify "domain" to send query to. Defaults to ipv4 if host has ipv4 address, or ipv6 otherwise. Modified: head/net-mgmt/nagios-check_netsnmp/Makefile head/net-mgmt/nagios-check_netsnmp/files/check_netsnmp Modified: head/net-mgmt/nagios-check_netsnmp/Makefile ============================================================================== --- head/net-mgmt/nagios-check_netsnmp/Makefile Mon Mar 30 15:35:12 2015 (r382677) +++ head/net-mgmt/nagios-check_netsnmp/Makefile Mon Mar 30 15:43:14 2015 (r382678) @@ -3,6 +3,7 @@ PORTNAME= check_netsnmp PORTVERSION= 1.0 +PORTREVISION= 1 CATEGORIES= net-mgmt MASTER_SITES= # none PKGNAMEPREFIX= nagios- Modified: head/net-mgmt/nagios-check_netsnmp/files/check_netsnmp ============================================================================== --- head/net-mgmt/nagios-check_netsnmp/files/check_netsnmp Mon Mar 30 15:35:12 2015 (r382677) +++ head/net-mgmt/nagios-check_netsnmp/files/check_netsnmp Mon Mar 30 15:43:14 2015 (r382678) @@ -22,7 +22,7 @@ my $proc = '.1.3.6.1.4.1.2021.2.1.'; my $disk = '.1.3.6.1.4.1.2021.9.1.'; my $file = '.1.3.6.1.4.1.2021.15.1.'; my $swap = '.1.3.6.1.4.1.2021.4.'; -my $exec = '.1.3.6.1.4.1.2021.8.'; +my $exec = '.1.3.6.1.4.1.2021.8.1.'; my $errorFlag = '100'; my $errorMsg = '101'; my $TotalSwap = '.1.3.6.1.4.1.2021.4.3.0'; @@ -32,13 +32,15 @@ my $laLoad5 = '.1.3.6.1.4.1.2021.10.1.3. my $laLoad15 = '.1.3.6.1.4.1.2021.10.1.3.3'; my $errflag = $ERRORS{'OK'}; +my $execMode = 0; -my ($opt_h, $opt_C, $opt_H, $opt_o, $opt_p, $opt_t); +my ($opt_h, $opt_d, $opt_C, $opt_H, $opt_o, $opt_p, $opt_t); Getopt::Long::Configure('bundling'); GetOptions( "h" => \$opt_h, "help" => \$opt_h, "C=s" => \$opt_C, "community=s" => \$opt_C, "H=s" => \$opt_H, "hostname=s" => \$opt_H, + "d=s" => \$opt_d, "domain=s" => \$opt_d, "o=s" => \$opt_o, "oid=s" => \$opt_o, "p=i" => \$opt_p, "port=i" => \$opt_p, "t=i" => \$opt_t, "timeout=i" => \$opt_t @@ -68,9 +70,14 @@ $SIG{'ALRM'} = sub { }; alarm($TIMEOUT * 6); # 1.5 minutes +if (!defined($opt_d)) { + my @addrv4 = gethostbyname($opt_H) or $opt_d = 'udp/ipv6'; +}; + my ($session, $error) = Net::SNMP->session( -timeout => $opt_t || $TIMEOUT, -hostname => $opt_H, + -domain => $opt_d || 'udp/ipv4', -community => $opt_C || 'public', -port => $opt_p || 161 ); @@ -119,7 +126,9 @@ sub checkOID { $baseOID = $file; } else { if ($_[0] =~ /^\d+$/) { - $baseOID = $exec . $_[0] . '.'; + $execMode = 1; + $baseOID = $exec; + $i = $_[0]; } else { $baseOID = $_[0]; } @@ -143,6 +152,7 @@ sub checkOID { $first_error = 0; } $first_query = 0; + last if $execMode > 0; $i++; $tmpOID = $baseOID . $errorFlag . ".$i"; $res = getOID($tmpOID); } @@ -195,7 +205,12 @@ sub checkOID { print "Error obtaining OID $AvailSwap!"; } } else { - my $tmp = getOID("$baseOID$errorMsg.1"); + my $tmp; + if ($execMode > 0) { + $tmp = getOID("$baseOID$errorMsg.$_[0]"); + } else { + $tmp = getOID("$baseOID$errorMsg.1"); + } if (defined($tmp)) { print $tmp; } else {