| 1 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem; |
| 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 |
fuses => [], |
| 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 |
cpqRackCommonEnclosureFuseEntry => '1.3.6.1.4.1.232.22.2.3.1.4.1', |
| 28 |
cpqRackCommonEnclosureFuseRack => '1.3.6.1.4.1.232.22.2.3.1.4.1.1', |
| 29 |
cpqRackCommonEnclosureFuseChassis => '1.3.6.1.4.1.232.22.2.3.1.4.1.2', |
| 30 |
cpqRackCommonEnclosureFuseIndex => '1.3.6.1.4.1.232.22.2.3.1.4.1.3', |
| 31 |
cpqRackCommonEnclosureFuseEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.4.1.4', |
| 32 |
cpqRackCommonEnclosureFuseLocation => '1.3.6.1.4.1.232.22.2.3.1.4.1.5', |
| 33 |
cpqRackCommonEnclosureFusePresent => '1.3.6.1.4.1.232.22.2.3.1.4.1.8', |
| 34 |
cpqRackCommonEnclosureFuseCondition => '1.3.6.1.4.1.232.22.2.3.1.4.1.11', |
| 35 |
cpqRackCommonEnclosureFusePresentValue => { |
| 36 |
1 => 'other', |
| 37 |
2 => 'absent', |
| 38 |
3 => 'present', |
| 39 |
}, |
| 40 |
cpqRackCommonEnclosureFuseConditionValue => { |
| 41 |
1 => 'other', |
| 42 |
2 => 'ok', |
| 43 |
4 => 'failed', |
| 44 |
} |
| 45 |
}; |
| 46 |
# INDEX { cpqRackCommonEnclosureFuseRack, cpqRackCommonEnclosureFuseChassis, cpqRackCommonEnclosureFuseIndex } |
| 47 |
foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureFuseEntry')) { |
| 48 |
push(@{$self->{fuses}}, |
| 49 |
HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem::Fuse->new(%{$_})); |
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
sub check { |
| 55 |
my $self = shift; |
| 56 |
foreach (@{$self->{fuses}}) { |
| 57 |
$_->check() if $_->{cpqRackCommonEnclosureFusePresent} eq 'present' || |
| 58 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
sub dump { |
| 63 |
my $self = shift; |
| 64 |
foreach (@{$self->{fuses}}) { |
| 65 |
$_->dump() if $_->{cpqRackCommonEnclosureFusePresent} eq 'present' || |
| 66 |
$self->{runtime}->{options}->{verbose} >= 3; # absent nur bei -vvv |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
package HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem::Fuse; |
| 72 |
|
| 73 |
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::FuseSubsystem); |
| 74 |
|
| 75 |
use strict; |
| 76 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 77 |
|
| 78 |
sub new { |
| 79 |
my $class = shift; |
| 80 |
my %params = @_; |
| 81 |
my $self = { |
| 82 |
runtime => $params{runtime}, |
| 83 |
rawdata => $params{rawdata}, |
| 84 |
method => $params{method}, |
| 85 |
blacklisted => 0, |
| 86 |
info => undef, |
| 87 |
extendedinfo => undef, |
| 88 |
}; |
| 89 |
map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureFuse/, keys %params; |
| 90 |
$self->{name} = $self->{cpqRackCommonEnclosureFuseRack}.':'.$self->{cpqRackCommonEnclosureFuseChassis}.':'.$self->{cpqRackCommonEnclosureFuseIndex}; |
| 91 |
bless $self, $class; |
| 92 |
return $self; |
| 93 |
} |
| 94 |
|
| 95 |
sub check { |
| 96 |
my $self = shift; |
| 97 |
$self->blacklist('fu', $self->{name}); |
| 98 |
$self->add_info(sprintf 'fuse %s is %s, location is %s, condition is %s', |
| 99 |
$self->{name}, $self->{cpqRackCommonEnclosureFusePresent}, |
| 100 |
$self->{cpqRackCommonEnclosureFuseLocation}, $self->{cpqRackCommonEnclosureFuseCondition}); |
| 101 |
if ($self->{cpqRackCommonEnclosureFuseCondition} eq 'failed') { |
| 102 |
$self->add_message(CRITICAL, $self->{info}); |
| 103 |
} elsif ($self->{cpqRackCommonEnclosureFuseCondition} ne 'ok') { |
| 104 |
$self->add_message(WARNING, $self->{info}); |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
sub dump { |
| 109 |
my $self = shift; |
| 110 |
printf "[FUSE_%s]\n", $self->{name}; |
| 111 |
foreach (qw(cpqRackCommonEnclosureFuseRack cpqRackCommonEnclosureFuseChassis |
| 112 |
cpqRackCommonEnclosureFuseIndex cpqRackCommonEnclosureFuseEnclosureName |
| 113 |
cpqRackCommonEnclosureFuseLocation cpqRackCommonEnclosureFusePresent |
| 114 |
cpqRackCommonEnclosureFuseCondition)) { |
| 115 |
printf "%s: %s\n", $_, $self->{$_}; |
| 116 |
} |
| 117 |
printf "info: %s\n", $self->{info}; |
| 118 |
printf "\n"; |
| 119 |
} |
| 120 |
|
| 121 |
1; |