aboutsummaryrefslogtreecommitdiff
path: root/net-mgmt/nagios-check_netsnmp
diff options
context:
space:
mode:
authorDmitry Sivachenko <demon@FreeBSD.org>2015-03-30 15:43:14 +0000
committerDmitry Sivachenko <demon@FreeBSD.org>2015-03-30 15:43:14 +0000
commit673ab771a285c8e4ea80a4474b5ca5a72dbf674c (patch)
tree74456fa565049d0487956071a689d866fc3e4c95 /net-mgmt/nagios-check_netsnmp
parent01d633cd1b805939e8b871a3608985a3bab55f04 (diff)
downloadports-673ab771a285c8e4ea80a4474b5ca5a72dbf674c.tar.gz
ports-673ab771a285c8e4ea80a4474b5ca5a72dbf674c.zip
Notes
Diffstat (limited to 'net-mgmt/nagios-check_netsnmp')
-rw-r--r--net-mgmt/nagios-check_netsnmp/Makefile1
-rw-r--r--net-mgmt/nagios-check_netsnmp/files/check_netsnmp23
2 files changed, 20 insertions, 4 deletions
diff --git a/net-mgmt/nagios-check_netsnmp/Makefile b/net-mgmt/nagios-check_netsnmp/Makefile
index 768484bbda2b..505af866417c 100644
--- a/net-mgmt/nagios-check_netsnmp/Makefile
+++ b/net-mgmt/nagios-check_netsnmp/Makefile
@@ -3,6 +3,7 @@
PORTNAME= check_netsnmp
PORTVERSION= 1.0
+PORTREVISION= 1
CATEGORIES= net-mgmt
MASTER_SITES= # none
PKGNAMEPREFIX= nagios-
diff --git a/net-mgmt/nagios-check_netsnmp/files/check_netsnmp b/net-mgmt/nagios-check_netsnmp/files/check_netsnmp
index 42f6eb250b25..6d076e0d7a88 100644
--- a/net-mgmt/nagios-check_netsnmp/files/check_netsnmp
+++ b/net-mgmt/nagios-check_netsnmp/files/check_netsnmp
@@ -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.2';
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 {