| 1 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem; |
| 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 |
fans => [], |
| 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 |
cpqRackCommonEnclosureFanEntry => '1.3.6.1.4.1.232.22.2.3.1.3.1', |
| 28 |
cpqRackCommonEnclosureFanRack => '1.3.6.1.4.1.232.22.2.3.1.3.1.1', |
| 29 |
cpqRackCommonEnclosureFanChassis => '1.3.6.1.4.1.232.22.2.3.1.3.1.2', |
| 30 |
cpqRackCommonEnclosureFanIndex => '1.3.6.1.4.1.232.22.2.3.1.3.1.3', |
| 31 |
cpqRackCommonEnclosureFanEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.3.1.4', |
| 32 |
cpqRackCommonEnclosureFanLocation => '1.3.6.1.4.1.232.22.2.3.1.3.1.5', |
| 33 |
cpqRackCommonEnclosureFanPartNumber => '1.3.6.1.4.1.232.22.2.3.1.3.1.6', |
| 34 |
cpqRackCommonEnclosureFanSparePartNumber => '1.3.6.1.4.1.232.22.2.3.1.3.1.7', |
| 35 |
cpqRackCommonEnclosureFanPresent => '1.3.6.1.4.1.232.22.2.3.1.3.1.8', |
| 36 |
cpqRackCommonEnclosureFanRedundant => '1.3.6.1.4.1.232.22.2.3.1.3.1.9', |
| 37 |
cpqRackCommonEnclosureFanRedundantGroupId => '1.3.6.1.4.1.232.22.2.3.1.3.1.10', |
| 38 |
cpqRackCommonEnclosureFanCondition => '1.3.6.1.4.1.232.22.2.3.1.3.1.11', |
| 39 |
cpqRackCommonEnclosureFanEnclosureSerialNum => '1.3.6.1.4.1.232.22.2.3.1.3.1.12', |
| 40 |
cpqRackCommonEnclosureFanPresentValue => { |
| 41 |
1 => 'other', |
| 42 |
2 => 'absent', |
| 43 |
3 => 'present', |
| 44 |
}, |
| 45 |
cpqRackCommonEnclosureFanRedundantValue => { |
| 46 |
0 => 'other', # meiner phantasie entsprungen, da sich hp nicht aeussert |
| 47 |
1 => 'other', |
| 48 |
2 => 'notRedundant', |
| 49 |
3 => 'redundant', |
| 50 |
}, |
| 51 |
cpqRackCommonEnclosureFanConditionValue => { |
| 52 |
1 => 'other', |
| 53 |
2 => 'ok', |
| 54 |
3 => 'degraded', |
| 55 |
4 => 'failed', |
| 56 |
} |
| 57 |
}; |
| 58 |
# INDEX { cpqRackCommonEnclosureFanRack, cpqRackCommonEnclosureFanChassis, cpqRackCommonEnclosureFanIndex } |
| 59 |
foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureFanEntry')) { |
| 60 |
push(@{$self->{fans}}, |
| 61 |
HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem::Fan->new(%{$_})); |
| 62 |
} |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
sub check { |
| 67 |
my $self = shift; |
| 68 |
foreach (@{$self->{fans}}) { |
| 69 |
$_->check() if $_->{cpqRackCommonEnclosureFanPresent} eq 'present' || |
| 70 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
sub dump { |
| 75 |
my $self = shift; |
| 76 |
foreach (@{$self->{fans}}) { |
| 77 |
$_->dump() if $_->{cpqRackCommonEnclosureFanPresent} eq 'present' || |
| 78 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem::Fan; |
| 84 |
|
| 85 |
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::FanSubsystem); |
| 86 |
|
| 87 |
use strict; |
| 88 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 89 |
|
| 90 |
sub new { |
| 91 |
my $class = shift; |
| 92 |
my %params = @_; |
| 93 |
my $self = { |
| 94 |
runtime => $params{runtime}, |
| 95 |
rawdata => $params{rawdata}, |
| 96 |
method => $params{method}, |
| 97 |
blacklisted => 0, |
| 98 |
info => undef, |
| 99 |
extendedinfo => undef, |
| 100 |
}; |
| 101 |
map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureFan/, keys %params; |
| 102 |
$self->{name} = $self->{cpqRackCommonEnclosureFanRack}.':'.$self->{cpqRackCommonEnclosureFanChassis}.':'.$self->{cpqRackCommonEnclosureFanIndex}; |
| 103 |
bless $self, $class; |
| 104 |
return $self; |
| 105 |
} |
| 106 |
|
| 107 |
sub check { |
| 108 |
my $self = shift; |
| 109 |
$self->blacklist('f', $self->{name}); |
| 110 |
$self->add_info(sprintf 'fan %s is %s, location is %s, redundance is %s, condition is %s', |
| 111 |
$self->{name}, $self->{cpqRackCommonEnclosureFanPresent}, |
| 112 |
$self->{cpqRackCommonEnclosureFanLocation}, |
| 113 |
$self->{cpqRackCommonEnclosureFanRedundant}, |
| 114 |
$self->{cpqRackCommonEnclosureFanCondition}); |
| 115 |
if ($self->{cpqRackCommonEnclosureFanCondition} eq 'degraded') { |
| 116 |
$self->{info} .= sprintf ", (SparePartNum: %s)", $self->{cpqRackCommonEnclosureFanSparePartNumber}; |
| 117 |
$self->add_message(WARNING, $self->{info}); |
| 118 |
} elsif ($self->{cpqRackCommonEnclosureFanCondition} eq 'failed') { |
| 119 |
$self->{info} .= sprintf ", (SparePartNum: %s)", $self->{cpqRackCommonEnclosureFanSparePartNumber}; |
| 120 |
$self->add_message(CRITICAL, $self->{info}); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
sub dump { |
| 125 |
my $self = shift; |
| 126 |
printf "[FAN_%s]\n", $self->{name}; |
| 127 |
foreach (qw(cpqRackCommonEnclosureFanRack cpqRackCommonEnclosureFanChassis |
| 128 |
cpqRackCommonEnclosureFanIndex cpqRackCommonEnclosureFanEnclosureName |
| 129 |
cpqRackCommonEnclosureFanLocation cpqRackCommonEnclosureFanPartNumber |
| 130 |
cpqRackCommonEnclosureFanSparePartNumber cpqRackCommonEnclosureFanPresent |
| 131 |
cpqRackCommonEnclosureFanRedundant cpqRackCommonEnclosureFanRedundantGroupId |
| 132 |
cpqRackCommonEnclosureFanCondition cpqRackCommonEnclosureFanEnclosureSerialNum)) { |
| 133 |
printf "%s: %s\n", $_, $self->{$_}; |
| 134 |
} |
| 135 |
printf "info: %s\n", $self->{info}; |
| 136 |
printf "\n"; |
| 137 |
} |
| 138 |
|
| 139 |
1; |