Debian Codegraph @

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

raw
1 package HP::Proliant::Component::BatterySubsystem::SNMP;
2 our @ISA = qw(HP::Proliant::Component::BatterySubsystem
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 sysbatteries => [],
15 blacklisted => 0,
16 info => undef,
17 extendedinfo => undef,
18 };
19 bless $self, $class;
20 $self->init(%params);
21 return $self;
22 }
23
24 sub init {
25 my $self = shift;
26 my %params = @_;
27 my $snmpwalk = $self->{rawdata};
28 my $oids = {
29 cpqHeSysBatteryTable => '1.3.6.1.4.1.232.6.2.17.2',
30 cpqHeSysBatteryEntry => '1.3.6.1.4.1.232.6.2.17.2.1',
31 cpqHeSysBatteryChassis => '1.3.6.1.4.1.232.6.2.17.2.1.1',
32 cpqHeSysBatteryIndex => '1.3.6.1.4.1.232.6.2.17.2.1.2',
33 cpqHeSysBatteryPresent => '1.3.6.1.4.1.232.6.2.17.2.1.3',
34 cpqHeSysBatteryPresentValue => {
35 '1' => 'other',
36 '2' => 'absent',
37 '3' => 'present',
38 },
39 cpqHeSysBatteryCondition => '1.3.6.1.4.1.232.6.2.17.2.1.4',
40 cpqHeSysBatteryConditionValue => {
41 '1' => 'other',
42 '2' => 'ok',
43 '3' => 'degraded',
44 '4' => 'failed',
45 },
46 cpqHeSysBatteryStatus => '1.3.6.1.4.1.232.6.2.17.2.1.5',
47 cpqHeSysBatteryStatusValue => {
48 '1' => 'noError',
49 '2' => 'generalFailure',
50 '3' => 'shutdownHighResistance',
51 '4' => 'shutdownLowVoltage',
52 '5' => 'shutdownShortCircuit',
53 '6' => 'shutdownChargeTimeout',
54 '7' => 'shutdownOverTemperature',
55 '8' => 'shutdownDischargeMinVoltage',
56 '9' => 'shutdownDischargeCurrent',
57 '10' => 'shutdownLoadCountHigh',
58 '11' => 'shutdownEnablePin',
59 '12' => 'shutdownOverCurrent',
60 '13' => 'shutdownPermanentFailure',
61 '14' => 'shutdownBackupTimeExceeded',
62 },
63 cpqHeSysBatteryCapacityMaximum => '1.3.6.1.4.1.232.6.2.17.2.1.6',
64 cpqHeSysBatteryProductName => '1.3.6.1.4.1.232.6.2.17.2.1.7',
65 cpqHeSysBatteryModel => '1.3.6.1.4.1.232.6.2.17.2.1.8',
66 cpqHeSysBatterySerialNumber => '1.3.6.1.4.1.232.6.2.17.2.1.9',
67 cpqHeSysBatteryFirmwareRev => '1.3.6.1.4.1.232.6.2.17.2.1.10',
68 cpqHeSysBatterySparePartNum => '1.3.6.1.4.1.232.6.2.17.2.1.11',
69 };
70 # INDEX { cpqHeSysBatteryChassis, cpqHeSysBatteryIndex }
71 foreach ($self->get_entries($oids, 'cpqHeSysBatteryEntry')) {
72 next if ! $_->{cpqHeSysBatteryPresent} eq "present";
73 push(@{$self->{sysbatteries}},
74 HP::Proliant::Component::BatterySubsystem::Battery->new(%{$_}));
75 }
76 }
77
78 1;