#! /usr/bin/perl -wT #---------------------------------------------------------------------- # # Author: Martin Fuerstenau, martin.fuerstenau_at_genesix.de # Date: 01.08.2006 # # Purpose: # Checking the status of network interface teaming on Windows # with Broadcomm BASP. # # Changes: # # - It is now checked that a minimum of 2 NICs is engaged. If there # is only one NIC a warning is given # Martin Fuerstenau, 04.08.2006 # # - btspLinkPacketsRetried is now checked. If this # counter is growing within the given interval of 5 sec. # you cann assume that there is a problem with the # backplane or with the backbone # Martin Fuerstenau, 04.08.2006 # # Synopsis: # # check_teaming_broadcom -H [-C ] [-v ] # #---------------------------------------------------------------------- use strict; use Getopt::Long; use vars qw($VERSION $HELP $hostname $host $PROGNAME %INTERFACE_ERROR); use vars qw($community @result $snmpversion $warning $critical $WHATSUP $error); use lib "/usr/lib/nagios/ops_plugins" ; use utils qw(%ERRORS &print_revision &support &usage); # Get the right package from CPAN and install it use SNMP::Util; use SNMP::Util_env; &SNMP::initMib(); $PROGNAME = "check_teaming_broadcom"; $ENV{'PATH'}=''; $ENV{'BASH_ENV'}=''; $ENV{'ENV'}=''; $ENV{'MIBDIRS'} = '/usr/share/snmp/mibs'; $ENV{'MIBFILES'} = '/usr/share/snmp/mibs/BASP-Config-MIB.txt: /usr/share/snmp/mibs/BASP-Statistics-MIB.txt'; Getopt::Long::Configure('bundling'); GetOptions ("V" => \$VERSION, "version" => \$VERSION, "h" => \$HELP, "help" => \$HELP, "v=s" => \$snmpversion, "snmpversion=s" => \$snmpversion, "H=s" => \$hostname, "hostname=s" => \$hostname, "C=s" => \$community, "community=s" => \$community); if ($VERSION) { print_revision($PROGNAME,'$Revision: 1.0 $'); exit $ERRORS{'OK'}; } if ($HELP) { print_help(); exit $ERRORS{'OK'}; } if (!$hostname) { print_usage(); usage("Host name/address not specified\n\n"); } if ($hostname =~ /([-.A-Za-z0-9]+)/) { $host = $1; } if (!$host) { print_usage(); usage("Invalid host: $hostname\n\n"); } if (!$community) { $community = "public"; } if (!$snmpversion) { $snmpversion = "1"; } if (!($snmpversion eq "1" || $snmpversion eq "2c")) { print "Error! Only SNMP V1 or 2c supported!\n"; print "Wrong version submitted.\n"; exit 2; } $WHATSUP=get_teaming(); if ($WHATSUP == 0 ) { exit $ERRORS{'OK'}; } if ($WHATSUP == 1 ) { exit $ERRORS{'WARNING'}; } if ($WHATSUP == 2 ) { exit $ERRORS{'CRITICAL'}; } # --------------- Begin subroutines ---------------------------------------- # We initialize the snmp connection sub get_teaming { my $NumElements = 0; my $NumElementsRow = 8; my $NumRows = 0; my $ROWCNT = 0; my $WARN_ME = 0; my $LOOPCNT; my @retry_counter; my $snmp = new SNMP::Util(-device => $hostname, -community => $community, -snmpversion => $snmpversion, -timeout => 5, -retry => 0, -poll => 'off', -verbose => 'on', -errmode => 'return', -delimiter => ' ', ); my $snmp2 = new SNMP::Util(-device => $hostname, -community => $community, -snmpversion => $snmpversion, -timeout => 5, -retry => 0, -poll => 'off', -verbose => 'on', -errmode => 'return', -delimiter => ' ', ); if (!$snmp) { print "Warning! "; print "Server $hostname not reachable!"; $WARN_ME = 1; } # Well - we get the f...ing data, but only is there is somethinf in $snmp if ($snmp) { @result = $snmp->walk(-format => 'ne', -oids =>['BASP-Config-MIB::btpLiveLinkIp','BASP-Config-MIB::btpMemberType','BASP-Config-MIB::btpMemberState','BASP-Statistics-MIB::btspLinkPacketsRetried'], -print => 'off'); if ($snmp->error) { print "Critical! "; $error = $snmp->errmsg; print "snmp error = $error"; $WARN_ME = 2; } else { # Now we create our coordinate system for getting the data from the array $NumElements = @result; $NumRows = $NumElements/$NumElementsRow; if ($NumElements == 0) { print "Warning! No data received from host!"; $WARN_ME = 1; } else { for ( $LOOPCNT=0;$LOOPCNT<$NumRows;$LOOPCNT++) { if ($NumRows == 1) { print "Warning! There is only one network card available.
That should not be!
"; $WARN_ME = 1; } print "LiveLinkIp: $result[$ROWCNT + 1] Balancing/Standby: $result[$ROWCNT + 3]
"; if ($result[$ROWCNT + 5] eq "unknown" ) { print "Critical! Interface Member State: Unknown.
"; $WARN_ME = 2; } if ($result[$ROWCNT + 5] eq "link-up-not-join-traffic" ) { if ($result[$ROWCNT + 3] eq "load-balance" ) { print "Critical! Interface Member State: Link is up, no join traffic.
"; $WARN_ME = 2; } if ($result[$ROWCNT + 3] eq "standby" ) { # We wait for 5 seconds get again the retry counter and compare it with the first one # If the counter grows we have a problem with the switch or the backbone sleep 5; @retry_counter = $snmp2->walk(-format => 'ne', -oids =>['BASP-Statistics-MIB::btspLinkPacketsRetried'], -print => 'off'); if ($result[$ROWCNT + 7] < $retry_counter[$LOOPCNT + 2] ) { print "Warning! The retry counter is growing!
"; print "Maybe there is a problem with the switch itself (backplane or backbone)
"; print "The link itself is up - it works fine.
"; $WARN_ME = 1; } else { print "Ok! Link is up - it works fine.
"; } } } if ($result[$ROWCNT + 5] eq "disable-not-join-traffic" ) { print "Critical! Interface Member State: No link signal, no join traffic.
"; $WARN_ME = 2; } if ($result[$ROWCNT + 5] eq "join-traffic" ) { print "Ok! This interface works fine.
"; } $ROWCNT = $ROWCNT + $NumElementsRow; } } } } return $WARN_ME; } sub print_usage { print "\nUsage: $PROGNAME -H [-C community] [-v SNMP Version]\n\n"; print "or\n"; print "\nUsage: $PROGNAME -V for version.\n\n"; print "or\n"; print "\nUsage: $PROGNAME -h for help.\n\n"; } sub print_help { print_revision($PROGNAME,'$Revision: 1.0 $'); print "Copyright (c) 2006 Martin Fuerstenau - martin.fuerstenau_at_genesix.de\n"; print "This plugin checks the status of network interface teaming on Windows with Broadcomm BASP.\n"; print_usage(); print " -H, --hostname=HOST Name or IP address of host to check\n"; print " -C, --community=community SNMPv1 community (default public)\n\n"; print " -v, --snmpversion=snmpversion Version of the SNMP protocol. At present version 1 or 2c\n\n"; print " -h, --help Short help message\n\n"; print " -V, --version Prints version of the plugin\n\n"; print "This plugin uses the 'snmpget' command included with the NET-SNMP package.\n"; print "If you don't have the package installed, you will need to download it from\n"; print "http://net-snmp.sourceforge.net before you can use this plugin.\n\n"; print "This plugin also make use of a enhanced version the perl module SNMP::Util .\n"; print "You will find it enclosed with this plugin. Be shure it is installed.\n\n"; support(); print "\n"; }