Imported Upstream version 2.1
This commit is contained in:
parent
0841b5c7c7
commit
060ec72678
47 changed files with 1718 additions and 1420 deletions
|
@ -9,6 +9,7 @@
|
|||
# Added -u option (4/2003)
|
||||
# Added -M option (10/2003)
|
||||
# Added SNMPv3 support (10/2003)
|
||||
# Added -n option (07/2014)
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -95,8 +96,10 @@ my $ifXTable;
|
|||
my $opt_h ;
|
||||
my $opt_V ;
|
||||
my $opt_u;
|
||||
my $opt_n;
|
||||
my $opt_x ;
|
||||
my %excluded ;
|
||||
my %unused_names ;
|
||||
my @unused_ports ;
|
||||
my %session_opts;
|
||||
|
||||
|
@ -171,27 +174,30 @@ alarm(0);
|
|||
foreach $key (keys %ifStatus) {
|
||||
|
||||
# skip unused interfaces
|
||||
if (!defined($ifStatus{$key}{'notInUse'})) {
|
||||
my $ifName = $ifStatus{$key}{$snmpIfDescr};
|
||||
|
||||
if (!defined($ifStatus{$key}{'notInUse'}) && !grep(/^${ifName}/, @unused_ports )) {
|
||||
# check only if interface is administratively up
|
||||
if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
|
||||
|
||||
# check only if interface type is not listed in %excluded
|
||||
if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ;}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
|
||||
$ifdown++ ;
|
||||
if (defined $ifXTable) {
|
||||
$ifmessage .= sprintf("%s: down -> %s<BR>",
|
||||
$ifStatus{$key}{$snmpIfName},
|
||||
$ifStatus{$key}{$snmpIfAlias});
|
||||
}else{
|
||||
$ifmessage .= sprintf("%s: down <BR>",
|
||||
$ifStatus{$key}{$snmpIfDescr});
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
|
||||
#check only if interface is not excluded
|
||||
if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) {
|
||||
# check only if interface type is not listed in %excluded
|
||||
if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; }
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
|
||||
$ifdown++ ;
|
||||
if (defined $ifXTable) {
|
||||
$ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias});
|
||||
}else{
|
||||
$ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr});
|
||||
}
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
|
||||
} else {
|
||||
$ifexclude++;
|
||||
}
|
||||
if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
|
||||
}else{
|
||||
$ifexclude++;
|
||||
} else {
|
||||
$ifunused++;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -221,7 +227,7 @@ foreach $key (keys %ifStatus) {
|
|||
$ifexclude,
|
||||
$ifunused);
|
||||
}
|
||||
my $perfdata = sprintf("up=%d,down=%d,dormant=%d,excluded=%d,unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
|
||||
my $perfdata = sprintf("up=%d down=%d dormant=%d excluded=%d unused=%d",$ifup,$ifdown,$ifdormant,$ifexclude,$ifunused);
|
||||
print ("$state: $answer |$perfdata\n");
|
||||
exit $ERRORS{$state};
|
||||
|
||||
|
@ -259,6 +265,8 @@ sub print_help() {
|
|||
printf " the descriptive name. Do not use if you don't know what this is. \n";
|
||||
printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n";
|
||||
printf " from the report (default for an empty list is PPP(23).\n";
|
||||
printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n";
|
||||
printf " from the report (default is an empty exclusion list).\n";
|
||||
printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n";
|
||||
printf " from the report (default is an empty exclusion list).\n";
|
||||
printf " See the IANAifType-MIB for a list of interface types.\n";
|
||||
|
@ -299,6 +307,7 @@ sub process_arguments() {
|
|||
"I" => \$ifXTable, "ifmib" => \$ifXTable,
|
||||
"x:s" => \$opt_x, "exclude:s" => \$opt_x,
|
||||
"u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
|
||||
"n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n,
|
||||
"M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
|
||||
"t=i" => \$timeout, "timeout=i" => \$timeout,
|
||||
);
|
||||
|
@ -406,6 +415,16 @@ sub process_arguments() {
|
|||
}
|
||||
}
|
||||
|
||||
# Excluded interface descriptors
|
||||
if (defined $opt_n) {
|
||||
my @unused = split(/,/,$opt_n);
|
||||
if ( @unused ) {
|
||||
foreach $key (@unused) {
|
||||
$unused_names{$key} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Excluded interface ports (ifIndex) - management reasons
|
||||
if ($opt_u) {
|
||||
@unused_ports = split(/,/,$opt_u);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue