mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 18:33:45 +01:00
Bugfix: Better error handling when DNS resolve fails
This commit is contained in:
parent
a94dec1228
commit
4d4c9cde73
@ -28,6 +28,7 @@
|
|||||||
use lib qw ( /usr/local/nagios/perl/lib );
|
use lib qw ( /usr/local/nagios/perl/lib );
|
||||||
use Net::SNMP;
|
use Net::SNMP;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
|
use Socket;
|
||||||
|
|
||||||
$script = "check_snmp_interfaces";
|
$script = "check_snmp_interfaces";
|
||||||
$script_version = "1.1";
|
$script_version = "1.1";
|
||||||
@ -179,9 +180,10 @@ if ($opt_C) {
|
|||||||
$community = $opt_C;
|
$community = $opt_C;
|
||||||
}
|
}
|
||||||
$exclude_interface = "bull";
|
$exclude_interface = "bull";
|
||||||
if ($opt_E) {
|
if (defined($opt_E)) {
|
||||||
$exclude_interface = $opt_E;
|
$exclude_interface = $opt_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opt_w) {
|
if ($opt_w) {
|
||||||
$warning = $opt_w;
|
$warning = $opt_w;
|
||||||
}
|
}
|
||||||
@ -205,6 +207,17 @@ $version = "1";
|
|||||||
-timeout => $timeout,
|
-timeout => $timeout,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if ( !defined($s) ) {
|
||||||
|
if (!gethostbyname($hostname)) {
|
||||||
|
print "Can't resolve $hostname !\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "Unable to establish SNMP session with $hostname !\n";
|
||||||
|
}
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if ( !defined( $s->get_request($oid_sysDescr) ) ) {
|
if ( !defined( $s->get_request($oid_sysDescr) ) ) {
|
||||||
|
|
||||||
# If we can't connect using SNMPv1 lets try as SNMPv2
|
# If we can't connect using SNMPv1 lets try as SNMPv2
|
||||||
@ -406,6 +419,7 @@ Usage: $script -H <hostname> -c <community> [...]
|
|||||||
Options: -H Hostname or IP address
|
Options: -H Hostname or IP address
|
||||||
-C Community (default is public)
|
-C Community (default is public)
|
||||||
-B To use MIB designed for Brocade San switches
|
-B To use MIB designed for Brocade San switches
|
||||||
|
-E Exclude Regexp
|
||||||
-d Debug
|
-d Debug
|
||||||
-l Detailed Output (Long service output)
|
-l Detailed Output (Long service output)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user