Debian Codegraph @

check_hpasm/src/plugins-scripts/HP/Proliant/Component/FanSubsystem/SNMP.pm

raw
1 package HP::Proliant::Component::FanSubsystem::SNMP;
2 our @ISA = qw(HP::Proliant::Component::FanSubsystem
3 HP::Proliant::Component::SNMP);
4
5 use strict;
6 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
7
8 sub new {
9 my $class = shift;
10 my %params = @_;
11 my $self = {
12 runtime => $params{runtime},
13 rawdata => $params{rawdata},
14 fans => [],
15 he_fans => [],
16 th_fans => [],
17 blacklisted => 0,
18 info => undef,
19 extendedinfo => undef,
20 };
21 bless $self, $class;
22 $self->overall_init(%params);
23 $self->he_init(%params);
24 $self->te_init(%params);
25 $self->unite();
26 return $self;
27 }
28
29 sub overall_init {
30 my $self = shift;
31 my %params = @_;
32 my $snmpwalk = $params{rawdata};
33 # overall
34 my $cpqHeThermalSystemFanStatus = '1.3.6.1.4.1.232.6.2.6.4.0';
35 my $cpqHeThermalSystemFanStatusValue = {
36 1 => 'other',
37 2 => 'ok',
38 3 => 'degraded',
39 4 => 'failed',
40 };
41 my $cpqHeThermalCpuFanStatus = '1.3.6.1.4.1.232.6.2.6.5.0';
42 my $cpqHeThermalCpuFanStatusValue = {
43 1 => 'other',
44 2 => 'ok',
45 4 => 'failed', # shutdown
46 };
47 $self->{sysstatus} = SNMP::Utils::get_object_value(
48 $snmpwalk, $cpqHeThermalSystemFanStatus,
49 $cpqHeThermalSystemFanStatusValue);
50 $self->{cpustatus} = SNMP::Utils::get_object_value(
51 $snmpwalk, $cpqHeThermalCpuFanStatus,
52 $cpqHeThermalCpuFanStatusValue);
53 $self->{sysstatus} |= lc $self->{sysstatus};
54 $self->{cpustatus} |= lc $self->{cpustatus};
55 }
56
57 sub te_init {
58 my $self = shift;
59 my %params = @_;
60 my $snmpwalk = $params{rawdata};
61 my $ignore_redundancy = $params{ignore_redundancy};
62 # cpqHeThermalFanTable
63 my $oids = {
64 cpqHeThermalFanEntry => '1.3.6.1.4.1.232.6.2.6.6.1',
65 cpqHeThermalFanIndex => '1.3.6.1.4.1.232.6.2.6.6.1.1',
66 cpqHeThermalFanRequired => '1.3.6.1.4.1.232.6.2.6.6.1.2',
67 cpqHeThermalFanPresent => '1.3.6.1.4.1.232.6.2.6.6.1.3',
68 cpqHeThermalFanCpuFan => '1.3.6.1.4.1.232.6.2.6.6.1.4',
69 cpqHeThermalFanStatus => '1.3.6.1.4.1.232.6.2.6.6.1.5',
70 cpqHeThermalFanHwLocation => '1.3.6.1.4.1.232.6.2.6.6.1.6',
71 cpqHeThermalFanRequiredValue => {
72 1 => 'other',
73 2 => 'nonRequired',
74 3 => 'required',
75 },
76 cpqHeThermalFanPresentValue => {
77 1 => 'other',
78 2 => 'absent',
79 3 => 'present',
80 },
81 cpqHeThermalFanCpuFanValue => {
82 1 => 'other',
83 2 => 'systemFan',
84 3 => 'cpuFan',
85 },
86 cpqHeThermalFanStatusValue => {
87 1 => 'other',
88 2 => 'ok',
89 4 => 'failed',
90 },
91 };
92 # INDEX { cpqHeThermalFanIndex }
93 foreach ($self->get_entries($oids, 'cpqHeThermalFanEntry')) {
94 next if ! $_->{cpqHeThermalFanPresent};
95 push(@{$self->{th_fans}},
96 HP::Proliant::Component::FanSubsystem::Fan->new(%{$_}));
97 }
98 }
99
100 sub he_init {
101 my $self = shift;
102 my %params = @_;
103 my $snmpwalk = $params{rawdata};
104 my $ignore_redundancy = $params{ignore_redundancy};
105 # cpqHeFltTolFanTable
106 my $oids = {
107 cpqHeFltTolFanEntry => '1.3.6.1.4.1.232.6.2.6.7.1',
108 cpqHeFltTolFanChassis => '1.3.6.1.4.1.232.6.2.6.7.1.1',
109 cpqHeFltTolFanIndex => '1.3.6.1.4.1.232.6.2.6.7.1.2',
110 cpqHeFltTolFanLocale => '1.3.6.1.4.1.232.6.2.6.7.1.3',
111 cpqHeFltTolFanPresent => '1.3.6.1.4.1.232.6.2.6.7.1.4',
112 cpqHeFltTolFanType => '1.3.6.1.4.1.232.6.2.6.7.1.5',
113 cpqHeFltTolFanSpeed => '1.3.6.1.4.1.232.6.2.6.7.1.6',
114 cpqHeFltTolFanRedundant => '1.3.6.1.4.1.232.6.2.6.7.1.7',
115 cpqHeFltTolFanRedundantPartner => '1.3.6.1.4.1.232.6.2.6.7.1.8',
116 cpqHeFltTolFanCondition => '1.3.6.1.4.1.232.6.2.6.7.1.9',
117 cpqHeFltTolFanHotPlug => '1.3.6.1.4.1.232.6.2.6.7.1.10',
118 cpqHeFltTolFanHwLocation => '1.3.6.1.4.1.232.6.2.6.7.1.11',
119 cpqHeFltTolFanCurrentSpeed => '1.3.6.1.4.1.232.6.2.6.7.1.12',
120 cpqHeFltTolFanLocaleValue => {
121 1 => "other",
122 2 => "unknown",
123 3 => "system",
124 4 => "systemBoard",
125 5 => "ioBoard",
126 6 => "cpu",
127 7 => "memory",
128 8 => "storage",
129 9 => "removableMedia",
130 10 => "powerSupply",
131 11 => "ambient",
132 12 => "chassis",
133 13 => "bridgeCard",
134 14 => "managementBoard",
135 15 => "backplane",
136 16 => "networkSlot",
137 17 => "bladeSlot",
138 18 => "virtual",
139 },
140 cpqHeFltTolFanPresentValue => {
141 1 => "other",
142 2 => "absent",
143 3 => "present",
144 },
145 cpqHeFltTolFanSpeedValue => {
146 1 => "other",
147 2 => "normal",
148 3 => "high",
149 },
150 cpqHeFltTolFanRedundantValue => {
151 1 => "other",
152 2 => "notRedundant",
153 3 => "redundant",
154 },
155 cpqHeFltTolFanTypeValue => {
156 1 => "other",
157 2 => "tachInput",
158 3 => "spinDetect",
159 },
160 cpqHeFltTolFanConditionValue => {
161 1 => "other",
162 2 => "ok",
163 3 => "degraded",
164 4 => "failed",
165 },
166 cpqHeFltTolFanHotPlugValue => {
167 1 => "other",
168 2 => "nonHotPluggable",
169 3 => "hotPluggable",
170 },
171 };
172 # INDEX { cpqHeFltTolFanChassis, cpqHeFltTolFanIndex }
173 foreach ($self->get_entries($oids, 'cpqHeFltTolFanEntry')) {
174 next if ! defined $_->{cpqHeFltTolFanIndex};
175 # z.b. USM65201WS hat nur solche fragmente. die werden erst gar nicht
176 # als fans akzeptiert. dafuer gibts dann die overall condition
177 # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.1 = INTEGER: 0
178 # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.2 = INTEGER: 0
179 $_->{cpqHeFltTolFanPctMax} = ($_->{cpqHeFltTolFanPresent} eq 'present') ?
180 50 : 0;
181 push(@{$self->{he_fans}},
182 HP::Proliant::Component::FanSubsystem::Fan->new(%{$_}));
183 }
184
185 }
186
187 sub unite {
188 my $self = shift;
189 my $tmpfans = {};
190 foreach (@{$self->{he_fans}}) {
191 $tmpfans->{$_->{cpqHeFltTolFanIndex}} = $_;
192 }
193 foreach (@{$self->{he_fans}}) {
194 if (exists $tmpfans->{$_->{cpqHeFltTolFanRedundantPartner}}) {
195 $_->{partner} = $tmpfans->{$_->{cpqHeFltTolFanRedundantPartner}};
196 } else {
197 $_->{partner} = undef;
198 }
199 }
200 @{$self->{fans}} = @{$self->{he_fans}};
201 }
202
203 sub overall_check {
204 my $self = shift;
205 my $result = 0;
206 $self->blacklist('ofs', '');
207 if ($self->{sysstatus} && $self->{cpustatus}) {
208 if ($self->{sysstatus} eq 'degraded') {
209 $result = 1;
210 $self->add_message(WARNING,
211 sprintf 'system fan overall status is %s', $self->{sysstatus});
212 } elsif ($self->{sysstatus} eq 'failed') {
213 $result = 2;
214 $self->add_message(CRITICAL,
215 sprintf 'system fan overall status is %s', $self->{sysstatus});
216 }
217 if ($self->{cpustatus} eq 'degraded') {
218 $result = 1;
219 $self->add_message(WARNING,
220 sprintf 'cpu fan overall status is %s', $self->{cpustatus});
221 } elsif ($self->{cpustatus} eq 'failed') {
222 $result = 2;
223 $self->add_message(CRITICAL,
224 sprintf 'cpu fan overall status is %s', $self->{cpustatus});
225 }
226 $self->add_info(sprintf 'overall fan status: system=%s, cpu=%s',
227 $self->{sysstatus}, $self->{cpustatus});
228 } else {
229 $result = 0;
230 $self->add_info('this system seems to be water-cooled. no fans found');
231 }
232 return $result;
233 }
234
235 1;
236