| 1 |
package HP::Proliant::Component::NicSubsystem; |
| 2 |
our @ISA = qw(HP::Proliant::Component); |
| 3 |
|
| 4 |
use strict; |
| 5 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 6 |
|
| 7 |
sub new { |
| 8 |
my $class = shift; |
| 9 |
my %params = @_; |
| 10 |
my $self = { |
| 11 |
runtime => $params{runtime}, |
| 12 |
rawdata => $params{rawdata}, |
| 13 |
method => $params{method}, |
| 14 |
condition => $params{condition}, |
| 15 |
status => $params{status}, |
| 16 |
logical_nics => [], |
| 17 |
physical_nics => [], |
| 18 |
blacklisted => 0, |
| 19 |
info => undef, |
| 20 |
extendedinfo => undef, |
| 21 |
}; |
| 22 |
bless $self, $class; |
| 23 |
if ($self->{method} eq 'snmp') { |
| 24 |
return HP::Proliant::Component::NicSubsystem::SNMP->new(%params); |
| 25 |
} elsif ($self->{method} eq 'cli') { |
| 26 |
return HP::Proliant::Component::NicSubsystem::CLI->new(%params); |
| 27 |
} else { |
| 28 |
die "unknown method"; |
| 29 |
} |
| 30 |
return $self; |
| 31 |
} |
| 32 |
|
| 33 |
sub check { |
| 34 |
my $self = shift; |
| 35 |
my $errorfound = 0; |
| 36 |
$self->add_info('checking nic teams'); |
| 37 |
if (scalar (@{$self->{logical_nics}}) == 0) { |
| 38 |
$self->add_info('no logical nics found'); |
| 39 |
$self->overall_check(); |
| 40 |
} else { |
| 41 |
foreach (@{$self->{logical_nics}}) { |
| 42 |
$_->check(); |
| 43 |
} |
| 44 |
} |
| 45 |
if (scalar (@{$self->{physical_nics}}) == 0) { |
| 46 |
$self->add_info('no physical nics found. do you connect with slip?'); |
| 47 |
} else { |
| 48 |
foreach (@{$self->{physical_nics}}) { |
| 49 |
$_->check(); |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
sub num_logical_nics { |
| 55 |
my $self = shift; |
| 56 |
return scalar @{$self->{logical_nics}}; |
| 57 |
} |
| 58 |
|
| 59 |
sub num_physical_nics { |
| 60 |
my $self = shift; |
| 61 |
return scalar @{$self->{physical_nics}}; |
| 62 |
} |
| 63 |
|
| 64 |
sub dump { |
| 65 |
my $self = shift; |
| 66 |
foreach (@{$self->{logical_nics}}) { |
| 67 |
$_->dump(); |
| 68 |
} |
| 69 |
foreach (@{$self->{physical_nics}}) { |
| 70 |
$_->dump(); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
sub overall_check { |
| 75 |
my $self = shift; |
| 76 |
if ($self->{lognicstatus} ne "ok") { |
| 77 |
$self->add_info(sprintf 'overall logical nic status is %s', |
| 78 |
$self->{lognicstatus}); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
package HP::Proliant::Component::NicSubsystem::LogicalNic; |
| 84 |
our @ISA = qw(HP::Proliant::Component::NicSubsystem); |
| 85 |
|
| 86 |
use strict; |
| 87 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 88 |
|
| 89 |
sub new { |
| 90 |
my $class = shift; |
| 91 |
my %params = @_; |
| 92 |
my $self = { |
| 93 |
runtime => $params{runtime}, |
| 94 |
blacklisted => 0, |
| 95 |
info => undef, |
| 96 |
extendedinfo => undef, |
| 97 |
}; |
| 98 |
foreach (qw(cpqNicIfLogMapIndex cpqNicIfLogMapIfNumber cpqNicIfLogMapDescription cpqNicIfLogMapGroupType cpqNicIfLogMapAdapterCount cpqNicIfLogMapAdapterOKCount cpqNicIfLogMapPhysicalAdapters cpqNicIfLogMapSwitchoverMode cpqNicIfLogMapCondition cpqNicIfLogMapStatus cpqNicIfLogMapNumSwitchovers cpqNicIfLogMapHwLocation cpqNicIfLogMapSpeed cpqNicIfLogMapVlanCount cpqNicIfLogMapVlans)) { |
| 99 |
$self->{$_} = $params{$_}; |
| 100 |
} |
| 101 |
bless $self, $class; |
| 102 |
return $self; |
| 103 |
} |
| 104 |
|
| 105 |
sub check { |
| 106 |
my $self = shift; |
| 107 |
$self->blacklist('lni', $self->{cpqNicIfLogMapIndex}); |
| 108 |
if ($self->{cpqNicIfLogMapAdapterCount} > 0) { |
| 109 |
if ($self->{cpqNicIfLogMapCondition} eq "other") { |
| 110 |
# simply ignore this. if there is a physical nic |
| 111 |
# it is usually unknown/other/scheissegal |
| 112 |
$self->add_info(sprintf "logical nic %d (%s) is %s", |
| 113 |
$self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, |
| 114 |
$self->{cpqNicIfLogMapCondition}); |
| 115 |
} elsif ($self->{cpqNicIfLogMapCondition} ne "ok") { |
| 116 |
$self->add_info(sprintf "logical nic %d (%s) is %s (%s)", |
| 117 |
$self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, |
| 118 |
$self->{cpqNicIfLogMapCondition}, $self->{cpqNicIfLogMapStatus}); |
| 119 |
$self->add_message(CRITICAL, $self->{info}); |
| 120 |
} else { |
| 121 |
$self->add_info(sprintf "logical nic %d (%s) is %s", |
| 122 |
$self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}, |
| 123 |
$self->{cpqNicIfLogMapCondition}); |
| 124 |
} |
| 125 |
} else { |
| 126 |
$self->add_info(sprintf "logical nic %d (%s) has 0 physical nics", |
| 127 |
$self->{cpqNicIfLogMapIndex}, $self->{cpqNicIfLogMapDescription}); |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
sub dump { |
| 132 |
my $self = shift; |
| 133 |
printf "[LNIC_%s]\n", $self->{cpqNicIfLogMapIndex}; |
| 134 |
foreach (qw(cpqNicIfLogMapIndex cpqNicIfLogMapIfNumber cpqNicIfLogMapDescription cpqNicIfLogMapAdapterCount cpqNicIfLogMapGroupType cpqNicIfLogMapSwitchoverMode cpqNicIfLogMapCondition cpqNicIfLogMapStatus cpqNicIfLogMapNumSwitchovers cpqNicIfLogMapHwLocation cpqNicIfLogMapSpeed)) { |
| 135 |
printf "%s: %s\n", $_, $self->{$_}; |
| 136 |
} |
| 137 |
printf "info: %s\n", $self->{info}; |
| 138 |
printf "\n"; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
package HP::Proliant::Component::NicSubsystem::PhysicalNic; |
| 143 |
our @ISA = qw(HP::Proliant::Component::NicSubsystem); |
| 144 |
|
| 145 |
use strict; |
| 146 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 147 |
|
| 148 |
sub new { |
| 149 |
my $class = shift; |
| 150 |
my %params = @_; |
| 151 |
my $self = { |
| 152 |
runtime => $params{runtime}, |
| 153 |
blacklisted => 0, |
| 154 |
info => undef, |
| 155 |
extendedinfo => undef, |
| 156 |
}; |
| 157 |
foreach (qw(cpqNicIfPhysAdapterIndex cpqNicIfPhysAdapterIfNumber cpqNicIfPhysAdapterRole cpqNicIfPhysAdapterDuplexState cpqNicIfPhysAdapterCondition cpqNicIfPhysAdapterState cpqNicIfPhysAdapterStatus cpqNicIfPhysAdapterBadTransmits cpqNicIfPhysAdapterBadReceives)) { |
| 158 |
$self->{$_} = $params{$_}; |
| 159 |
} |
| 160 |
bless $self, $class; |
| 161 |
return $self; |
| 162 |
} |
| 163 |
|
| 164 |
sub check { |
| 165 |
my $self = shift; |
| 166 |
$self->blacklist('pni', $self->{cpqNicIfPhysAdapterIndex}); |
| 167 |
if ($self->{cpqNicIfPhysAdapterCondition} eq "other") { |
| 168 |
# hp doesnt output a clear status. i am optimistic, unknown/other |
| 169 |
# means "dont care" |
| 170 |
$self->add_info(sprintf "physical nic %d (%s) is %s", |
| 171 |
$self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, |
| 172 |
$self->{cpqNicIfPhysAdapterCondition}); |
| 173 |
} elsif ($self->{cpqNicIfPhysAdapterCondition} ne "ok") { |
| 174 |
$self->add_info(sprintf "physical nic %d (%s) is %s (%s,%s)", |
| 175 |
$self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, |
| 176 |
$self->{cpqNicIfPhysAdapterCondition}, |
| 177 |
$self->{cpqNicIfPhysAdapterState}, $self->{cpqNicIfPhysAdapterStatus}); |
| 178 |
$self->add_message(CRITICAL, $self->{info}); |
| 179 |
} else { |
| 180 |
if ($self->{cpqNicIfPhysAdapterDuplexState} ne "full") { |
| 181 |
$self->add_info(sprintf "physical nic %d (%s) is %s duplex", |
| 182 |
$self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, |
| 183 |
$self->{cpqNicIfPhysAdapterDuplexState}); |
| 184 |
} else { |
| 185 |
$self->add_info(sprintf "physical nic %d (%s) is %s", |
| 186 |
$self->{cpqNicIfPhysAdapterIndex}, $self->{cpqNicIfPhysAdapterRole}, |
| 187 |
$self->{cpqNicIfPhysAdapterCondition}); |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
sub dump { |
| 193 |
my $self = shift; |
| 194 |
printf "[PNIC_%s]\n", $self->{cpqNicIfPhysAdapterIndex}; |
| 195 |
foreach (qw(cpqNicIfPhysAdapterIndex cpqNicIfPhysAdapterIfNumber cpqNicIfPhysAdapterRole cpqNicIfPhysAdapterDuplexState cpqNicIfPhysAdapterCondition cpqNicIfPhysAdapterState cpqNicIfPhysAdapterStatus cpqNicIfPhysAdapterBadTransmits cpqNicIfPhysAdapterBadReceives)) { |
| 196 |
printf "%s: %s\n", $_, $self->{$_}; |
| 197 |
} |
| 198 |
printf "info: %s\n", $self->{info}; |
| 199 |
printf "\n"; |
| 200 |
} |
| 201 |
|
| 202 |
|