~ubuntu-branches/ubuntu/trusty/nagios-plugins-contrib/trusty-proposed

« back to all changes in this revision

Viewing changes to check_hpasm/check_hpasm-4.5.2/plugins-scripts/HP/BladeSystem/Component/PowerEnclosureSubsystem.pm

  • Committer: Package Import Robot
  • Author(s): Bernd Zeimetz
  • Date: 2013-05-21 22:11:50 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130521221150-k5bda5v5euvt7wg9
Tags: 6.20130521
* [e68c82e1] check_raid: do not run hpacucli if cciss_vol_status is available.
* [4a1c57e8] Also support tw-cli as additional name for the 3ware binary.
  Thanks to Dennis Hoppe
* [eb5e1c7c] Add /run/ to the check_libs ignore file.

Show diffs side-by-side

added added

removed removed

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