| 1 |
package HP::Storage; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 }; |
| 5 |
use Data::Dumper; |
| 6 |
|
| 7 |
our @ISA = qw(HP::Server); |
| 8 |
|
| 9 |
sub init { |
| 10 |
my $self = shift; |
| 11 |
$self->{components} = { |
| 12 |
powersupply_subsystem => undef, |
| 13 |
fan_subsystem => undef, |
| 14 |
temperature_subsystem => undef, |
| 15 |
cpu_subsystem => undef, |
| 16 |
memory_subsystem => undef, |
| 17 |
disk_subsystem => undef, |
| 18 |
sensor_subsystem => undef, |
| 19 |
}; |
| 20 |
$self->{serial} = 'unknown'; |
| 21 |
$self->{product} = 'unknown'; |
| 22 |
$self->{romversion} = 'unknown'; |
| 23 |
$self->collect(); |
| 24 |
if (! $self->{runtime}->{plugin}->check_messages()) { |
| 25 |
$self->set_serial(); |
| 26 |
# $self->check_for_buggy_firmware(); |
| 27 |
# $self->analyze_cpus(); |
| 28 |
# $self->analyze_powersupplies(); |
| 29 |
# $self->analyze_fan_subsystem(); |
| 30 |
# $self->analyze_temperatures(); |
| 31 |
# $self->analyze_memory_subsystem(); |
| 32 |
$self->analyze_disk_subsystem(); |
| 33 |
## $self->analyze_sensor_subsystem(); |
| 34 |
# $self->check_cpus(); |
| 35 |
# $self->check_powersupplies(); |
| 36 |
# $self->check_fan_subsystem(); |
| 37 |
# $self->check_temperatures(); |
| 38 |
# $self->check_memory_subsystem(); |
| 39 |
$self->check_disk_subsystem(); |
| 40 |
## $self->check_sensor_subsystem(); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
sub identify { |
| 45 |
my $self = shift; |
| 46 |
return sprintf "System: '%s', S/N: '%s', ROM: '%s'", |
| 47 |
$self->{product}, $self->{serial}, $self->{romversion}; |
| 48 |
} |
| 49 |
|
| 50 |
sub check_for_buggy_firmware { |
| 51 |
my $self = shift; |
| 52 |
my @buggyfirmwares = ( |
| 53 |
"P24 12/11/2001", |
| 54 |
"P24 11/15/2002", |
| 55 |
"D13 06/03/2003", |
| 56 |
"D13 09/15/2004", |
| 57 |
"P20 12/17/2002" |
| 58 |
); |
| 59 |
$self->{runtime}->{options}->{buggy_firmware} = |
| 60 |
grep /^$self->{romversion}/, @buggyfirmwares; |
| 61 |
} |
| 62 |
|
| 63 |
sub dump { |
| 64 |
my $self = shift; |
| 65 |
printf STDERR "serial %s\n", $self->{serial}; |
| 66 |
printf STDERR "product %s\n", $self->{product}; |
| 67 |
printf STDERR "romversion %s\n", $self->{romversion}; |
| 68 |
printf STDERR "%s\n", Data::Dumper::Dumper($self->{components}); |
| 69 |
} |
| 70 |
|
| 71 |
sub analyze_powersupplies { |
| 72 |
my $self = shift; |
| 73 |
$self->{components}->{powersupply_subsystem} = |
| 74 |
HP::Storage::Component::PowersupplySubsystem->new( |
| 75 |
rawdata => $self->{rawdata}, |
| 76 |
method => $self->{method}, |
| 77 |
runtime => $self->{runtime}, |
| 78 |
); |
| 79 |
} |
| 80 |
|
| 81 |
sub analyze_fan_subsystem { |
| 82 |
my $self = shift; |
| 83 |
$self->{components}->{fan_subsystem} = |
| 84 |
HP::Storage::Component::FanSubsystem->new( |
| 85 |
rawdata => $self->{rawdata}, |
| 86 |
method => $self->{method}, |
| 87 |
runtime => $self->{runtime}, |
| 88 |
); |
| 89 |
} |
| 90 |
|
| 91 |
sub analyze_temperatures { |
| 92 |
my $self = shift; |
| 93 |
$self->{components}->{temperature_subsystem} = |
| 94 |
HP::Storage::Component::TemperatureSubsystem->new( |
| 95 |
rawdata => $self->{rawdata}, |
| 96 |
method => $self->{method}, |
| 97 |
runtime => $self->{runtime}, |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
sub analyze_cpus { |
| 102 |
my $self = shift; |
| 103 |
$self->{components}->{cpu_subsystem} = |
| 104 |
HP::Storage::Component::CpuSubsystem->new( |
| 105 |
rawdata => $self->{rawdata}, |
| 106 |
method => $self->{method}, |
| 107 |
runtime => $self->{runtime}, |
| 108 |
); |
| 109 |
} |
| 110 |
|
| 111 |
sub analyze_memory_subsystem { |
| 112 |
my $self = shift; |
| 113 |
$self->{components}->{memory_subsystem} = |
| 114 |
HP::Storage::Component::MemorySubsystem->new( |
| 115 |
rawdata => $self->{rawdata}, |
| 116 |
method => $self->{method}, |
| 117 |
runtime => $self->{runtime}, |
| 118 |
); |
| 119 |
} |
| 120 |
|
| 121 |
sub analyze_disk_subsystem { |
| 122 |
my $self = shift; |
| 123 |
$self->{components}->{disk_subsystem} = |
| 124 |
HP::Proliant::Component::DiskSubsystem->new( |
| 125 |
rawdata => $self->{rawdata}, |
| 126 |
method => $self->{method}, |
| 127 |
runtime => $self->{runtime}, |
| 128 |
); |
| 129 |
} |
| 130 |
|
| 131 |
sub analyze_sensor_subsystem { |
| 132 |
my $self = shift; |
| 133 |
$self->{components}->{sensor_subsystem} = |
| 134 |
HP::FCMGMT::Component::SensorSubsystem->new( |
| 135 |
rawdata => $self->{rawdata}, |
| 136 |
method => $self->{method}, |
| 137 |
runtime => $self->{runtime}, |
| 138 |
); |
| 139 |
} |
| 140 |
|
| 141 |
sub check_cpus { |
| 142 |
my $self = shift; |
| 143 |
$self->{components}->{cpu_subsystem}->check(); |
| 144 |
$self->{components}->{cpu_subsystem}->dump() |
| 145 |
if $self->{runtime}->{options}->{verbose} >= 2; |
| 146 |
} |
| 147 |
|
| 148 |
sub check_powersupplies { |
| 149 |
my $self = shift; |
| 150 |
$self->{components}->{powersupply_subsystem}->check(); |
| 151 |
$self->{components}->{powersupply_subsystem}->dump() |
| 152 |
if $self->{runtime}->{options}->{verbose} >= 2; |
| 153 |
} |
| 154 |
|
| 155 |
sub check_fan_subsystem { |
| 156 |
my $self = shift; |
| 157 |
$self->{components}->{fan_subsystem}->check(); |
| 158 |
$self->{components}->{fan_subsystem}->dump() |
| 159 |
if $self->{runtime}->{options}->{verbose} >= 2; |
| 160 |
} |
| 161 |
|
| 162 |
sub check_temperatures { |
| 163 |
my $self = shift; |
| 164 |
$self->{components}->{temperature_subsystem}->check(); |
| 165 |
$self->{components}->{temperature_subsystem}->dump() |
| 166 |
if $self->{runtime}->{options}->{verbose} >= 2; |
| 167 |
} |
| 168 |
|
| 169 |
sub check_memory_subsystem { |
| 170 |
my $self = shift; |
| 171 |
$self->{components}->{memory_subsystem}->check(); |
| 172 |
$self->{components}->{memory_subsystem}->dump() |
| 173 |
if $self->{runtime}->{options}->{verbose} >= 2; |
| 174 |
} |
| 175 |
|
| 176 |
sub check_disk_subsystem { |
| 177 |
my $self = shift; |
| 178 |
$self->{components}->{disk_subsystem}->check(); |
| 179 |
$self->{components}->{disk_subsystem}->dump() |
| 180 |
if $self->{runtime}->{options}->{verbose} >= 1; |
| 181 |
} |
| 182 |
|
| 183 |
sub check_sensor_subsystem { |
| 184 |
my $self = shift; |
| 185 |
$self->{components}->{isensor_subsystem}->check(); |
| 186 |
$self->{components}->{sensor_subsystem}->dump() |
| 187 |
if $self->{runtime}->{options}->{verbose} >= 1; |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
sub collect { |
| 192 |
my $self = shift; |
| 193 |
if ($self->{runtime}->{plugin}->opts->snmpwalk) { |
| 194 |
my $cpqSeMibCondition = '1.3.6.1.4.1.232.6.1.3.0'; |
| 195 |
# rindsarsch! |
| 196 |
$self->{rawdata}->{$cpqSeMibCondition} = 0; |
| 197 |
if (! exists $self->{rawdata}->{$cpqSeMibCondition}) { |
| 198 |
$self->add_message(CRITICAL, |
| 199 |
'snmpwalk returns no health data (cpqhlth-mib)'); |
| 200 |
} |
| 201 |
} else { |
| 202 |
my $net_snmp_version = Net::SNMP->VERSION(); # 5.002000 or 6.000000 |
| 203 |
#$params{'-translate'} = [ |
| 204 |
# -all => 0x0 |
| 205 |
#]; |
| 206 |
my ($session, $error) = |
| 207 |
Net::SNMP->session(%{$self->{runtime}->{snmpparams}}); |
| 208 |
if (! defined $session) { |
| 209 |
$self->{plugin}->add_message(CRITICAL, 'cannot create session object'); |
| 210 |
$self->trace(1, Data::Dumper::Dumper($self->{runtime}->{snmpparams})); |
| 211 |
} else { |
| 212 |
# revMajor is often used for discovery of hp devices |
| 213 |
my $cpqSeMibRev = '1.3.6.1.4.1.232.6.1'; |
| 214 |
my $cpqSeMibRevMajor = '1.3.6.1.4.1.232.6.1.1.0'; |
| 215 |
my $cpqSeMibCondition = '1.3.6.1.4.1.232.6.1.3.0'; |
| 216 |
my $result = $session->get_request( |
| 217 |
-varbindlist => [$cpqSeMibCondition] |
| 218 |
); |
| 219 |
# rindsarsch! |
| 220 |
$result->{$cpqSeMibCondition} = 0; |
| 221 |
if (!defined($result) || |
| 222 |
$result->{$cpqSeMibCondition} eq 'noSuchInstance' || |
| 223 |
$result->{$cpqSeMibCondition} eq 'noSuchObject' || |
| 224 |
$result->{$cpqSeMibCondition} eq 'endOfMibView') { |
| 225 |
$self->add_message(CRITICAL, |
| 226 |
'snmpwalk returns no health data (cpqhlth-mib)'); |
| 227 |
$session->close; |
| 228 |
} else { |
| 229 |
# this is not reliable. many agents return 4=failed |
| 230 |
#if ($result->{$cpqSeMibCondition} != 2) { |
| 231 |
# $obstacle = "cmapeerstart"; |
| 232 |
#} |
| 233 |
} |
| 234 |
} |
| 235 |
if (! $self->{runtime}->{plugin}->check_messages()) { |
| 236 |
# snmp peer is alive |
| 237 |
$self->trace(2, sprintf "Protocol is %s", |
| 238 |
$self->{runtime}->{snmpparams}->{'-version'}); |
| 239 |
my $cpqSsSys = "1.3.6.1.4.1.232.8"; |
| 240 |
$session->translate; |
| 241 |
my $response = {}; #break the walk up in smaller pieces |
| 242 |
my $tic = time; my $tac = $tic; |
| 243 |
my $response1 = $session->get_table( |
| 244 |
-baseoid => $cpqSsSys); |
| 245 |
$tac = time; |
| 246 |
$self->trace(2, sprintf "%03d seconds for walk cpqSsSys (%d oids)", |
| 247 |
$tac - $tic, scalar(keys %{$response1})); |
| 248 |
$session->close; |
| 249 |
map { $response->{$_} = $response1->{$_} } keys %{$response1}; |
| 250 |
map { $response->{$_} =~ s/^\s+//; $response->{$_} =~ s/\s+$//; } |
| 251 |
keys %$response; |
| 252 |
$self->{rawdata} = $response; |
| 253 |
} |
| 254 |
} |
| 255 |
return $self->{runtime}->{plugin}->check_messages(); |
| 256 |
} |
| 257 |
|
| 258 |
sub set_serial { |
| 259 |
my $self = shift; |
| 260 |
my $snmpwalk = $self->{rawdata}; |
| 261 |
my @serials = (); |
| 262 |
my @models = (); |
| 263 |
my @fws = (); |
| 264 |
my $cpqSsBackplaneEntry = '1.3.6.1.4.1.232.8.2.2.6.1'; |
| 265 |
my $cpqSsBackplaneFWRev = '1.3.6.1.4.1.232.8.2.2.6.1.3'; |
| 266 |
my $cpqSsBackplaneModel = '1.3.6.1.4.1.232.8.2.2.6.1.9'; |
| 267 |
my $cpqSsBackplaneSerialNumber = '1.3.6.1.4.1.232.8.2.2.6.1.13'; |
| 268 |
# INDEX { cpqSsBackplaneChassisIndex, cpqSsBackplaneIndex } |
| 269 |
my @indexes = SNMP::Utils::get_indices($snmpwalk, |
| 270 |
$cpqSsBackplaneEntry); |
| 271 |
foreach (@indexes) { |
| 272 |
my($idx1, $idx2) = ($_->[0], $_->[1]); |
| 273 |
my $fw = SNMP::Utils::get_object($snmpwalk, |
| 274 |
$cpqSsBackplaneFWRev, $idx1, $idx2); |
| 275 |
my $model = SNMP::Utils::get_object($snmpwalk, |
| 276 |
$cpqSsBackplaneModel, $idx1, $idx2); |
| 277 |
my $serial = SNMP::Utils::get_object($snmpwalk, |
| 278 |
$cpqSsBackplaneSerialNumber, $idx1, $idx2); |
| 279 |
push(@serials, $serial); |
| 280 |
push(@models, $model); |
| 281 |
push(@fws, $fw); |
| 282 |
} |
| 283 |
|
| 284 |
$self->{serial} = join('/', @serials); |
| 285 |
$self->{product} = join('/', @models); |
| 286 |
$self->{romversion} = join('/', @fws); |
| 287 |
$self->{runtime}->{product} = $self->{product}; |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
1; |