diff --git a/check_snmp/trunk/check_snmp_interfaces b/check_snmp/trunk/check_snmp_interfaces index 5727496..7f235d8 100755 --- a/check_snmp/trunk/check_snmp_interfaces +++ b/check_snmp/trunk/check_snmp_interfaces @@ -28,6 +28,7 @@ use lib qw ( /usr/local/nagios/perl/lib ); use Net::SNMP; use Getopt::Std; +use Socket; $script = "check_snmp_interfaces"; $script_version = "1.1"; @@ -179,9 +180,10 @@ if ($opt_C) { $community = $opt_C; } $exclude_interface = "bull"; -if ($opt_E) { +if (defined($opt_E)) { $exclude_interface = $opt_E; } + if ($opt_w) { $warning = $opt_w; } @@ -205,6 +207,17 @@ $version = "1"; -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 we can't connect using SNMPv1 lets try as SNMPv2 @@ -406,6 +419,7 @@ Usage: $script -H -c [...] Options: -H Hostname or IP address -C Community (default is public) -B To use MIB designed for Brocade San switches + -E Exclude Regexp -d Debug -l Detailed Output (Long service output)