~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/Proliant/Component/PowersupplySubsystem/CLI.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::Proliant::Component::PowersupplySubsystem::CLI;
2
 
our @ISA = qw(HP::Proliant::Component::PowersupplySubsystem);
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
 
    powersupplies => [],
14
 
    powerconverters => [],
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 %tmpps = (
28
 
    runtime => $self->{runtime},
29
 
    cpqHeFltTolPowerSupplyChassis => 1,
30
 
  );
31
 
  my $inblock = 0;
32
 
  foreach (grep(/^powersupply/, split(/\n/, $self->{rawdata}))) {
33
 
    s/^powersupply\s*//g;
34
 
    if (/^Power supply #(\d+)/) {
35
 
      if ($inblock) {
36
 
        $inblock = 0;
37
 
        push(@{$self->{powersupplies}},
38
 
            HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps));
39
 
        %tmpps = (
40
 
          runtime => $self->{runtime},
41
 
          cpqHeFltTolPowerSupplyChassis => 1,
42
 
        );
43
 
      }
44
 
      $tmpps{cpqHeFltTolPowerSupplyBay} = $1;
45
 
      $inblock = 1;
46
 
    } elsif (/\s*Present\s+:\s+(\w+)/) {
47
 
      $tmpps{cpqHeFltTolPowerSupplyPresent} = lc $1 eq 'yes' ? 'present' :
48
 
          lc $1 eq 'no' ? 'absent': 'other';
49
 
    } elsif (/\s*Redundant\s*:\s+(\w+)/) {
50
 
      $tmpps{cpqHeFltTolPowerSupplyRedundant} = lc $1 eq 'yes' ? 'redundant' :
51
 
          lc $1 eq 'no' ? 'notRedundant' : 'other';
52
 
    } elsif (/\s*Condition\s*:\s+(\w+)/) {
53
 
      $tmpps{cpqHeFltTolPowerSupplyCondition} = lc $1;
54
 
    } elsif (/\s*Power Supply not present/) {
55
 
      $tmpps{cpqHeFltTolPowerSupplyPresent} = "absent";
56
 
      $tmpps{cpqHeFltTolPowerSupplyCondition} = "other";
57
 
      $tmpps{cpqHeFltTolPowerSupplyRedundant} = "notRedundant";
58
 
    } elsif (/^\s*$/) {
59
 
      if ($inblock) {
60
 
        $inblock = 0;
61
 
        push(@{$self->{powersupplies}},
62
 
            HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps));
63
 
        %tmpps = (
64
 
          runtime => $self->{runtime},
65
 
          cpqHeFltTolPowerSupplyChassis => 1,
66
 
        );
67
 
      }
68
 
    }
69
 
  }
70
 
  if ($inblock) {
71
 
    push(@{$self->{powersupplies}},
72
 
        HP::Proliant::Component::PowersupplySubsystem::Powersupply->new(%tmpps));
73
 
    %tmpps = (
74
 
      runtime => $params{runtime},
75
 
    );
76
 
  }
77
 
}
78
 
 
79
 
1;