mirror of
https://github.com/opinkerfi/nagios-plugins.git
synced 2024-11-22 02:13:44 +01:00
Ouch this is such an ugly hack
This commit is contained in:
parent
5dfa2918f4
commit
e60a53daf9
2
check_emc_clariion/trunk/capacity.cli
Normal file
2
check_emc_clariion/trunk/capacity.cli
Normal file
@ -0,0 +1,2 @@
|
||||
show pool capacity
|
||||
quit
|
305
check_emc_clariion/trunk/check_emc_centera.pl
Normal file
305
check_emc_clariion/trunk/check_emc_centera.pl
Normal file
@ -0,0 +1,305 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# check_emc_centera.pl - checks the EMC CENTERA storage devices
|
||||
# Copyright (C) 2008 NETWAYS GmbH, www.netways.de
|
||||
# Author: Michael Streb <michael.streb@netways.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# $Id: check_emc.pl 1725 2007-07-31 13:11:06Z mstreb $
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# basic requirements
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use Pod::Usage;
|
||||
use POSIX;
|
||||
|
||||
# predeclared subs
|
||||
use subs qw/print_help check_value bool_state trim/;
|
||||
|
||||
# predeclared vars
|
||||
use vars qw (
|
||||
$PROGNAME
|
||||
$VERSION
|
||||
$JAVA
|
||||
$CENTERA_VIEWER
|
||||
|
||||
%state_names
|
||||
$state
|
||||
|
||||
$opt_host
|
||||
$opt_user
|
||||
$opt_pass
|
||||
$opt_node
|
||||
$opt_pool
|
||||
$node_name
|
||||
$opt_verbose
|
||||
$opt_help
|
||||
$opt_checktype
|
||||
$opt_script
|
||||
$opt_man
|
||||
|
||||
$output
|
||||
|
||||
);
|
||||
|
||||
my $dummy;
|
||||
|
||||
# Main values
|
||||
$PROGNAME = basename($0);
|
||||
$VERSION = '1.1';
|
||||
$JAVA = '/usr/bin/java';
|
||||
$CENTERA_VIEWER = "/usr/local/nagios/libexec/EMC/CenteraViewer\.jar";
|
||||
|
||||
# Nagios exit states
|
||||
our %states = (
|
||||
OK => 0,
|
||||
WARNING => 1,
|
||||
CRITICAL => 2,
|
||||
UNKNOWN => 3
|
||||
);
|
||||
|
||||
# Nagios state names
|
||||
%state_names = (
|
||||
0 => 'OK',
|
||||
1 => 'WARNING',
|
||||
2 => 'CRITICAL',
|
||||
3 => 'UNKNOWN'
|
||||
);
|
||||
|
||||
# Get the options from cl
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions(
|
||||
'h' => \$opt_help,
|
||||
'H=s' => \$opt_host,
|
||||
'u=s' => \$opt_user,
|
||||
'p=s' => \$opt_pass,
|
||||
'node=s' => \$opt_node,
|
||||
'pool=s' => \$opt_pool,
|
||||
't=s', => \$opt_checktype,
|
||||
'script=s', => \$opt_script,
|
||||
'man', => \$opt_man
|
||||
)
|
||||
|| print_help( 1, 'Please check your options!' );
|
||||
|
||||
# If somebody wants to the help ...
|
||||
if ($opt_help) {
|
||||
print_help(1);
|
||||
}
|
||||
elsif ($opt_man) {
|
||||
print_help(99);
|
||||
}
|
||||
|
||||
# Check if all needed options present.
|
||||
if ( $opt_host && $opt_checktype && $opt_user && $opt_pass && $opt_script) {
|
||||
# do the work
|
||||
if ($opt_checktype eq "node_status" && $opt_node ne "") {
|
||||
check_node_status();
|
||||
}
|
||||
if ($opt_checktype eq "capacity" && $opt_pool ne "") {
|
||||
check_pool_capacity();
|
||||
}
|
||||
print_help(1, 'Wrong parameters specified!');
|
||||
}
|
||||
else {
|
||||
|
||||
print_help( 1, 'Too few options!' );
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# THE SUBS:
|
||||
# -------------------------
|
||||
|
||||
# check_node_status();
|
||||
# checks the node status of the centera devices
|
||||
sub check_node_status {
|
||||
open (VIEWEROUT ,"$JAVA -cp $CENTERA_VIEWER com.filepool.remote.cli.CLI -u $opt_user -p $opt_pass -ip $opt_host -script $opt_script |");
|
||||
my $node_line = 0;
|
||||
my $error_count = 0;
|
||||
my $access_node = 0;
|
||||
while (<VIEWEROUT>) {
|
||||
chomp $_;
|
||||
if ($_ =~ m/Node\s+($opt_node)/ ) {
|
||||
# got an DPE line
|
||||
$node_line = 1;
|
||||
$node_name = $1;
|
||||
$access_node = 0;
|
||||
next;
|
||||
}
|
||||
if ($node_line == 1) {
|
||||
my $status;
|
||||
my $roles;
|
||||
if ($_ =~ m/^\s+Status:\s+(\w+)$/) {
|
||||
$status = $1;
|
||||
if ($status =~ m/on/) {
|
||||
$output = "$node_name: Status $status; ";
|
||||
} else {
|
||||
$output = "$node_name: Status $status; ";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
if ($_ =~ m/Roles:\s+(.*)/) {
|
||||
$roles = $1;
|
||||
if ($roles =~ m/access/) {
|
||||
$output .= "Roles $roles";
|
||||
$access_node = 1;
|
||||
} else {
|
||||
$output .= "Roles $roles";
|
||||
$node_line = 0;
|
||||
}
|
||||
if ($access_node) {;
|
||||
$output .= "; ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($access_node) {
|
||||
if ($_ =~ m/Hardware\sFailures\/Exceptions:\s+\w+:connected/) {
|
||||
$output .= "access node connected";
|
||||
$node_line = 0;
|
||||
} elsif ($_ =~ m/Hardware\sFailures\/Exceptions:\s+\w+/) {
|
||||
$output .= "access node NOT connected";
|
||||
$node_line = 0;
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close (VIEWEROUT);
|
||||
|
||||
if ($error_count == 0 && $output ne "") {
|
||||
$state = 'OK';
|
||||
} elsif ($output eq "" ) {
|
||||
$output = "UNKNOWN: node $opt_node not found";
|
||||
$state = 'UNKNOWN';
|
||||
} else {
|
||||
$state = 'CRITICAL';
|
||||
}
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
|
||||
}
|
||||
|
||||
# check_pool_capacity();
|
||||
# checks the node status of the centera devices
|
||||
sub check_pool_capacity {
|
||||
open (VIEWEROUT ,"$JAVA -cp $CENTERA_VIEWER com.filepool.remote.cli.CLI -u $opt_user -p $opt_pass -ip $opt_host -script $opt_script |");
|
||||
my @values;
|
||||
while (<VIEWEROUT>) {
|
||||
chomp $_;
|
||||
if ($_ =~ m/^$opt_pool/ ) {
|
||||
@values = split(/\s+/, $_);
|
||||
}
|
||||
}
|
||||
close (VIEWEROUT);
|
||||
|
||||
# strip out the seperator
|
||||
$values[1] =~ s/,//g;
|
||||
$values[3] =~ s/,//g;
|
||||
$values[5] =~ s/,//g;
|
||||
|
||||
$output = "Pool $opt_pool: Size: $values[1] $values[2], Used: $values[3] $values[4] , Free: $values[5] $values[6]";
|
||||
print $output."\n";
|
||||
exit $states{'OK'};
|
||||
|
||||
}
|
||||
|
||||
# print_help($level, $msg);
|
||||
# prints some message and the POD DOC
|
||||
sub print_help {
|
||||
my ( $level, $msg ) = @_;
|
||||
$level = 0 unless ($level);
|
||||
pod2usage(
|
||||
{
|
||||
-message => $msg,
|
||||
-verbose => $level
|
||||
}
|
||||
);
|
||||
|
||||
exit( $states{UNKNOWN} );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
check_emc.pl - Checks EMC SAN devies for NAGIOS.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
check_emc.pl -h
|
||||
|
||||
check_emc.pl --man
|
||||
|
||||
check_emc.pl -H <host> -t <checktype>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<check_emc.pl> recieves the data from the emc devices via navicli.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-h>
|
||||
|
||||
Display this helpmessage.
|
||||
|
||||
=item B<-H>
|
||||
|
||||
The hostname or ipaddress of the emc centera device.
|
||||
|
||||
=item B<-t>
|
||||
|
||||
The check type to execute:
|
||||
|
||||
the following checks are currently available
|
||||
|
||||
node_status - checks the status of the centera nodes
|
||||
|
||||
capacity - check the drive usage
|
||||
|
||||
=item B<-u>
|
||||
|
||||
administrative user used for the cli connection
|
||||
|
||||
=item B<-p>
|
||||
|
||||
administrative password used for the cli connection
|
||||
|
||||
=item B<--node>
|
||||
|
||||
the cluster node to check (ony used with check type node_status)
|
||||
|
||||
=item B<--script>
|
||||
|
||||
cli script with commands executed on the centera command line
|
||||
|
||||
=cut
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id: check_emc.pl 1725 2008-04-16 13:11:06Z mstreb $
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
NETWAYS GmbH, 2008, http://www.netways.de.
|
||||
|
||||
Written by Michael Streb <michael.streb@netways.de>.
|
||||
|
||||
Please report bugs through the contact of Nagios Exchange, http://www.nagiosexchange.org.
|
679
check_emc_clariion/trunk/check_emc_clariion.pl
Normal file
679
check_emc_clariion/trunk/check_emc_clariion.pl
Normal file
@ -0,0 +1,679 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# nagios: -epn
|
||||
# ------------------------------------------------------------------------------
|
||||
# check_emc_clariion.pl - checks the EMC CLARIION SAN devices
|
||||
# Copyright (C) 2005 NETWAYS GmbH, www.netways.de
|
||||
# Author: Michael Streb <michael.streb@netways.de>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
# $Id$
|
||||
# ------------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
# basic requirements
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use Pod::Usage;
|
||||
|
||||
# predeclared subs
|
||||
use subs qw/print_help check_sp check_disk check_portstate check_hbastate check_cache check_faults/;
|
||||
|
||||
# predeclared vars
|
||||
use vars qw (
|
||||
$PROGNAME
|
||||
$VERSION
|
||||
$NAVICLI
|
||||
$NAVISECCLI
|
||||
|
||||
%state_names
|
||||
$state
|
||||
|
||||
$opt_host
|
||||
$opt_sp
|
||||
$opt_verbose
|
||||
$opt_help
|
||||
$opt_checktype
|
||||
$opt_pathcount
|
||||
$opt_node
|
||||
$opt_user
|
||||
$opt_password
|
||||
|
||||
$output
|
||||
|
||||
$secure
|
||||
|
||||
);
|
||||
|
||||
my $output;
|
||||
|
||||
### add some declaration in order to manage the --port option for check_portstate();
|
||||
my $opt_port;
|
||||
$opt_port=-1;
|
||||
|
||||
# a variable in order to manage the secure mode of Navicli
|
||||
my $secure;
|
||||
$secure=0;
|
||||
|
||||
# Main values
|
||||
$PROGNAME = basename($0);
|
||||
$VERSION = '1.0';
|
||||
$NAVICLI = '/opt/Navisphere/bin/navicli';
|
||||
$NAVISECCLI = '/opt/Navisphere/bin/naviseccli';
|
||||
|
||||
# Nagios exit states
|
||||
our %states = (
|
||||
OK => 0,
|
||||
WARNING => 1,
|
||||
CRITICAL => 2,
|
||||
UNKNOWN => 3
|
||||
);
|
||||
|
||||
# Nagios state names
|
||||
%state_names = (
|
||||
0 => 'OK',
|
||||
1 => 'WARNING',
|
||||
2 => 'CRITICAL',
|
||||
3 => 'UNKNOWN'
|
||||
);
|
||||
|
||||
# Get the options from cl
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions(
|
||||
'h' => \$opt_help,
|
||||
'help' => \$opt_help,
|
||||
'H=s' => \$opt_host,
|
||||
'node=s' => \$opt_node,
|
||||
'sp=s' => \$opt_sp,
|
||||
't=s' => \$opt_checktype,
|
||||
'u=s' => \$opt_user,
|
||||
'p=s' => \$opt_password,
|
||||
'port=s' => \$opt_port,
|
||||
'paths=s' => \$opt_pathcount
|
||||
) || print_help(2);
|
||||
|
||||
# If somebody wants to the help ...
|
||||
if ($opt_help) {
|
||||
print_help(2);
|
||||
}
|
||||
# check if user and password for Naviseccli is given
|
||||
# If it is providen, then it passes in secure mode for the command to the array.
|
||||
# else we are staying in navicli mode
|
||||
if ( $opt_user && $opt_password ) {
|
||||
$secure = 1;
|
||||
}
|
||||
|
||||
# Check if all needed options present.
|
||||
if ( $opt_host && $opt_checktype ) {
|
||||
# do the work
|
||||
if ($opt_checktype eq "sp" && $opt_sp ne "") {
|
||||
check_sp();
|
||||
}
|
||||
if ($opt_checktype eq "disk") {
|
||||
check_disk();
|
||||
}
|
||||
if ($opt_checktype eq "cache") {
|
||||
check_cache();
|
||||
}
|
||||
if ($opt_checktype eq "faults") {
|
||||
check_faults();
|
||||
}
|
||||
if ($opt_checktype eq "portstate" && $opt_sp ne "") {
|
||||
check_portstate();
|
||||
}
|
||||
if ($opt_checktype eq "hbastate" && $opt_pathcount ne "" && $opt_node ne "") {
|
||||
check_hbastate();
|
||||
}
|
||||
print_help(1, 'Wrong parameters specified!');
|
||||
}
|
||||
else {
|
||||
print_help(2);
|
||||
}
|
||||
|
||||
# -------------------------
|
||||
# THE SUBS:
|
||||
# -------------------------
|
||||
|
||||
# check_sp();
|
||||
# check state of the storage processors
|
||||
sub check_sp {
|
||||
if ($secure eq 0 ) {
|
||||
open (NAVICLIOUT ,"$NAVICLI -h $opt_host getcrus |");
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getcrus |");
|
||||
}
|
||||
my $sp_line = 0;
|
||||
my $error_count = 0;
|
||||
while (<NAVICLIOUT>) {
|
||||
if ($_ =~ m/^DPE|^SPE|^DAE/ ) {
|
||||
# got an DPE line
|
||||
$sp_line=1;
|
||||
}
|
||||
if ($sp_line == 1) {
|
||||
# check for SP lines
|
||||
if( $_ =~ m/^SP\s$opt_sp\s\w+:\s+(\w+)/) {
|
||||
if ($1 =~ m/(Present|Valid)/) {
|
||||
$output .= "SP $opt_sp $1,";
|
||||
} else {
|
||||
$output .= "SP $opt_sp failed,";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
# check for Enclosure lines
|
||||
if( $_ =~ m/Enclosure\s(\d+|\w+)\s(\w+)\s$opt_sp\d?\s\w+:\s+(.*)/) {
|
||||
my $check = $2;
|
||||
if ($3 =~ m/Present|Valid|N\/A|255.255/) {
|
||||
$output .= "$check ok,";
|
||||
} else {
|
||||
$output .= "$check failed,";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
# check for Cabling lines
|
||||
if( $_ =~ m/Enclosure\s(\d+|\w+)\s\w+\s$opt_sp\s(\w+)\s\w+:\s+(.*)/) {
|
||||
my $check = $2;
|
||||
if ($3 =~ m/Present|Valid|N\/A|255.255/) {
|
||||
$output .= "$check ok,";
|
||||
} else {
|
||||
$output .= "$check failed,";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
# end of section
|
||||
if ( $_ =~ m/^\s*$/) {
|
||||
$sp_line=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
if ($error_count == 0 && $output ne "") {
|
||||
$state = 'OK';
|
||||
} elsif ($output eq "") {
|
||||
$output = "UNKNOWN: No output from $NAVICLI";
|
||||
$state = 'UNKNOWN';
|
||||
} else {
|
||||
$state = 'CRITICAL';
|
||||
}
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
|
||||
}
|
||||
|
||||
# check_disk();
|
||||
# check state of the disks
|
||||
sub check_disk {
|
||||
my $disk_line = 0;
|
||||
my $crit_count = 0;
|
||||
my $warn_count = 0;
|
||||
my $hotspare_count = 0;
|
||||
my $disk_ok_count = 0;
|
||||
my ($bus,$enclosure,$disk) = 0;
|
||||
$state = 'UNKNOWN';
|
||||
if ($secure eq 0 ) {
|
||||
open (NAVICLIOUT ,"$NAVICLI -h $opt_host getdisk -state |");
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getdisk -state |");
|
||||
}
|
||||
while (<NAVICLIOUT>) {
|
||||
# check for disk lines
|
||||
if( $_ =~ m/^Bus\s(\d+)\s\w+\s(\d+)\s+\w+\s+(\d+)/) {
|
||||
$bus = $1;
|
||||
$enclosure = $2;
|
||||
$disk = $3;
|
||||
$disk_line=1;
|
||||
}
|
||||
|
||||
if ($disk_line == 1) {
|
||||
# check for States lines
|
||||
if( $_ =~ m/^State:\s+(.*)$/) {
|
||||
my $status = $1;
|
||||
if ($status =~ m/Hot Spare Ready/) {
|
||||
$hotspare_count++;
|
||||
$disk_ok_count++;
|
||||
} elsif ($status =~ m/Binding|Empty|Enabled|Expanding|Unbound|Powering Up|Ready|Transitioning/) {
|
||||
$disk_ok_count++;
|
||||
} elsif ($status =~ m/Equalizing|Rebuilding/) {
|
||||
$warn_count++;
|
||||
$output .= "Bus $bus, Enclosure $enclosure, Disk $disk is replaced or is being rebuilt, ";
|
||||
} else {
|
||||
$crit_count++;
|
||||
$output .= "Bus $bus, Enclosure $enclosure, Disk $disk is critical, ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# end of section
|
||||
if ( $_ =~ m/^\s*$/) {
|
||||
$disk_line=0;
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
if ($disk_ok_count eq 0) {
|
||||
print "No disk were founded !\n";
|
||||
$state = 'UNKNOWN';
|
||||
} elsif ($crit_count > 0) {
|
||||
$state='CRITICAL';
|
||||
} elsif ($warn_count > 0 || $hotspare_count eq 0) {
|
||||
$state='WARNING';
|
||||
} else {
|
||||
$state='OK';
|
||||
}
|
||||
$output .= $disk_ok_count." physical disks are OK. ".$hotspare_count." Hotspares are ready.";
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
|
||||
# check_cache();
|
||||
# check state of the read and write cache
|
||||
sub check_cache {
|
||||
my $read_state = 0;
|
||||
my $write_state = 0;
|
||||
my $write_mirrored_state = 0;
|
||||
my $crit_count = 0;
|
||||
my $warn_count = 0;
|
||||
$state = 'UNKNOWN';
|
||||
if ($secure eq 0 ) {
|
||||
open (NAVICLIOUT ,"$NAVICLI -h $opt_host getcache |");
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getcache |");
|
||||
}
|
||||
while (<NAVICLIOUT>) {
|
||||
# check for cache
|
||||
if( $_ =~ m/^SP Read Cache State\s+(\w+)/) {
|
||||
$read_state = $1;
|
||||
if ($read_state =~ m/Enabled/) {
|
||||
$output .= "Read cache is enable, ";
|
||||
} else {
|
||||
$output .= "Read cache is not enable ! ";
|
||||
$warn_count++;
|
||||
}
|
||||
} elsif ( $_ =~ m/^SP Write Cache State\s+(\w+)/) {
|
||||
$write_state = $1;
|
||||
if ($write_state =~ m/Enabled/) {
|
||||
$output .= "Write cache is enable, ";
|
||||
} else {
|
||||
$output .= "Write cache is not enable ! ";
|
||||
$crit_count++;
|
||||
}
|
||||
} elsif ( $_ =~ m/^Write Cache Mirrored\:\s+(\w+)/) {
|
||||
$write_mirrored_state = $1;
|
||||
if ($write_mirrored_state =~ m/YES/) {
|
||||
$output .= "Write cache mirroring is enable.";
|
||||
} else {
|
||||
$output .= "The Write cache mirroring is not enable !";
|
||||
$crit_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
if ( !defined($output) ) {
|
||||
print "No output from the command getcache !\n";
|
||||
$state = 'UNKNOWN';
|
||||
exit $states{$state};
|
||||
} elsif ($crit_count > 0) {
|
||||
$state='CRITICAL';
|
||||
} elsif ($warn_count > 0 ) {
|
||||
$state='WARNING';
|
||||
} else {
|
||||
$state='OK';
|
||||
}
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
|
||||
# check_faults();
|
||||
# check state of the different faults
|
||||
# only works with naviseccli
|
||||
sub check_faults {
|
||||
$state = 'UNKNOWN';
|
||||
if ($secure eq 0 ) {
|
||||
print "The check of the faults only works with Naviseccli. Please provide user and password with -u and -p options !\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host Faults -list |");
|
||||
}
|
||||
while (<NAVICLIOUT>) {
|
||||
# check for faults on the array
|
||||
if( $_ =~ m/^The array is operating normally/) {
|
||||
$state='OK';
|
||||
$output .= $_ ;
|
||||
close (NAVICLIOUT);
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
} else {
|
||||
$state='CRITICAL';
|
||||
$output .= $_ ;
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
if ( !defined($output) ) {
|
||||
print "No output from the command Faults -list !\n";
|
||||
$state = 'UNKNOWN';
|
||||
exit $states{$state};
|
||||
}
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
|
||||
# check_portstate();
|
||||
# check port state of the sp`s
|
||||
sub check_portstate {
|
||||
my $sp_section = 0;
|
||||
my $sp_line = 0;
|
||||
my $portstate_line = 0;
|
||||
my $error_count = -1;
|
||||
my ($port_id,$enclosure,$disk) = 0;
|
||||
$state = 'UNKNOWN';
|
||||
if ($secure eq 0 ) {
|
||||
open (NAVICLIOUT ,"$NAVICLI -h $opt_host getall -hba |");
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getall -hba |");
|
||||
}
|
||||
while (<NAVICLIOUT>) {
|
||||
# check for port lines
|
||||
if ($_ =~ m/SPPORT/ ) {
|
||||
$sp_section = 1;
|
||||
}
|
||||
# check for requested SP
|
||||
if( $_ =~ m/^SP\sName:\s+SP\s$opt_sp/ ) {
|
||||
$sp_line = 1;
|
||||
}
|
||||
# check for requested port id
|
||||
if ($opt_port >=0) {
|
||||
if( $_ =~ m/^SP\sPort\sID:\s+($opt_port)$/) {
|
||||
$port_id = $1;
|
||||
$portstate_line = 1;
|
||||
$error_count = 0;
|
||||
}
|
||||
} else {
|
||||
|
||||
### if( $_ =~ m/^SP\sPort\sID:\s+($opt_port)$/) {
|
||||
if( $_ =~ m/^SP\sPort\sID:\s+(\d+)$/) {
|
||||
$port_id = $1;
|
||||
$portstate_line = 1;
|
||||
$error_count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($sp_section == 1 && $sp_line == 1 && $portstate_line == 1) {
|
||||
# check for Link line
|
||||
if( $_ =~ m/^Link\sStatus:\s+(.*)$/) {
|
||||
my $status = $1;
|
||||
if ($status =~ m/Up/) {
|
||||
$output .= "SP $opt_sp Port: $port_id, Link: $status, ";
|
||||
} else {
|
||||
$output .= "SP $opt_sp Port: $port_id, Link: $status, ";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
# check for Link line
|
||||
### check for Port line
|
||||
if( $_ =~ m/^Port\sStatus:\s+(.*)$/) {
|
||||
my $status = $1;
|
||||
if ($status =~ m/Online/) {
|
||||
$output .= "State: $status, ";
|
||||
} else {
|
||||
$output .= "State: $status, ";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
# check for Connection Type
|
||||
if( $_ =~ m/^Connection\sType:\s+(.*)$/) {
|
||||
my $type = $1;
|
||||
$output .= "Connection Type: $type. ";
|
||||
}
|
||||
# end of section
|
||||
if ( $_ =~ m/^\s*$/) {
|
||||
$portstate_line = 0;
|
||||
### $sp_section = 0;
|
||||
if ($opt_port >=0 ) {
|
||||
$sp_section = 0;
|
||||
}
|
||||
$sp_line = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
if ($error_count == 0) {
|
||||
$state='OK';
|
||||
} elsif ($error_count == -1) {
|
||||
$state='UNKNOWN';
|
||||
$output = 'UNKNOWN: specified port not found '.$opt_port;
|
||||
} else {
|
||||
$state='CRITICAL';
|
||||
}
|
||||
|
||||
print $output."\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
|
||||
# check_hbastate();
|
||||
# check hba and path states for specific client
|
||||
sub check_hbastate {
|
||||
$state = 'UNKNOWN';
|
||||
my $hba_node;
|
||||
my $hba_node_line = 0;
|
||||
my $hba_section = 0;
|
||||
my $hba_port_section = 0;
|
||||
my $hba_port_count = 0;
|
||||
my $hba_uid = "";
|
||||
my $error_count = 0;
|
||||
my $output = "";
|
||||
if ($secure eq 0 ) {
|
||||
open (NAVICLIOUT ,"$NAVICLI -h $opt_host getall -hba |");
|
||||
}
|
||||
if ($secure eq 1 ) {
|
||||
open (NAVICLIOUT ,"$NAVISECCLI -User $opt_user -Password $opt_password -Scope 0 -h $opt_host getall -hba |");
|
||||
}
|
||||
while (<NAVICLIOUT>) {
|
||||
if ($_ =~ m/Information\sabout\seach\sHBA/) {
|
||||
$hba_section = 1;
|
||||
$hba_port_section = 0;
|
||||
$hba_node_line = 0;
|
||||
}
|
||||
if ($hba_section == 1) {
|
||||
if ($_ =~ m/^HBA\sUID:\s+((\w+:?)+)/i) {
|
||||
$hba_uid=$1;
|
||||
}
|
||||
if ($_ =~ m/^Server\sName:\s+($opt_node)/i) {
|
||||
$hba_node = $1;
|
||||
$hba_node_line = 1;
|
||||
}
|
||||
if ($_ =~ m/Information\sabout\seach\sport\sof\sthis\sHBA/) {
|
||||
$hba_section = 0;
|
||||
$hba_port_section = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($hba_port_section && $hba_node_line) {
|
||||
if ($_ =~ m/SP\sName:\s+(\w+\s+\w+)/) {
|
||||
$output .= "$hba_uid connected to: $1, ";
|
||||
}
|
||||
if ($_ =~ m/SP\sPort\sID:\s+(\d+)/) {
|
||||
$output .= "port: $1, ";
|
||||
}
|
||||
if ($_ =~ m/Logged\sIn:\s+(YES)/) {
|
||||
$output .= "Logged in: $1; ";
|
||||
$hba_port_count++;
|
||||
} elsif ($_ =~ m/Logged\sIn:\s+(\w+)/) {
|
||||
$output .= "Logged in: $1; <br>";
|
||||
$error_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
close (NAVICLIOUT);
|
||||
|
||||
|
||||
if ($error_count == 0 && $hba_port_count == $opt_pathcount) {
|
||||
$state='OK';
|
||||
} elsif (lc($opt_node) ne lc($hba_node) ) {
|
||||
$state='UNKNOWN';
|
||||
$output = 'UNKNOWN: specified node not found '.$opt_node;
|
||||
} elsif ($hba_port_count != $opt_pathcount) {
|
||||
$output .= " error in pathcount from client to SAN: suggested $opt_pathcount detected $hba_port_count";
|
||||
$state='CRITICAL';
|
||||
} elsif ($error_count != 0 && $hba_port_count == $opt_pathcount) {
|
||||
$output .= " Error in Configuration, one path not connected !";
|
||||
$state='CRITICAL';
|
||||
}
|
||||
|
||||
print $opt_node."<br>".$output."\n";
|
||||
exit $states{$state};
|
||||
}
|
||||
|
||||
# print_help($level, $msg);
|
||||
# prints some message and the POD DOC
|
||||
sub print_help {
|
||||
my ( $level, $msg ) = @_;
|
||||
$level = 0 unless ($level);
|
||||
pod2usage(
|
||||
{
|
||||
-message => $msg,
|
||||
-verbose => $level,
|
||||
-noperldoc => 1
|
||||
}
|
||||
);
|
||||
|
||||
exit( $states{UNKNOWN} );
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
check_emc_clariion.pl - Checks EMC SAN devices for NAGIOS.
|
||||
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
check_emc_clariion.pl -h | --help
|
||||
|
||||
check_emc_clariion.pl -H <host> -t <checktype>
|
||||
|
||||
check_emc_clariion.pl -H <host> -u <user> -p <password> -t <checktype>
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<check_emc_clariion.pl> receives the data from the emc devices via Navicli or Naviseccli if user and password are provided.
|
||||
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<-h>
|
||||
|
||||
Display this helpmessage.
|
||||
|
||||
=item B<-H>
|
||||
|
||||
The hostname or ipaddress of the emc storage processor device.
|
||||
|
||||
=item B<-u>
|
||||
|
||||
The user used to connect to the emc storage processor device with Naviseccli.
|
||||
You must use this option with -password !
|
||||
|
||||
=item B<-p>
|
||||
|
||||
The password of the user used to connect to the emc storage processor device with Naviseccli.
|
||||
|
||||
=item B<-t>
|
||||
|
||||
The check type to execute:
|
||||
|
||||
=back
|
||||
|
||||
=head2 TYPES
|
||||
|
||||
the following checks are currently available
|
||||
|
||||
sp - check the status of the storage processors
|
||||
|
||||
disk - check the status of the physical disks attached in the DAE`s
|
||||
|
||||
cache - check the status of the read and write cache
|
||||
|
||||
faults - Report the different faults on the array
|
||||
|
||||
portstate - check the status of the FC ports in the SP`s
|
||||
|
||||
hbastate - check the connection state of the specified node
|
||||
|
||||
=head3 TYPE OPTIONS
|
||||
|
||||
=head4 sp
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--sp>
|
||||
|
||||
The storageprocessor to check e.g. A or B
|
||||
|
||||
=back
|
||||
|
||||
=head4 portstate
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--sp>
|
||||
|
||||
The storageprocessor to check e.g. A or B
|
||||
|
||||
=item B<--port>
|
||||
|
||||
The port ID to check e.g. 0 or 1 or 0, 1, 2 or 3 for Clariion CX3-80
|
||||
|
||||
- if not specified, all ports are checked
|
||||
|
||||
=back
|
||||
|
||||
=head4 hbastate
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--node>
|
||||
|
||||
The node name to check out of navisphere
|
||||
|
||||
=item B<--paths>
|
||||
|
||||
The number of available FC Paths from the client to the SAN Infrastructure e.g. 2
|
||||
|
||||
=cut
|
||||
|
||||
=back
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
$Id$
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
NETWAYS GmbH, 2008, http://www.netways.de.
|
||||
|
||||
Written by Michael Streb <michael.streb@netways.de>.
|
||||
|
||||
Please report bugs through the contact of Nagios Exchange, http://www.nagiosexchange.org.
|
12
check_emc_clariion/trunk/checkcommands.cfg
Normal file
12
check_emc_clariion/trunk/checkcommands.cfg
Normal file
@ -0,0 +1,12 @@
|
||||
define command{
|
||||
command_name check_emc_sp
|
||||
command_line $USER1$/check_emc_clariion.pl -H $HOSTADDRESS$ -t sp --sp $ARG1$
|
||||
}
|
||||
define command{
|
||||
command_name check_emc_disk
|
||||
command_line $USER1$/check_emc_clariion.pl -H $HOSTADDRESS$ -t disk
|
||||
}
|
||||
define command{
|
||||
command_name check_emc_port
|
||||
command_line $USER1$/check_emc_clariion.pl -H $HOSTADDRESS$ -t portstate --port $ARG1$
|
||||
}
|
4
check_emc_clariion/trunk/status.cli
Normal file
4
check_emc_clariion/trunk/status.cli
Normal file
@ -0,0 +1,4 @@
|
||||
show node detail all
|
||||
yes
|
||||
yes
|
||||
quit
|
778
check_snmp_interfaces/trunk/check_snmp_cisco_ifstatus
Executable file
778
check_snmp_interfaces/trunk/check_snmp_cisco_ifstatus
Executable file
@ -0,0 +1,778 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
#
|
||||
# AUTHORS:
|
||||
# Copyright (C) 2003-2010 Opsera Limited. All rights reserved
|
||||
#
|
||||
# This file is part of Opsview
|
||||
#
|
||||
# Opsview is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Opsview is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Opsview; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
|
||||
use lib qw ( /usr/local/nagios/perl/lib );
|
||||
use Net::SNMP;
|
||||
use Getopt::Std;
|
||||
|
||||
$script = "check_snmp_cisco_ifstatus";
|
||||
$script_version = "2.1.0";
|
||||
|
||||
# SNMP options
|
||||
$version = "2c";
|
||||
$timeout = 2;
|
||||
|
||||
$number_of_interfaces = 0;
|
||||
$target_interface_index = 0;
|
||||
|
||||
@list_interfaces=undef; # List of inappropriate interfaces;
|
||||
|
||||
$oid_base = ".1.3.6.1.2.1.2.2.1.1.";
|
||||
$oid_sysdescr = ".1.3.6.1.2.1.1.1.0";
|
||||
$oid_ifnumber = ".1.3.6.1.2.1.2.1.0"; # number of interfaces on device
|
||||
$oid_ifdescr = ".1.3.6.1.2.1.2.2.1.2."; # need to append integer for specific interface
|
||||
$oid_iftype = ".1.3.6.1.2.1.2.2.1.3."; # need to append integer for specific interface
|
||||
$oid_ifmtu = ".1.3.6.1.2.1.2.2.1.4."; # need to append integer for specific interface
|
||||
$oid_ifspeed = ".1.3.6.1.2.1.2.2.1.5."; # need to append integer for specific interface
|
||||
$oid_ifphysaddress = ".1.3.6.1.2.1.2.2.1.6."; # need to append integer for specific interface
|
||||
$oid_ifadminstatus = ".1.3.6.1.2.1.2.2.1.7."; # need to append integer for specific interface
|
||||
$oid_ifoperstatus = ".1.3.6.1.2.1.2.2.1.8."; # need to append integer for specific interface
|
||||
$oid_iflastchange = ".1.3.6.1.2.1.2.2.1.9."; # need to append integer for specific interface
|
||||
$oid_ifinerrors = ".1.3.6.1.2.1.2.2.1.14."; # 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
|
||||
my $realbitssec; # Perf data is always in bps, save this data here
|
||||
|
||||
# Cisco Specific
|
||||
|
||||
$oid_locIfIntBitsSec = "1.3.6.1.4.1.9.2.2.1.1.6."; # need to append integer for specific interface
|
||||
$oid_locIfOutBitsSec = "1.3.6.1.4.1.9.2.2.1.1.8."; # need to append integer for specific interface
|
||||
|
||||
$ifdescr = "n/a";
|
||||
$iftype = "n/a";
|
||||
$ifmtu = "n/a";
|
||||
$ifspeed = "n/a";
|
||||
$ifphysaddress = "n/a";
|
||||
$ifadminstatus = "n/a";
|
||||
$ifoperstatus = "n/a";
|
||||
$iflastchange = "n/a";
|
||||
$ifinerrors = "n/a";
|
||||
$ifouterrors = "n/a";
|
||||
$ifoutqlen = "n/a";
|
||||
$ifoutbitssec = "n/a";
|
||||
|
||||
$warning = 100000000; # Warning threshold
|
||||
$critical = 100000000; # Critical threshold
|
||||
|
||||
$hostname = "192.168.10.21";
|
||||
|
||||
#$hostname = "212.113.28.134";
|
||||
$returnstring = "";
|
||||
|
||||
$community = "public"; # Default community string
|
||||
$configfilepath = "/usr/local/nagios/etc";
|
||||
|
||||
# Do we have enough information?
|
||||
if ( @ARGV < 1 ) {
|
||||
print "Too few arguments\n";
|
||||
usage();
|
||||
}
|
||||
|
||||
getopts("hH:C:i:w:c:");
|
||||
if ($opt_h) {
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
if ($opt_H) {
|
||||
$hostname = $opt_H;
|
||||
|
||||
# print "Hostname $opt_H\n";
|
||||
}
|
||||
else {
|
||||
print "No hostname specified\n";
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
if ($opt_C) {
|
||||
$community = $opt_C;
|
||||
}
|
||||
if ($opt_i) {
|
||||
$target_interface = $opt_i;
|
||||
}
|
||||
if ($opt_w) {
|
||||
$warning = $opt_w;
|
||||
}
|
||||
if ($opt_c) {
|
||||
$critical = $opt_c;
|
||||
}
|
||||
else {
|
||||
|
||||
# print "Using community $community\n";
|
||||
}
|
||||
|
||||
# Create the SNMP session
|
||||
|
||||
$oid_sysDescr = ".1.3.6.1.2.1.1.1.0"; # Used to check whether SNMP is actually responding
|
||||
|
||||
$version = "1";
|
||||
( $s, $e ) = Net::SNMP->session(
|
||||
-community => $community,
|
||||
-hostname => $hostname,
|
||||
-version => $version,
|
||||
-timeout => $timeout,
|
||||
);
|
||||
|
||||
if ( !defined( $s->get_request($oid_sysDescr) ) ) {
|
||||
|
||||
# If we can't connect using SNMPv1 lets try as SNMPv2
|
||||
$s->close();
|
||||
sleep 0.5;
|
||||
$version = "2c";
|
||||
( $s, $e ) = Net::SNMP->session(
|
||||
-community => $community,
|
||||
-hostname => $hostname,
|
||||
-version => $version,
|
||||
-timeout => $timeout,
|
||||
);
|
||||
if ( !defined( $s->get_request($oid_sysDescr) ) ) {
|
||||
print "Agent not responding, tried SNMP v1 and v2\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ( find_match() == 0 ) {
|
||||
probe_interface();
|
||||
}
|
||||
else {
|
||||
$status = 2;
|
||||
print "Interface $target_interface not found on device $hostname\n";
|
||||
exit $status;
|
||||
}
|
||||
|
||||
# Close the session
|
||||
$s->close();
|
||||
|
||||
if ( $status == 0 ) {
|
||||
print "Status is OK - $returnstring\n";
|
||||
exit $status;
|
||||
}
|
||||
elsif ( $status == 1 ) {
|
||||
print "Status is a Warning Level - $returnstring\n";
|
||||
exit $status;
|
||||
}
|
||||
elsif ( $status == 2 ) {
|
||||
print "Status is CRITICAL - $returnstring\n";
|
||||
exit $status;
|
||||
}
|
||||
else {
|
||||
print "Plugin error! SNMP status unknown\n";
|
||||
exit $status;
|
||||
}
|
||||
|
||||
exit 2;
|
||||
|
||||
#################################################
|
||||
# Finds match for supplied interface name
|
||||
#################################################
|
||||
|
||||
sub find_match {
|
||||
|
||||
my $resultat = $s->get_table($oid_base);
|
||||
|
||||
if (!defined($resultat)) {
|
||||
printf("ERROR: NHR table : %s.\n", $s->error);
|
||||
$s->close;
|
||||
exit 3;
|
||||
}
|
||||
|
||||
my @keys=undef;
|
||||
my $oidindex=0;
|
||||
foreach my $key ( keys %$resultat) {
|
||||
#verb("OID : $key, Desc : $$resultat{$key}" );
|
||||
#print $$resultat{$key} + "\n";
|
||||
$key =~ s/$oid_base//;
|
||||
push(@keys, $key);
|
||||
#print "$key \n";
|
||||
}
|
||||
|
||||
#print $resultat ;
|
||||
#exit 0;
|
||||
|
||||
|
||||
if ( !defined( $s->get_request($oid_ifnumber) ) ) {
|
||||
if ( !defined( $s->get_request($oid_sysdescr) ) ) {
|
||||
print "Status is a Warning Level - SNMP agent not responding\n";
|
||||
exit 1;
|
||||
}
|
||||
else {
|
||||
print "Status is a Warning Level - SNMP OID does not exist\n";
|
||||
exit 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ( $s->var_bind_names() ) {
|
||||
$number_of_interfaces = $s->var_bind_list()->{$_};
|
||||
if ( $number_of_interfaces == 0 ) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#$index = 1;
|
||||
#while ( $index <= $number_of_interfaces ) {
|
||||
foreach $index ( @keys ) {
|
||||
my $target_interface_index = $index;
|
||||
$oid_temp = $oid_ifdescr . $index;
|
||||
if ( !defined( $s->get_request($oid_temp) ) ) {
|
||||
}
|
||||
else {
|
||||
foreach ( $s->var_bind_names() ) {
|
||||
$temp_interface_descr = $s->var_bind_list()->{$_};
|
||||
}
|
||||
if ( lc($temp_interface_descr) eq lc($target_interface) ) {
|
||||
$target_interface_index = $index;
|
||||
}
|
||||
}
|
||||
|
||||
############################
|
||||
$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()->{$_};
|
||||
}
|
||||
}
|
||||
############################
|
||||
if ( $ifoperstatus != $ifadminstatus ) {
|
||||
push(@list_interfaces, $temp_interface_descr);
|
||||
#print ": $temp_interface_descr: $ifoperstatus / $ifadminstatus \n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
# $index++;
|
||||
}
|
||||
my $list_interfaces = @list_interfaces;
|
||||
my $keys = @keys;
|
||||
if ($list_interfaces > 0) {
|
||||
print "$list_interfaces out of $keys in inappropriate state: @list_interfaces \n";
|
||||
exit 1
|
||||
}
|
||||
else {
|
||||
print "All $keys interfaces in appropriate state\n";
|
||||
exit 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 ( $status < 1 ) {
|
||||
|
||||
# Don't bother is status is down
|
||||
if ( $ifoutbitssec > $critical ) {
|
||||
$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;
|
||||
|
||||
# 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);
|
||||
}
|
||||
|
||||
####################################################################
|
||||
# help and usage information #
|
||||
####################################################################
|
||||
|
||||
sub usage {
|
||||
print << "USAGE";
|
||||
--------------------------------------------------------------------
|
||||
$script v$script_version
|
||||
|
||||
Monitors status of specific Ethernet interface.
|
||||
|
||||
Usage: $script -H <hostname> -c <community> [...]
|
||||
|
||||
Options: -H Hostname or IP address
|
||||
-C Community (default is public)
|
||||
-i Target interface name
|
||||
Eg: Serial0/0, FastEthernet0/12
|
||||
-w Warning threshold - Out bits / sec
|
||||
-c Critical threshold - Out bits / sec
|
||||
|
||||
--------------------------------------------------------------------
|
||||
Copyright (C) 2003-2010 Opsera Limited. All rights reserved
|
||||
|
||||
This program is free software; you can redistribute it or modify
|
||||
it under the terms of the GNU General Public License
|
||||
--------------------------------------------------------------------
|
||||
|
||||
USAGE
|
||||
exit 1;
|
||||
}
|
||||
|
||||
####################################################################
|
||||
# Appends string to existing $returnstring #
|
||||
####################################################################
|
||||
|
||||
sub append {
|
||||
my $appendstring = @_[0];
|
||||
$returnstring = "$returnstring$appendstring";
|
||||
}
|
||||
|
||||
####################################################################
|
||||
# Returns the interface type for given IANA metric #
|
||||
####################################################################
|
||||
|
||||
sub return_interfacetype {
|
||||
my $iftype_int = @_[0];
|
||||
my @iana = ();
|
||||
my $returnstring = $iftype_int;
|
||||
|
||||
$iana[0] = "";
|
||||
$iana[1] = "other";
|
||||
$iana[2] = "regular1822";
|
||||
$iana[3] = "hdh1822";
|
||||
$iana[4] = "ddnX25";
|
||||
$iana[5] = "rfc877x25";
|
||||
$iana[6] = "ethernet";
|
||||
$iana[7] = "";
|
||||
$iana[8] = "TokenBus";
|
||||
$iana[9] = "TokenRing";
|
||||
$iana[10] = "iso88026Man";
|
||||
$iana[11] = "starLan";
|
||||
$iana[12] = "proteon10Mbit";
|
||||
$iana[13] = "proteon80Mbit";
|
||||
$iana[14] = "hyperchannel";
|
||||
$iana[15] = "fddi";
|
||||
$iana[16] = "lapb";
|
||||
$iana[17] = "sdlc";
|
||||
$iana[18] = "DSL";
|
||||
$iana[19] = "E1";
|
||||
$iana[20] = "basicISDN";
|
||||
$iana[21] = "primaryISDN";
|
||||
$iana[22] = "propritory PointToPointSerial";
|
||||
$iana[23] = "PPP";
|
||||
$iana[24] = "softwareLoopback";
|
||||
$iana[25] = "CLNP over IP ";
|
||||
$iana[26] = "ethernet3Mbit";
|
||||
$iana[27] = "XNS over IP";
|
||||
$iana[28] = "SLIP";
|
||||
$iana[29] = "ultra";
|
||||
$iana[30] = "DS3";
|
||||
$iana[31] = "SMDS";
|
||||
$iana[32] = "frameRelay DTE";
|
||||
$iana[33] = "RS232";
|
||||
$iana[34] = "Parallel port";
|
||||
$iana[35] = "arcnet";
|
||||
$iana[36] = "arcnetPlus";
|
||||
$iana[37] = "ATM";
|
||||
$iana[38] = "miox25";
|
||||
$iana[39] = "SONET / SDH ";
|
||||
$iana[40] = "X25PLE";
|
||||
$iana[41] = "iso88022llc";
|
||||
$iana[42] = "localTalk";
|
||||
$iana[43] = "SMDSDxi";
|
||||
$iana[44] = "frameRelayService";
|
||||
$iana[45] = "v35";
|
||||
$iana[46] = "hssi";
|
||||
$iana[47] = "hippi";
|
||||
$iana[48] = "Generic MODEM";
|
||||
$iana[49] = "";
|
||||
$iana[50] = "sonetPath";
|
||||
$iana[51] = "sonetVT";
|
||||
$iana[52] = "SMDSIcip";
|
||||
$iana[53] = "propVirtual";
|
||||
$iana[54] = "propMultiplexor";
|
||||
$iana[55] = "ieee80212 100BaseVG";
|
||||
$iana[56] = "fibreChannel";
|
||||
$iana[57] = "HIPPI interface";
|
||||
$iana[58] = "";
|
||||
$iana[59] = "ATM Emulated LAN for 802.3";
|
||||
$iana[60] = "ATM Emulated LAN for 802.5";
|
||||
$iana[61] = "ATM Emulated circuit ";
|
||||
$iana[62] = "";
|
||||
$iana[63] = "ISDN / X.25 ";
|
||||
$iana[64] = "CCITT V.11/X.21 ";
|
||||
$iana[65] = "CCITT V.36 ";
|
||||
$iana[66] = "CCITT G703 at 64Kbps";
|
||||
$iana[67] = "G703 at 2Mb";
|
||||
$iana[68] = "SNA QLLC ";
|
||||
$iana[69] = "";
|
||||
$iana[70] = "channel ";
|
||||
$iana[71] = "ieee80211 radio spread spectrum ";
|
||||
$iana[72] = "IBM System 360/370 OEMI Channel";
|
||||
$iana[73] = "IBM Enterprise Systems Connection";
|
||||
$iana[74] = "Data Link Switching";
|
||||
$iana[75] = "ISDN S/T interface";
|
||||
$iana[76] = "ISDN U interface";
|
||||
$iana[77] = "Link Access Protocol D";
|
||||
$iana[78] = "IP Switching Objects";
|
||||
$iana[79] = "Remote Source Route Bridging";
|
||||
$iana[80] = "ATM Logical Port";
|
||||
$iana[81] = "Digital Signal Level 0";
|
||||
$iana[82] = "ds0 Bundle (group of ds0s on the same ds1)";
|
||||
$iana[83] = "Bisynchronous Protocol";
|
||||
$iana[84] = "Asynchronous Protocol";
|
||||
$iana[85] = "Combat Net Radio";
|
||||
$iana[86] = "ISO 802.5r DTR";
|
||||
$iana[87] = "Ext Pos Loc Report Sys";
|
||||
$iana[88] = "Appletalk Remote Access Protocol";
|
||||
$iana[89] = "Proprietary Connectionless Protocol";
|
||||
$iana[90] = "CCITT-ITU X.29 PAD Protocol";
|
||||
$iana[91] = "CCITT-ITU X.3 PAD Facility";
|
||||
$iana[92] = "frameRelay MPI";
|
||||
$iana[93] = "CCITT-ITU X213";
|
||||
$iana[94] = "ADSL";
|
||||
$iana[95] = "Rate-Adapt. DSL";
|
||||
$iana[96] = "SDSL";
|
||||
$iana[97] = "Very High-Speed DSL";
|
||||
$iana[98] = "ISO 802.5 CRFP";
|
||||
$iana[99] = "Myricom Myrinet";
|
||||
$iana[100] = "voiceEM voice recEive and transMit";
|
||||
$iana[101] = "voiceFXO voice Foreign Exchange Office";
|
||||
$iana[102] = "voiceFXS voice Foreign Exchange Station";
|
||||
$iana[103] = "voiceEncap voice encapsulation";
|
||||
$iana[104] = "VoIP";
|
||||
$iana[105] = "ATM DXI";
|
||||
$iana[106] = "ATM FUNI";
|
||||
$iana[107] = "ATM IMA";
|
||||
$iana[108] = "PPP Multilink Bundle";
|
||||
$iana[109] = "IBM ipOverCdlc";
|
||||
$iana[110] = "IBM Common Link Access to Workstn";
|
||||
$iana[111] = "IBM stackToStack";
|
||||
$iana[112] = "IBM VIPA";
|
||||
$iana[113] = "IBM multi-protocol channel support";
|
||||
$iana[114] = "IBM IP over ATM";
|
||||
$iana[115] = "ISO 802.5j Fiber Token Ring";
|
||||
$iana[116] = "IBM twinaxial data link control";
|
||||
$iana[117] = "";
|
||||
$iana[118] = "HDLC";
|
||||
$iana[119] = "LAP F";
|
||||
$iana[120] = "V.37";
|
||||
$iana[121] = "X25 Multi-Link Protocol";
|
||||
$iana[122] = "X25 Hunt Group";
|
||||
$iana[123] = "Transp HDLC";
|
||||
$iana[124] = "Interleave channel";
|
||||
$iana[125] = "Fast channel";
|
||||
$iana[126] = "IP (for APPN HPR in IP networks)";
|
||||
$iana[127] = "CATV Mac Layer";
|
||||
$iana[128] = "CATV Downstream interface";
|
||||
$iana[129] = "CATV Upstream interface";
|
||||
$iana[130] = "Avalon Parallel Processor";
|
||||
$iana[131] = "Encapsulation interface";
|
||||
$iana[132] = "Coffee pot (no, really)";
|
||||
$iana[133] = "Circuit Emulation Service";
|
||||
$iana[134] = "ATM Sub Interface";
|
||||
$iana[135] = "Layer 2 Virtual LAN using 802.1Q";
|
||||
$iana[136] = "Layer 3 Virtual LAN using IP";
|
||||
$iana[137] = "Layer 3 Virtual LAN using IPX";
|
||||
$iana[138] = "IP over Power Lines";
|
||||
$iana[139] = "Multimedia Mail over IP";
|
||||
$iana[140] = "Dynamic Synchronous Transfer Mode";
|
||||
$iana[141] = "Data Communications Network";
|
||||
$iana[142] = "IP Forwarding Interface";
|
||||
$iana[143] = "Multi-rate Symmetric DSL";
|
||||
$iana[144] = "IEEE1394 High Performance Serial Bus";
|
||||
$iana[145] = "HIPPI-6400 ";
|
||||
$iana[146] = "DVB-RCC MAC Layer";
|
||||
$iana[147] = "DVB-RCC Downstream Channel";
|
||||
$iana[148] = "DVB-RCC Upstream Channel";
|
||||
$iana[149] = "ATM Virtual Interface";
|
||||
$iana[150] = "MPLS Tunnel Virtual Interface";
|
||||
$iana[151] = "Spatial Reuse Protocol";
|
||||
$iana[152] = "Voice Over ATM";
|
||||
$iana[153] = "Voice Over Frame Relay ";
|
||||
$iana[154] = "Digital Subscriber Loop over ISDN";
|
||||
$iana[155] = "Avici Composite Link Interface";
|
||||
$iana[156] = "SS7 Signaling Link ";
|
||||
$iana[157] = "Prop. P2P wireless interface";
|
||||
$iana[158] = "Frame Forward Interface";
|
||||
$iana[159] = "Multiprotocol over ATM AAL5";
|
||||
$iana[160] = "USB Interface";
|
||||
$iana[161] = "IEEE 802.3ad Link Aggregate";
|
||||
$iana[162] = "BGP Policy Accounting";
|
||||
$iana[163] = "FRF .16 Multilink Frame Relay ";
|
||||
$iana[164] = "H323 Gatekeeper";
|
||||
$iana[165] = "H323 Voice and Video Proxy";
|
||||
$iana[166] = "MPLS";
|
||||
$iana[167] = "Multi-frequency signaling link";
|
||||
$iana[168] = "High Bit-Rate DSL - 2nd generation";
|
||||
$iana[169] = "Multirate HDSL2";
|
||||
$iana[170] = "Facility Data Link 4Kbps on a DS1";
|
||||
$iana[171] = "Packet over SONET/SDH Interface";
|
||||
$iana[172] = "DVB-ASI Input";
|
||||
$iana[173] = "DVB-ASI Output ";
|
||||
$iana[174] = "Power Line Communtications";
|
||||
$iana[175] = "Non Facility Associated Signaling";
|
||||
$iana[176] = "TR008";
|
||||
$iana[177] = "Remote Digital Terminal";
|
||||
$iana[178] = "Integrated Digital Terminal";
|
||||
$iana[179] = "ISUP";
|
||||
$iana[180] = "Cisco proprietary MAC layer";
|
||||
$iana[181] = "Cisco proprietary Downstream";
|
||||
$iana[182] = "Cisco proprietary Upstream";
|
||||
$iana[183] = "HIPERLAN Type 2 Radio Interface";
|
||||
$iana[184] = "PropBroadbandWirelessAccesspt2multipt";
|
||||
$iana[185] = "SONET Overhead Channel";
|
||||
$iana[186] = "Digital Wrapper";
|
||||
$iana[187] = "ATM adaptation layer 2";
|
||||
$iana[188] = "MAC layer over radio links";
|
||||
$iana[189] = "ATM over radio links ";
|
||||
$iana[190] = "Inter Machine Trunks";
|
||||
$iana[191] = "Multiple Virtual Lines DSL";
|
||||
$iana[192] = "Long Reach DSL";
|
||||
$iana[193] = "Frame Relay DLCI End Point";
|
||||
$iana[194] = "ATM VCI End Point";
|
||||
$iana[195] = "Optical Channel";
|
||||
$iana[196] = "Optical Transport";
|
||||
$iana[197] = "Proprietary ATM ";
|
||||
$iana[198] = "Voice Over Cable Interface";
|
||||
$iana[199] = "Infiniband";
|
||||
$iana[200] = "TE Link";
|
||||
$iana[201] = "Q.2931";
|
||||
$iana[202] = "Virtual Trunk Group";
|
||||
$iana[203] = "SIP Trunk Group";
|
||||
$iana[204] = "SIP Signaling ";
|
||||
$iana[205] = "CATV Upstream Channel";
|
||||
$iana[206] = "Acorn Econet";
|
||||
$iana[207] = "FSAN 155Mb Symetrical PON interface";
|
||||
$iana[208] = "FSAN622Mb Symetrical PON interface";
|
||||
$iana[209] = "Transparent bridge interface";
|
||||
$iana[210] = "Interface common to multiple lines";
|
||||
$iana[211] = "voice E&M Feature Group D";
|
||||
$iana[212] = "voice FGD Exchange Access North American";
|
||||
$iana[213] = "voice Direct Inward Dialing";
|
||||
$iana[214] = "MPEG transport interface";
|
||||
$iana[215] = "6to4 interface";
|
||||
$iana[216] = "GTP (GPRS Tunneling Protocol)";
|
||||
$iana[217] = "Paradyne EtherLoop 1";
|
||||
$iana[218] = "Paradyne EtherLoop 2";
|
||||
$iana[219] = "Optical Channel Group";
|
||||
$iana[220] = "HomePNA ITU-T G.989";
|
||||
$iana[221] = "Generic Framing Procedure (GFP)";
|
||||
$iana[222] = "Layer 2 Virtual LAN using Cisco ISL";
|
||||
$iana[223] = "Acteleis proprietary MetaLOOP High Speed Link ";
|
||||
$iana[224] = "FCIP Link ";
|
||||
$iana[225] = "Resilient Packet Ring Interface Type";
|
||||
$iana[226] = "RF Qam Interface";
|
||||
$iana[227] = "Link Management Protocol";
|
||||
|
||||
if ( $iftype_int > 227 ) {
|
||||
$returnstring = "$iftype_int";
|
||||
}
|
||||
else {
|
||||
$returnstring = $iana[$iftype_int];
|
||||
}
|
||||
|
||||
return ($returnstring);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user