1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
package HP::BladeSystem::Component::PowerEnclosureSubsystem;
our _æ_ ISA = qw(HP::BladeSystem::Component);
use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
sub new {
my $class = shift;
my %params = _æ_ _;
my $self = {
runtime => $params{runtime},
rawdata => $params{rawdata},
method => $params{method},
power_enclosures => [],
blacklisted => 0,
info => undef,
extendedinfo => undef,
};
bless $self, $class;
$self->init();
return $self;
}
sub init {
my $self = shift;
# cpqRackPowerEnclosureTable
my $oids = {
cpqRackPowerEnclosureEntry => '1.3.6.1.4.1.232.22.2.3.3.1.1',
cpqRackPowerEnclosureRack => '1.3.6.1.4.1.232.22.2.3.3.1.1.1',
cpqRackPowerEnclosureIndex => '1.3.6.1.4.1.232.22.2.3.3.1.1.2',
cpqRackPowerEnclosureName => '1.3.6.1.4.1.232.22.2.3.3.1.1.3',
cpqRackPowerEnclosureMgmgtBoardSerialNum => '1.3.6.1.4.1.232.22.2.3.3.1.1.4',
cpqRackPowerEnclosureRedundant => '1.3.6.1.4.1.232.22.2.3.3.1.1.5',
cpqRackPowerEnclosureLoadBalanced => '1.3.6.1.4.1.232.22.2.3.3.1.1.6',
cpqRackPowerEnclosureInputPwrType => '1.3.6.1.4.1.232.22.2.3.3.1.1.7',
cpqRackPowerEnclosurePwrFeedMax => '1.3.6.1.4.1.232.22.2.3.3.1.1.8',
cpqRackPowerEnclosureCondition => '1.3.6.1.4.1.232.22.2.3.3.1.1.9',
cpqRackPowerEnclosureRedundantValue => {
1 => 'other',
2 => 'notRedundant',
3 => 'redundant',
},
cpqRackPowerEnclosureLoadBalancedValue => {
0 => 'aechz',
1 => 'other',
2 => 'notLoadBalanced',
3 => 'loadBalanced',
},
cpqRackPowerEnclosureInputPwrTypeValue => {
1 => 'other',
2 => 'singlePhase',
3 => 'threePhase',
4 => 'directCurrent',
},
cpqRackPowerEnclosureConditionValue => {
1 => 'other',
2 => 'ok',
3 => 'degraded',
},
};
# INDEX { cpqRackPowerEnclosureRack, cpqRackPowerEnclosureIndex }
# dreckada dreck, dreckada
foreach ($self->get_entries($oids, 'cpqRackPowerEnclosureEntry')) {
push( _æ_ {$self->{power_enclosures}},
HP::BladeSystem::Component::PowerEnclosureSubsystem::PowerEnclosure->new(%{$_}));
}
}
sub check {
my $self = shift;
foreach ( _æ_ {$self->{power_enclosures}}) {
$_->check();
}
}
sub dump {
my $self = shift;
foreach ( _æ_ {$self->{power_enclosures}}) {
$_->dump();
}
}
package HP::BladeSystem::Component::PowerEnclosureSubsystem::PowerEnclosure;
our _æ_ ISA = qw(HP::BladeSystem::Component::PowerEnclosureSubsystem);
use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
sub new {
my $class = shift;
my %params = _æ_ _;
my $self = {
runtime => $params{runtime},
rawdata => $params{rawdata},
method => $params{method},
blacklisted => 0,
info => undef,
extendedinfo => undef,
};
map { $self->{$_} = $params{$_} } grep /cpqRackPowerEnclosure/, keys %params;
$self->{name} = $self->{cpqRackPowerEnclosureRack}.':'.$self->{cpqRackPowerEnclosureIndex};
bless $self, $class;
$self->init();
return $self;
}
sub check {
my $self = shift;
$self->blacklist('pe', $self->{name});
my $info = sprintf 'power enclosure %s \'%s\' condition is %s',
$self->{name}, $self->{cpqRackPowerEnclosureName}, $self->{cpqRackPowerEnclosureCondition};
$self->add_info($info);
if ($self->{cpqRackPowerEnclosureCondition} eq 'degraded') {
$self->add_message(WARNING, $info);
}
}
sub dump {
my $self = shift;
printf "[POWER_ENCLOSURE_%s]\n", $self->{cpqRackPowerEnclosureName};
foreach (qw(cpqRackPowerEnclosureRack cpqRackPowerEnclosureIndex
cpqRackPowerEnclosureName cpqRackPowerEnclosureMgmgtBoardSerialNum
cpqRackPowerEnclosureRedundant cpqRackPowerEnclosureLoadBalanced
cpqRackPowerEnclosureInputPwrType cpqRackPowerEnclosurePwrFeedMax
cpqRackPowerEnclosureCondition)) {
printf "%s: %s\n", $_, $self->{$_};
}
printf "\n";
}
1;
|