| 1 |
package HP::BladeSystem::Component::NetConnectorSubsystem; |
| 2 |
our @ISA = qw(HP::BladeSystem::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 |
net_connectors => [], |
| 15 |
blacklisted => 0, |
| 16 |
info => undef, |
| 17 |
extendedinfo => undef, |
| 18 |
}; |
| 19 |
bless $self, $class; |
| 20 |
$self->init(); |
| 21 |
return $self; |
| 22 |
} |
| 23 |
|
| 24 |
sub init { |
| 25 |
my $self = shift; |
| 26 |
my $oids = { |
| 27 |
cpqRackNetConnectorEntry => '1.3.6.1.4.1.232.22.2.6.1.1.1', |
| 28 |
cpqRackNetConnectorRack => '1.3.6.1.4.1.232.22.2.6.1.1.1.1', |
| 29 |
cpqRackNetConnectorChassis => '1.3.6.1.4.1.232.22.2.6.1.1.1.2', |
| 30 |
cpqRackNetConnectorIndex => '1.3.6.1.4.1.232.22.2.6.1.1.1.3', |
| 31 |
cpqRackNetConnectorEnclosureName => '1.3.6.1.4.1.232.22.2.6.1.1.1.4', |
| 32 |
cpqRackNetConnectorName => '1.3.6.1.4.1.232.22.2.6.1.1.1.5', |
| 33 |
cpqRackNetConnectorModel => '1.3.6.1.4.1.232.22.2.6.1.1.1.6', |
| 34 |
cpqRackNetConnectorSerialNum => '1.3.6.1.4.1.232.22.2.6.1.1.1.7', |
| 35 |
cpqRackNetConnectorPartNumber => '1.3.6.1.4.1.232.22.2.6.1.1.1.8', |
| 36 |
cpqRackNetConnectorSparePartNumber => '1.3.6.1.4.1.232.22.2.6.1.1.1.9', |
| 37 |
cpqRackNetConnectorFWRev => '1.3.6.1.4.1.232.22.2.6.1.1.1.10', |
| 38 |
cpqRackNetConnectorType => '1.3.6.1.4.1.232.22.2.6.1.1.1.11', |
| 39 |
cpqRackNetConnectorLocation => '1.3.6.1.4.1.232.22.2.6.1.1.1.12', |
| 40 |
cpqRackNetConnectorPresent => '1.3.6.1.4.1.232.22.2.6.1.1.1.13', |
| 41 |
cpqRackNetConnectorHasFuses => '1.3.6.1.4.1.232.22.2.6.1.1.1.14', |
| 42 |
cpqRackNetConnectorEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.6.1.1.1.15', |
| 43 |
cpqRackNetConnectorTypeValue => { |
| 44 |
0 => 'other', # undefined |
| 45 |
1 => 'other', |
| 46 |
2 => 'active', |
| 47 |
3 => 'passive', |
| 48 |
}, |
| 49 |
cpqRackNetConnectorPresentValue => { |
| 50 |
1 => 'other', |
| 51 |
2 => 'absent', |
| 52 |
3 => 'present', |
| 53 |
}, |
| 54 |
cpqRackNetConnectorHasFusesValue => { |
| 55 |
-1 => 'false', # wird geliefert, also vermute ich false |
| 56 |
1 => 'false', |
| 57 |
2 => 'true', |
| 58 |
}, |
| 59 |
}; |
| 60 |
|
| 61 |
|
| 62 |
# INDEX { cpqRackNetConnectorRack, cpqRackNetConnectorChassis, cpqRackNetConnectorIndex } |
| 63 |
# dreckada dreck, dreckada |
| 64 |
foreach ($self->get_entries($oids, 'cpqRackNetConnectorEntry')) { |
| 65 |
push(@{$self->{net_connectors}}, |
| 66 |
HP::BladeSystem::Component::NetConnectorSubsystem::NetConnector->new(%{$_})); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
sub check { |
| 71 |
my $self = shift; |
| 72 |
foreach (@{$self->{net_connectors}}) { |
| 73 |
$_->check() if $_->{cpqRackNetConnectorPresent} eq 'present' || |
| 74 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
sub dump { |
| 79 |
my $self = shift; |
| 80 |
foreach (@{$self->{net_connectors}}) { |
| 81 |
$_->dump() if $_->{cpqRackNetConnectorPresent} eq 'present' || |
| 82 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
package HP::BladeSystem::Component::NetConnectorSubsystem::NetConnector; |
| 88 |
our @ISA = qw(HP::BladeSystem::Component::NetConnectorSubsystem); |
| 89 |
|
| 90 |
use strict; |
| 91 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 92 |
|
| 93 |
sub new { |
| 94 |
my $class = shift; |
| 95 |
my %params = @_; |
| 96 |
my $self = { |
| 97 |
runtime => $params{runtime}, |
| 98 |
rawdata => $params{rawdata}, |
| 99 |
method => $params{method}, |
| 100 |
blacklisted => 0, |
| 101 |
info => undef, |
| 102 |
extendedinfo => undef, |
| 103 |
}; |
| 104 |
map { $self->{$_} = $params{$_} } grep /cpqRackNetConnector/, keys %params; |
| 105 |
$self->{name} = $params{cpqRackNetConnectorRack}. |
| 106 |
':'.$params{cpqRackNetConnectorChassis}. |
| 107 |
':'.$params{cpqRackNetConnectorIndex}; |
| 108 |
$self->{serfw} = sprintf "Ser: %s, FW: %s", $self->{cpqRackNetConnectorSerialNum}, $self->{cpqRackNetConnectorFWRev}; |
| 109 |
bless $self, $class; |
| 110 |
return $self; |
| 111 |
} |
| 112 |
|
| 113 |
sub check { |
| 114 |
my $self = shift; |
| 115 |
$self->blacklist('nc', $self->{name}); |
| 116 |
my $info = sprintf 'net connector %s is %s, model is %s (%s)', |
| 117 |
$self->{name}.($self->{cpqRackNetConnectorName} ? ' \''.$self->{cpqRackNetConnectorName}.'\'' : ''), |
| 118 |
$self->{cpqRackNetConnectorPresent}, $self->{cpqRackNetConnectorModel}, $self->{serfw}; |
| 119 |
$self->add_info($info); |
| 120 |
# hat weder status noch condition, vielleicht spaeter mal |
| 121 |
$info .= sprintf " (SparePartNum %s)", $self->{cpqRackNetConnectorSparePartNumber}; |
| 122 |
} |
| 123 |
|
| 124 |
sub dump { |
| 125 |
my $self = shift; |
| 126 |
printf "[NET_CONNECTOR_%s]\n", $self->{cpqRackNetConnectorName}; |
| 127 |
foreach (qw(cpqRackNetConnectorRack cpqRackNetConnectorChassis cpqRackNetConnectorIndex cpqRackNetConnectorEnclosureName cpqRackNetConnectorName cpqRackNetConnectorModel cpqRackNetConnectorSerialNum cpqRackNetConnectorPartNumber cpqRackNetConnectorSparePartNumber cpqRackNetConnectorFWRev cpqRackNetConnectorType cpqRackNetConnectorLocation cpqRackNetConnectorPresent cpqRackNetConnectorHasFuses cpqRackNetConnectorEnclosureSerialNum)) { |
| 128 |
printf "%s: %s\n", $_, $self->{$_}; |
| 129 |
} |
| 130 |
printf "\n"; |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
1; |