mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 18:33:45 +01:00
Brocade support added in check_snmp_interfaces
This commit is contained in:
parent
2ab18b68b3
commit
adf1af57eb
@ -2,31 +2,35 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# AUTHORS:
|
# AUTHORS:
|
||||||
# Copyright (C) 2003-2010 Opsera Limited. All rights reserved
|
# Based on check_snmp_cisco_ifs by Opsera Limited.
|
||||||
|
# Author: Pall Sigurdsson <palli 'at' opensource.is>
|
||||||
#
|
#
|
||||||
# This file is part of Opsview
|
# This software is free software; you can redistribute it and/or modify
|
||||||
#
|
|
||||||
# Opsview is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# Opsview is distributed in the hope that it will be useful,
|
# This software is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Opsview; if not, write to the Free Software
|
# along with this software; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# ChangeLog
|
||||||
|
# 2010-06-10:
|
||||||
|
# Modified to include -B option for Brocade SAN switches
|
||||||
|
# 2010-02-05:
|
||||||
|
# Initial Release
|
||||||
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;
|
||||||
|
|
||||||
$script = "check_snmp_cisco_ifstatus";
|
$script = "check_snmp_interfaces";
|
||||||
$script_version = "2.1.0";
|
$script_version = "1.1";
|
||||||
|
|
||||||
# SNMP options
|
# SNMP options
|
||||||
$version = "2c";
|
$version = "2c";
|
||||||
@ -52,6 +56,7 @@ $oid_ifinerrors = ".1.3.6.1.2.1.2.2.1.14."; # need to append integer for s
|
|||||||
$oid_ifouterrors = ".1.3.6.1.2.1.2.2.1.20."; # need to append integer for specific interface
|
$oid_ifouterrors = ".1.3.6.1.2.1.2.2.1.20."; # need to append integer for specific interface
|
||||||
$oid_ifoutqlen = ".1.3.6.1.2.1.2.2.1.21."; # need to append integer for specific interface
|
$oid_ifoutqlen = ".1.3.6.1.2.1.2.2.1.21."; # need to append integer for specific interface
|
||||||
my $realbitssec; # Perf data is always in bps, save this data here
|
my $realbitssec; # Perf data is always in bps, save this data here
|
||||||
|
$longServiceOutput = ();
|
||||||
|
|
||||||
# Cisco Specific
|
# Cisco Specific
|
||||||
|
|
||||||
@ -71,8 +76,58 @@ $ifouterrors = "n/a";
|
|||||||
$ifoutqlen = "n/a";
|
$ifoutqlen = "n/a";
|
||||||
$ifoutbitssec = "n/a";
|
$ifoutbitssec = "n/a";
|
||||||
|
|
||||||
$warning = 100000000; # Warning threshold
|
|
||||||
$critical = 100000000; # Critical threshold
|
# swFCPortPhyState OBJECT-TYPE
|
||||||
|
# SYNTAX INTEGER {
|
||||||
|
# noCard (1),
|
||||||
|
# noTransceiver (2),
|
||||||
|
# laserFault (3),
|
||||||
|
# noLight (4),
|
||||||
|
# noSync (5),
|
||||||
|
# inSync (6),
|
||||||
|
# portFault (7),
|
||||||
|
# diagFault (8),
|
||||||
|
# lockRef (9)
|
||||||
|
# }
|
||||||
|
%phyState = ();
|
||||||
|
$phyState{1} = "noCard";
|
||||||
|
$phyState{2} = "noTransceiver";
|
||||||
|
$phyState{3} = "laserFault";
|
||||||
|
$phyState{4} = "noLight";
|
||||||
|
$phyState{5} = "noSync";
|
||||||
|
$phyState{6} = "inSync";
|
||||||
|
$phyState{7} = "portFault";
|
||||||
|
$phyState{8} = "diagFault";
|
||||||
|
$phyState{9} = "lockRef";
|
||||||
|
|
||||||
|
# swFCPortLinkState OBJECT-TYPE
|
||||||
|
# SYNTAX INTEGER {
|
||||||
|
# enabled (1),
|
||||||
|
# disabled (2),
|
||||||
|
# loopback (3)
|
||||||
|
# }
|
||||||
|
%linkState = ();
|
||||||
|
$linkState{1} = "enabled";
|
||||||
|
$linkState{2} = "disabled";
|
||||||
|
$linkState{3} = "loopback";
|
||||||
|
|
||||||
|
%admState = ();
|
||||||
|
$admState{1} = "online";
|
||||||
|
$admState{2} = "offline";
|
||||||
|
$admState{3} = "testing";
|
||||||
|
$admState{4} = "faulty";
|
||||||
|
|
||||||
|
%opState = ();
|
||||||
|
$opState{0} = "unknown";
|
||||||
|
$opState{1} = "online";
|
||||||
|
$opState{2} = "offline";
|
||||||
|
$opState{3} = "testing";
|
||||||
|
$opState{4} = "faulty";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#$warning = 100000000; # Warning threshold
|
||||||
|
#$critical = 100000000; # Critical threshold
|
||||||
|
|
||||||
$hostname = "192.168.10.21";
|
$hostname = "192.168.10.21";
|
||||||
|
|
||||||
@ -80,7 +135,6 @@ $hostname = "192.168.10.21";
|
|||||||
$returnstring = "";
|
$returnstring = "";
|
||||||
|
|
||||||
$community = "public"; # Default community string
|
$community = "public"; # Default community string
|
||||||
$configfilepath = "/usr/local/nagios/etc";
|
|
||||||
|
|
||||||
# Do we have enough information?
|
# Do we have enough information?
|
||||||
if ( @ARGV < 1 ) {
|
if ( @ARGV < 1 ) {
|
||||||
@ -88,7 +142,7 @@ if ( @ARGV < 1 ) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
getopts("hH:C:i:w:c:");
|
getopts("hH:C:BdlE:");
|
||||||
if ($opt_h) {
|
if ($opt_h) {
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -96,18 +150,37 @@ if ($opt_h) {
|
|||||||
if ($opt_H) {
|
if ($opt_H) {
|
||||||
$hostname = $opt_H;
|
$hostname = $opt_H;
|
||||||
|
|
||||||
# print "Hostname $opt_H\n";
|
#print "Hostname $opt_H\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
print "No hostname specified\n";
|
print "No hostname specified\n";
|
||||||
usage();
|
usage();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# -B is for brocade defice
|
||||||
|
if ($opt_B) {
|
||||||
|
$oid_PhyState = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.3.";
|
||||||
|
$oid_OpStatus = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.4.";
|
||||||
|
$oid_AdmStatus = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.5.";
|
||||||
|
$oid_LinkState = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.6.";
|
||||||
|
$oid_PortName = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.36.";
|
||||||
|
$oid_PortSpecifier = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.37.";
|
||||||
|
|
||||||
|
|
||||||
|
$oid_base = ".1.3.6.1.4.1.1588.2.1.1.1.6.2.1.1.";
|
||||||
|
$oid_ifadminstatus = $oid_LinkState; # need to append integer for specific interface
|
||||||
|
$oid_ifoperstatus = $oid_OpStatus ; # need to append integer for specific interface
|
||||||
|
$oid_ifdescr = $oid_PortSpecifier;
|
||||||
|
}
|
||||||
|
|
||||||
if ($opt_C) {
|
if ($opt_C) {
|
||||||
$community = $opt_C;
|
$community = $opt_C;
|
||||||
}
|
}
|
||||||
if ($opt_i) {
|
$exclude_interface = "bull";
|
||||||
$target_interface = $opt_i;
|
if ($opt_E) {
|
||||||
|
$exclude_interface = $opt_E;
|
||||||
}
|
}
|
||||||
if ($opt_w) {
|
if ($opt_w) {
|
||||||
$warning = $opt_w;
|
$warning = $opt_w;
|
||||||
@ -150,44 +223,40 @@ if ( !defined( $s->get_request($oid_sysDescr) ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( find_match() == 0 ) {
|
$status = check_interfaces();
|
||||||
probe_interface();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$status = 2;
|
|
||||||
print "Interface $target_interface not found on device $hostname\n";
|
|
||||||
exit $status;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Close the session
|
# Close the session
|
||||||
$s->close();
|
$s->close();
|
||||||
|
|
||||||
if ( $status == 0 ) {
|
if ( $status == 0 ) {
|
||||||
print "Status is OK - $returnstring\n";
|
print "OK - $returnstring\n";
|
||||||
exit $status;
|
exit $status;
|
||||||
}
|
}
|
||||||
elsif ( $status == 1 ) {
|
elsif ( $status == 1 ) {
|
||||||
print "Status is a Warning Level - $returnstring\n";
|
print "Warning - $returnstring\n";
|
||||||
exit $status;
|
exit $status;
|
||||||
}
|
}
|
||||||
elsif ( $status == 2 ) {
|
elsif ( $status == 2 ) {
|
||||||
print "Status is CRITICAL - $returnstring\n";
|
print "CRITICAL - $returnstring\n";
|
||||||
exit $status;
|
exit $status;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Plugin error! SNMP status unknown\n";
|
print "Plugin error! SNMP status unknown $returnstring\n";
|
||||||
exit $status;
|
exit $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 2;
|
exit 3;
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Finds match for supplied interface name
|
# Finds match for supplied interface name
|
||||||
#################################################
|
#################################################
|
||||||
|
|
||||||
sub find_match {
|
sub check_interfaces {
|
||||||
|
|
||||||
my $resultat = $s->get_table($oid_base);
|
my $resultat = $s->get_table($oid_base);
|
||||||
|
#print $oid_base;
|
||||||
|
|
||||||
if (!defined($resultat)) {
|
if (!defined($resultat)) {
|
||||||
printf("ERROR: NHR table : %s.\n", $s->error);
|
printf("ERROR: NHR table : %s.\n", $s->error);
|
||||||
@ -214,6 +283,7 @@ foreach my $key ( keys %$resultat) {
|
|||||||
print "Status is a Warning Level - SNMP agent not responding\n";
|
print "Status is a Warning Level - SNMP agent not responding\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
print "Status is a Warning Level - SNMP OID does not exist\n";
|
print "Status is a Warning Level - SNMP OID does not exist\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
@ -233,6 +303,7 @@ foreach my $key ( keys %$resultat) {
|
|||||||
|
|
||||||
# Weed out empty entries
|
# Weed out empty entries
|
||||||
@keys = grep(!/^$/, @keys);
|
@keys = grep(!/^$/, @keys);
|
||||||
|
#@keys = sort(@keys);
|
||||||
|
|
||||||
foreach $index ( @keys ) {
|
foreach $index ( @keys ) {
|
||||||
my $target_interface_index = $index;
|
my $target_interface_index = $index;
|
||||||
@ -242,8 +313,9 @@ foreach my $key ( keys %$resultat) {
|
|||||||
else {
|
else {
|
||||||
foreach ( $s->var_bind_names() ) {
|
foreach ( $s->var_bind_names() ) {
|
||||||
$temp_interface_descr = $s->var_bind_list()->{$_};
|
$temp_interface_descr = $s->var_bind_list()->{$_};
|
||||||
|
$temp_interface_descr = sprintf("%02d", $temp_interface_descr) if $opt_B;
|
||||||
}
|
}
|
||||||
next if ($temp_interface_descr !~ m/$target_interface/);
|
next if ($temp_interface_descr =~ m/$exclude_interface/);
|
||||||
if ( lc($temp_interface_descr) eq lc($target_interface) ) {
|
if ( lc($temp_interface_descr) eq lc($target_interface) ) {
|
||||||
$target_interface_index = $index;
|
$target_interface_index = $index;
|
||||||
}
|
}
|
||||||
@ -267,9 +339,17 @@ foreach my $key ( keys %$resultat) {
|
|||||||
foreach ( $s->var_bind_names() ) {
|
foreach ( $s->var_bind_names() ) {
|
||||||
$ifoperstatus = $s->var_bind_list()->{$_};
|
$ifoperstatus = $s->var_bind_list()->{$_};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$temp = "port $temp_interface_descr is $opState{$ifoperstatus} ($ifoperstatus) / $linkState{$ifadminstatus} ($ifadminstatus) \n";
|
||||||
|
push(@longServiceOutput, $temp);
|
||||||
|
if ($opt_d) {
|
||||||
|
print ": $temp_interface_descr: $opState{$ifoperstatus} ($ifoperstatus) / $linkState{$ifadminstatus} ($ifadminstatus) \n";
|
||||||
}
|
}
|
||||||
############################
|
############################
|
||||||
if ( $ifoperstatus != $ifadminstatus ) {
|
if ( $ifoperstatus != $ifadminstatus ) {
|
||||||
|
if ($opt_B && $ifadminstatus == 2) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
push(@list_interfaces, $temp_interface_descr);
|
push(@list_interfaces, $temp_interface_descr);
|
||||||
#print ": $temp_interface_descr: $ifoperstatus / $ifadminstatus \n";
|
#print ": $temp_interface_descr: $ifoperstatus / $ifadminstatus \n";
|
||||||
}
|
}
|
||||||
@ -278,219 +358,36 @@ foreach my $key ( keys %$resultat) {
|
|||||||
|
|
||||||
# $index++;
|
# $index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Edit The return message and exit to main.
|
||||||
|
$returnmessage = "";
|
||||||
|
$returncode = 3;
|
||||||
|
sort(@list_interfaces);
|
||||||
my $list_interfaces = @list_interfaces;
|
my $list_interfaces = @list_interfaces;
|
||||||
my $keys = @keys;
|
my $keys = @keys;
|
||||||
if ($list_interfaces > 0) {
|
if ($list_interfaces > 0) {
|
||||||
print "$list_interfaces out of $keys in inappropriate state: @list_interfaces \n";
|
append("$list_interfaces out of $keys in inappropriate state: @list_interfaces\n");
|
||||||
exit 1
|
$returncode=1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "All $keys interfaces in appropriate state\n";
|
append("All $keys interfaces in appropriate state\n");
|
||||||
exit 0
|
$returncode=0;
|
||||||
}
|
|
||||||
print "@list_interfaces \n";
|
|
||||||
if ( $target_interface_index == 0 ) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
# Gathers data about target interface #
|
|
||||||
####################################################################
|
|
||||||
|
|
||||||
sub probe_interface {
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifdescr . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifdescr = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_iftype . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$iftype = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifmtu . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifmtu = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifspeed . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifspeed = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifadminstatus . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifadminstatus = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifoperstatus . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifoperstatus = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_iflastchange . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$iflastchange = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifinerrors . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifinerrors = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifouterrors . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifouterrors = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_ifoutqlen . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifoutqlen = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$oid_temp = $oid_locIfOutBitsSec . $target_interface_index;
|
|
||||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
|
||||||
$ifoutbitssec = -1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ( $s->var_bind_names() ) {
|
|
||||||
$ifoutbitssec = $s->var_bind_list()->{$_};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
############################
|
|
||||||
|
|
||||||
$errorstring = "";
|
|
||||||
|
|
||||||
# Sets warning / critical levels if interface down
|
|
||||||
|
|
||||||
if ( $ifadminstatus eq "1" ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$status = 1;
|
|
||||||
$errorstring = "INTERFACE ADMINISTRATIVELY DOWN:";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $ifoperstatus eq "1" ) {
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$status = 2;
|
|
||||||
$errorstring = "INTERFACE DOWN:";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Sets warning / critical levels if ifoutbitssec exceeds threshold
|
# If -l was requested, sort the interface list before returning.
|
||||||
|
if ($opt_l) {
|
||||||
if ( $status < 1 ) {
|
$longOutput = "";
|
||||||
|
@longServiceOutput = sort(@longServiceOutput);
|
||||||
# Don't bother is status is down
|
foreach (@longServiceOutput) {
|
||||||
if ( $ifoutbitssec > $critical ) {
|
append($_) ;
|
||||||
$errorstring = "HIGH THROUGHPUT:";
|
|
||||||
$status = 2;
|
|
||||||
}
|
|
||||||
elsif ( $ifoutbitssec > $warning ) {
|
|
||||||
$errorstring = "HIGH THROUGHPUT:";
|
|
||||||
$status = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mangles interface speed
|
|
||||||
|
|
||||||
my $mbps = $ifspeed / 1000000;
|
|
||||||
if ( $mbps < 1 ) {
|
|
||||||
$ifspeed = $ifspeed / 1000;
|
|
||||||
$ifspeed = "$ifspeed Kbps";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ifspeed = "$mbps Mbps";
|
|
||||||
}
|
|
||||||
|
|
||||||
$realbitssec = $ifoutbitssec;
|
return $returncode;
|
||||||
|
|
||||||
# Mangles IfOutBitsSec stat to bits / kbits
|
|
||||||
if ( $ifoutbitssec > 0 ) {
|
|
||||||
my $mbps = $ifoutbitssec / 1000000;
|
|
||||||
if ( $mbps < 1 ) {
|
|
||||||
$ifoutbitssec = $ifoutbitssec / 1000;
|
|
||||||
$ifoutbitssec = "$ifoutbitssec Kbps";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ifoutbitssec = "$mbps Mbps";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ( $ifoutbitssec < 0 ) {
|
|
||||||
$ifoutbitssec = "N/A";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ifoutbitssec = "0 bps";
|
|
||||||
}
|
|
||||||
|
|
||||||
# Returns string relating to interface media
|
|
||||||
my $iftype_string = return_interfacetype($iftype);
|
|
||||||
|
|
||||||
if ( $status == 0 ) {
|
|
||||||
$temp = sprintf "$ifdescr ($iftype_string) - Current: $ifoutbitssec, Limit: $ifspeed, MTU: $ifmtu, Last change: $iflastchange, STATS:(in errors: $ifinerrors, out errors: $ifouterrors, queue length: $ifoutqlen)";
|
|
||||||
append($temp);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$temp = sprintf "$errorstring $ifdescr ($iftype_string) - Current: $ifoutbitssec, Limit: $ifspeed, MTU: $ifmtu, Last change: $iflastchange, STATS:(in errors: $ifinerrors, out errors: $ifouterrors, queue length: $ifoutqlen)";
|
|
||||||
append($temp);
|
|
||||||
}
|
|
||||||
$perfinfo = sprintf "|bits/sec=$realbitssec";
|
|
||||||
append($perfinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
@ -502,19 +399,18 @@ sub usage {
|
|||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
$script v$script_version
|
$script v$script_version
|
||||||
|
|
||||||
Monitors status of specific Ethernet interface.
|
Monitors status of all interfaces via SNMP
|
||||||
|
|
||||||
Usage: $script -H <hostname> -c <community> [...]
|
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)
|
||||||
-i Target interface name
|
-B To use MIB designed for Brocade San switches
|
||||||
Eg: Serial0/0, FastEthernet0/12
|
-d Debug
|
||||||
-w Warning threshold - Out bits / sec
|
-l Detailed Output (Long service output)
|
||||||
-c Critical threshold - Out bits / sec
|
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
Copyright (C) 2003-2010 Opsera Limited. All rights reserved
|
Copyright (C) 2003-2010 Pall Sigurdsson <palli 'at' opensource.is>
|
||||||
|
|
||||||
This program is free software; you can redistribute it or modify
|
This program is free software; you can redistribute it or modify
|
||||||
it under the terms of the GNU General Public License
|
it under the terms of the GNU General Public License
|
||||||
@ -781,3 +677,4 @@ sub return_interfacetype {
|
|||||||
return ($returnstring);
|
return ($returnstring);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user