Debian Codegraph @

check_hpasm/check_hpasm-4.9/plugins-scripts/HP/Proliant/Component/DiskSubsystem/Ide.pm

raw
1 package HP::Proliant::Component::DiskSubsystem::Ide;
2 our @ISA = qw(HP::Proliant::Component::DiskSubsystem);
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 controllers => [],
15 enclosures => [],
16 physical_drives => [],
17 logical_drives => [],
18 spare_drives => [],
19 condition => undef,
20 blacklisted => 0,
21 };
22 bless $self, $class;
23 if ($self->{method} eq 'snmp') {
24 bless $self, 'HP::Proliant::Component::DiskSubsystem::Ide::SNMP';
25 } else {
26 bless $self, 'HP::Proliant::Component::DiskSubsystem::Ide::CLI';
27 }
28 $self->init();
29 $self->assemble();
30 return $self;
31 }
32
33 sub check {
34 my $self = shift;
35 foreach (@{$self->{controllers}}) {
36 $_->check();
37 }
38 }
39
40 sub dump {
41 my $self = shift;
42 foreach (@{$self->{controllers}}) {
43 $_->dump();
44 }
45 }
46
47 package HP::Proliant::Component::DiskSubsystem::Ide::Controller;
48 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide);
49
50 use strict;
51 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
52
53 sub new {
54 my $class = shift;
55 my %params = @_;
56 my $self = {
57 runtime => $params{runtime},
58 cpqIdeControllerIndex => $params{cpqIdeControllerIndex},
59 cpqIdeControllerOverallCondition => $params{cpqIdeControllerOverallCondition},
60 cpqIdeControllerModel => $params{cpqIdeControllerModel},
61 cpqIdeControllerSlot => $params{cpqIdeControllerSlot}, # -1 ist sysboard?
62 blacklisted => 0,
63 };
64 $self->{name} = $params{name} || $self->{cpqIdeControllerIndex};
65 $self->{controllerindex} = $self->{cpqIdeControllerIndex};
66 bless $self, $class;
67 return $self;
68 }
69
70 sub check {
71 my $self = shift;
72 $self->blacklist('ideco', $self->{name});
73 if ($self->{cpqIdeControllerOverallCondition} eq 'other') {
74 if (scalar(@{$self->{physical_drives}})) {
75 $self->add_message(CRITICAL,
76 sprintf 'ide controller %s in slot %s needs attention',
77 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
78 $self->add_info(sprintf 'ide controller %s in slot %s needs attention',
79 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
80 } else {
81 $self->add_info(sprintf 'ide controller %s in slot %s is ok and unused',
82 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
83 $self->{blacklisted} = 1;
84 }
85 } elsif ($self->{cpqIdeControllerOverallCondition} ne 'ok') {
86 $self->add_message(CRITICAL,
87 sprintf 'ide controller %s in slot %s needs attention',
88 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
89 $self->add_info(sprintf 'ide controller %s in slot %s needs attention',
90 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
91 } else {
92 $self->add_info(sprintf 'ide controller %s in slot %s is ok',
93 $self->{cpqIdeControllerIndex}, $self->{cpqIdeControllerSlot});
94 }
95 foreach (@{$self->{logical_drives}}) {
96 $_->check();
97 }
98 foreach (@{$self->{physical_drives}}) {
99 $_->check();
100 }
101 foreach (@{$self->{spare_drives}}) {
102 $_->check();
103 }
104 }
105
106 sub dump {
107 my $self = shift;
108 printf "[IDE_CONTROLLER_%s]\n", $self->{name};
109 foreach (qw(cpqIdeControllerIndex cpqIdeControllerSlot
110 cpqIdeControllerModel cpqIdeControllerOverallCondition)) {
111 printf "%s: %s\n", $_, $self->{$_};
112 }
113 printf "\n";
114 foreach (@{$self->{logical_drives}}) {
115 $_->dump();
116 }
117 foreach (@{$self->{physical_drives}}) {
118 $_->dump();
119 }
120 foreach (@{$self->{spare_drives}}) {
121 $_->dump();
122 }
123 }
124
125
126 package HP::Proliant::Component::DiskSubsystem::Ide::LogicalDrive;
127 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide);
128
129 use strict;
130 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
131
132 sub new {
133 my $class = shift;
134 my %params = @_;
135 my $self = {
136 runtime => $params{runtime},
137 cpqIdeLogicalDriveControllerIndex => $params{cpqIdeLogicalDriveControllerIndex},
138 cpqIdeLogicalDriveIndex => $params{cpqIdeLogicalDriveIndex},
139 cpqIdeLogicalDriveRaidLevel => $params{cpqIdeLogicalDriveRaidLevel},
140 cpqIdeLogicalDriveCapacity => $params{cpqIdeLogicalDriveCapacity},
141 cpqIdeLogicalDriveStatus => $params{cpqIdeLogicalDriveStatus},
142 cpqIdeLogicalDriveCondition => $params{cpqIdeLogicalDriveCondition},
143 cpqIdeLogicalDriveDiskIds => $params{cpqIdeLogicalDriveDiskIds},
144 cpqIdeLogicalDriveSpareIds => $params{cpqIdeLogicalDriveSpareIds},
145 cpqIdeLogicalDriveRebuildingDisk => $params{cpqIdeLogicalDriveRebuildingDisk},
146 blacklisted => 0,
147 };
148 bless $self, $class;
149 $self->{name} = $params{name} ||
150 $self->{cpqIdeLogicalDriveControllerIndex}.':'.
151 $self->{cpqIdeLogicalDriveIndex};
152 $self->{controllerindex} = $self->{cpqIdeLogicalDriveControllerIndex};
153 return $self;
154 }
155
156 sub check {
157 my $self = shift;
158 $self->blacklist('ideld', $self->{name});
159 if ($self->{cpqIdeLogicalDriveCondition} ne "ok") {
160 if ($self->{cpqIdeLogicalDriveStatus} =~
161 /rebuild/) {
162 $self->add_message(WARNING,
163 sprintf "logical drive %s is %s",
164 $self->{name}, $self->{cpqIdeLogicalDriveStatus});
165 } else {
166 $self->add_message(CRITICAL,
167 sprintf "logical drive %s is %s",
168 $self->{name}, $self->{cpqIdeLogicalDriveStatus});
169 }
170 }
171 $self->add_info(
172 sprintf "logical drive %s is %s", $self->{name},
173 $self->{cpqIdeLogicalDriveStatus});
174 }
175
176 sub dump {
177 my $self = shift;
178 printf "[LOGICAL_DRIVE]\n";
179 foreach (qw(cpqIdeLogicalDriveControllerIndex cpqIdeLogicalDriveIndex
180 cpqIdeLogicalDriveRaidLevel cpqIdeLogicalDriveCapacity
181 cpqIdeLogicalDriveDiskIds cpqIdeLogicalDriveSpareIds
182 cpqIdeLogicalDriveRebuildingDisk cpqIdeLogicalDriveStatus
183 cpqIdeLogicalDriveCondition)) {
184 printf "%s: %s\n", $_, $self->{$_};
185 }
186 printf "\n";
187 }
188
189
190 package HP::Proliant::Component::DiskSubsystem::Ide::PhysicalDrive;
191 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide);
192
193 use strict;
194 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
195
196 sub new {
197 my $class = shift;
198 my %params = @_;
199 my $self = {
200 runtime => $params{runtime},
201 cpqIdeAtaDiskControllerIndex => $params{cpqIdeAtaDiskControllerIndex},
202 cpqIdeAtaDiskIndex => $params{cpqIdeAtaDiskIndex},
203 cpqIdeAtaDiskModel => $params{cpqIdeAtaDiskModel},
204 cpqIdeAtaDiskStatus => $params{cpqIdeAtaDiskStatus},
205 cpqIdeAtaDiskCondition => $params{cpqIdeAtaDiskCondition},
206 cpqIdeAtaDiskCapacity => $params{cpqIdeAtaDiskCapacity},
207 cpqIdeAtaDiskLogicalDriveMember => $params{cpqIdeAtaDiskLogicalDriveMember},
208 cpqIdeAtaDiskIsSpare => $params{cpqIdeAtaDiskIsSpare},
209 blacklisted => 0,
210 };
211 $self->{name} = $params{name} ||
212 $self->{cpqIdeAtaDiskControllerIndex}.':'.
213 $self->{cpqIdeAtaDiskIndex}; ####vorerst
214 $self->{controllerindex} = $self->{cpqIdeAtaDiskControllerIndex};
215 bless $self, $class;
216 return $self;
217 }
218
219 sub check {
220 my $self = shift;
221 $self->blacklist('idepd', $self->{name});
222 if ($self->{cpqIdeAtaDiskCondition} ne 'ok') {
223 $self->add_message(CRITICAL,
224 sprintf "physical drive %s is %s",
225 $self->{name}, $self->{cpqIdeAtaDiskCondition});
226 }
227 $self->add_info(
228 sprintf "physical drive %s is %s",
229 $self->{name}, $self->{cpqIdeAtaDiskCondition});
230 }
231
232 sub dump {
233 my $self = shift;
234 printf "[PHYSICAL_DRIVE]\n";
235 foreach (qw(cpqIdeAtaDiskControllerIndex cpqIdeAtaDiskIndex
236 cpqIdeAtaDiskModel cpqIdeAtaDiskCapacity cpqIdeAtaDiskLogicalDriveMember
237 cpqIdeAtaDiskStatus cpqIdeAtaDiskCondition)) {
238 printf "%s: %s\n", $_, $self->{$_};
239 }
240 printf "\n";
241 }
242
243
244 package HP::Proliant::Component::DiskSubsystem::Ide::SpareDrive;
245 our @ISA = qw(HP::Proliant::Component::DiskSubsystem::Ide);
246
247 use strict;
248 use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
249
250 sub dump {
251 my $self = shift;
252 printf "[SPARE_DRIVE]\n";
253 }
254
255
256 1;