| 1 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem; |
| 2 |
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem); |
| 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 |
blacklisted => 0, |
| 15 |
managers => [], |
| 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 |
cpqRackCommonEnclosureManagerEntry => '1.3.6.1.4.1.232.22.2.3.1.6.1', |
| 28 |
cpqRackCommonEnclosureManagerRack => '1.3.6.1.4.1.232.22.2.3.1.6.1.1', |
| 29 |
cpqRackCommonEnclosureManagerChassis => '1.3.6.1.4.1.232.22.2.3.1.6.1.2', |
| 30 |
cpqRackCommonEnclosureManagerIndex => '1.3.6.1.4.1.232.22.2.3.1.6.1.3', |
| 31 |
cpqRackCommonEnclosureManagerEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.6.1.4', |
| 32 |
cpqRackCommonEnclosureManagerLocation => '1.3.6.1.4.1.232.22.2.3.1.6.1.5', |
| 33 |
cpqRackCommonEnclosureManagerPartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.6', |
| 34 |
cpqRackCommonEnclosureManagerSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.6.1.7', |
| 35 |
cpqRackCommonEnclosureManagerSerialNum => '1.3.6.1.4.1.232.22.2.3.1.6.1.8', |
| 36 |
cpqRackCommonEnclosureManagerRole => '1.3.6.1.4.1.232.22.2.3.1.6.1.9', |
| 37 |
cpqRackCommonEnclosureManagerPresent => '1.3.6.1.4.1.232.22.2.3.1.6.1.10', |
| 38 |
cpqRackCommonEnclosureManagerRedundant => '1.3.6.1.4.1.232.22.2.3.1.6.1.11', |
| 39 |
cpqRackCommonEnclosureManagerCondition => '1.3.6.1.4.1.232.22.2.3.1.6.1.12', |
| 40 |
cpqRackCommonEnclosureManagerFWRev => '1.3.6.1.4.1.232.22.2.3.1.6.1.15', |
| 41 |
cpqRackCommonEnclosureManagerRoleValue => { |
| 42 |
1 => 'standby', |
| 43 |
2 => 'active', |
| 44 |
}, |
| 45 |
cpqRackCommonEnclosureManagerPresentValue => { |
| 46 |
1 => 'other', |
| 47 |
2 => 'absent', # mit vorsicht zu geniessen! |
| 48 |
3 => 'present', |
| 49 |
}, |
| 50 |
cpqRackCommonEnclosureManagerRedundantValue => { |
| 51 |
0 => 'other', # meiner phantasie entsprungen, da sich hp nicht aeussert |
| 52 |
1 => 'other', |
| 53 |
2 => 'notRedundant', |
| 54 |
3 => 'redundant', |
| 55 |
}, |
| 56 |
cpqRackCommonEnclosureManagerConditionValue => { |
| 57 |
1 => 'other', |
| 58 |
2 => 'ok', |
| 59 |
3 => 'degraded', |
| 60 |
4 => 'failed', |
| 61 |
} |
| 62 |
}; |
| 63 |
# INDEX { cpqRackCommonEnclosureManagerRack, cpqRackCommonEnclosureManagerChassis, cpqRackCommonEnclosureManagerIndex } |
| 64 |
foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureManagerEntry')) { |
| 65 |
push(@{$self->{managers}}, |
| 66 |
HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager->new(%{$_})); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
sub check { |
| 71 |
my $self = shift; |
| 72 |
foreach (@{$self->{managers}}) { |
| 73 |
$_->check() if $_->{cpqRackCommonEnclosureManagerPresent} 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->{managers}}) { |
| 81 |
$_->dump() if $_->{cpqRackCommonEnclosureManagerPresent} eq 'present' || |
| 82 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem::Manager; |
| 88 |
|
| 89 |
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::ManagerSubsystem); |
| 90 |
|
| 91 |
use strict; |
| 92 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 93 |
|
| 94 |
sub new { |
| 95 |
my $class = shift; |
| 96 |
my %params = @_; |
| 97 |
my $self = { |
| 98 |
runtime => $params{runtime}, |
| 99 |
rawdata => $params{rawdata}, |
| 100 |
method => $params{method}, |
| 101 |
blacklisted => 0, |
| 102 |
info => undef, |
| 103 |
extendedinfo => undef, |
| 104 |
}; |
| 105 |
map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureManager/, keys %params; |
| 106 |
$self->{name} = $self->{cpqRackCommonEnclosureManagerRack}. |
| 107 |
':'.$self->{cpqRackCommonEnclosureManagerChassis}. |
| 108 |
':'.$self->{cpqRackCommonEnclosureManagerIndex}; |
| 109 |
if ($self->{cpqRackCommonEnclosureManagerPresent} eq "absent" && |
| 110 |
defined $self->{cpqRackCommonEnclosureManagerEnclosureName}) { |
| 111 |
$self->{cpqRackCommonEnclosureManagerPresent} = "present"; |
| 112 |
} |
| 113 |
bless $self, $class; |
| 114 |
return $self; |
| 115 |
} |
| 116 |
|
| 117 |
sub check { |
| 118 |
my $self = shift; |
| 119 |
$self->blacklist('em', $self->{name}); |
| 120 |
my $info = sprintf 'manager %s is %s, location is %s, redundance is %s, condition is %s, role is %s', |
| 121 |
$self->{name}, $self->{cpqRackCommonEnclosureManagerPresent}, |
| 122 |
$self->{cpqRackCommonEnclosureManagerLocation}, |
| 123 |
$self->{cpqRackCommonEnclosureManagerRedundant}, |
| 124 |
$self->{cpqRackCommonEnclosureManagerCondition}, |
| 125 |
$self->{cpqRackCommonEnclosureManagerRole}; |
| 126 |
$self->add_info($info) if $self->{cpqRackCommonEnclosureManagerPresent} eq 'present' || |
| 127 |
$self->{runtime}->{options}->{verbose} >= 3; # absent managers nur bei -vvv |
| 128 |
if ($self->{cpqRackCommonEnclosureManagerCondition} eq 'degraded') { |
| 129 |
$self->{info} .= sprintf ' (SparePartNum: %s)', |
| 130 |
$self->{cpqRackCommonEnclosureManagerSparePartNumber}; |
| 131 |
$self->add_message(WARNING, $self->{info}); |
| 132 |
} elsif ($self->{cpqRackCommonEnclosureManagerCondition} eq 'failed') { |
| 133 |
$self->{info} .= sprintf ' (SparePartNum: %s)', |
| 134 |
$self->{cpqRackCommonEnclosureManagerSparePartNumber}; |
| 135 |
$self->add_message(CRITICAL, $self->{info}); |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
sub dump { |
| 140 |
my $self = shift; |
| 141 |
printf "[ENCLOSURE_MANAGER_%s]\n", $self->{name}; |
| 142 |
foreach (qw(cpqRackCommonEnclosureManagerRack cpqRackCommonEnclosureManagerChassis |
| 143 |
cpqRackCommonEnclosureManagerIndex cpqRackCommonEnclosureManagerEnclosureName |
| 144 |
cpqRackCommonEnclosureManagerLocation cpqRackCommonEnclosureManagerPartNumber |
| 145 |
cpqRackCommonEnclosureManagerSparePartNumber cpqRackCommonEnclosureManagerPresent |
| 146 |
cpqRackCommonEnclosureManagerRedundant |
| 147 |
cpqRackCommonEnclosureManagerCondition cpqRackCommonEnclosureManagerFWRev)) { |
| 148 |
printf "%s: %s\n", $_, $self->{$_}; |
| 149 |
} |
| 150 |
printf "info: %s\n", $self->{info}; |
| 151 |
printf "\n"; |
| 152 |
} |
| 153 |
|
| 154 |
1; |