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

« back to all changes in this revision

Viewing changes to check_hpasm/check_hpasm-4.5.2/plugins-scripts/HP/BladeSystem/Component/CommonEnclosureSubsystem/TempSubsystem.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::CommonEnclosureSubsystem::TempSubsystem;
2
 
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem);
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
 
    condition => $params{condition},
15
 
    status => $params{status},
16
 
    temperatures => [],
17
 
    blacklisted => 0,
18
 
    info => undef,
19
 
    extendedinfo => undef,
20
 
  };
21
 
  bless $self, $class;
22
 
  if ($params{runtime}->{options}->{customthresholds}) {
23
 
    if (-f $params{runtime}->{options}->{customthresholds}) {
24
 
      open CT, $params{runtime}->{options}->{customthresholds};
25
 
      $params{runtime}->{options}->{customthresholds} = <CT>;
26
 
      close CT;
27
 
    }
28
 
    foreach my $ct_items
29
 
        (split(/\//, $params{runtime}->{options}->{customthresholds})) {
30
 
      if ($ct_items =~ /^(\d+):(\d+)$/) {
31
 
        my $temp = $2;
32
 
        $params{runtime}->{options}->{thresholds}->{$1} = $temp;
33
 
      } else {
34
 
        die sprintf "invalid threshold %s", $ct_items;
35
 
      }
36
 
    }
37
 
  }
38
 
  $self->init();
39
 
  return $self;
40
 
}
41
 
 
42
 
sub init {
43
 
  my $self = shift;
44
 
  my %params = @_;
45
 
  my $snmpwalk = $self->{rawdata};
46
 
  my $oids = {
47
 
      cpqRackCommonEnclosureTempEntry => '1.3.6.1.4.1.232.22.2.3.1.2.1',
48
 
      cpqRackCommonEnclosureTempRack => '1.3.6.1.4.1.232.22.2.3.1.2.1.1',
49
 
      cpqRackCommonEnclosureTempChassis => '1.3.6.1.4.1.232.22.2.3.1.2.1.2',
50
 
      cpqRackCommonEnclosureTempSensorIndex => '1.3.6.1.4.1.232.22.2.3.1.2.1.3',
51
 
      cpqRackCommonEnclosureTempSensorEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.2.1.4',
52
 
      cpqRackCommonEnclosureTempLocation => '1.3.6.1.4.1.232.22.2.3.1.2.1.5',
53
 
      cpqRackCommonEnclosureTempCurrent => '1.3.6.1.4.1.232.22.2.3.2.1.6',
54
 
      cpqRackCommonEnclosureTempThreshold => '1.3.6.1.4.1.232.22.2.3.1.2.1.7',
55
 
      cpqRackCommonEnclosureTempCondition => '1.3.6.1.4.1.232.22.2.3.1.2.1.8',
56
 
      cpqRackCommonEnclosureTempType => '1.3.6.1.4.1.232.22.2.3.1.2.1.9',
57
 
      cpqRackCommonEnclosureTempConditionValue => {
58
 
          1 => 'other',
59
 
          2 => 'ok',
60
 
          3 => 'degraded',
61
 
          4 => 'failed',
62
 
      },
63
 
      cpqRackCommonEnclosureTempTypeValue => {
64
 
          1 => 'other',
65
 
          5 => 'blowout',
66
 
          9 => 'caution',
67
 
          15 => 'critical',
68
 
      },
69
 
  };
70
 
  # INDEX { cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis
71
 
  #         cpqRackCommonEnclosureTempSensorIndex }
72
 
  foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureTempEntry')) {
73
 
    push(@{$self->{temperatures}},
74
 
       HP::BladeSystem::Component::CommonEnclosureSubsystem::TemperatureSubsystem::Temperature->new(%{$_}));
75
 
  }
76
 
 
77
 
}
78
 
 
79
 
 
80
 
sub check {
81
 
  my $self = shift;
82
 
  my $errorfound = 0;
83
 
  if (scalar (@{$self->{temperatures}}) == 0) {
84
 
    #$self->overall_check();
85
 
  } else {
86
 
    foreach (@{$self->{temperatures}}) {
87
 
      $_->check();
88
 
    }
89
 
  }
90
 
}
91
 
 
92
 
sub dump {
93
 
  my $self = shift;
94
 
  foreach (@{$self->{temperatures}}) {
95
 
    $_->dump();
96
 
  }
97
 
}
98
 
 
99
 
 
100
 
package HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem::Temp;
101
 
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem);
102
 
 
103
 
use strict;
104
 
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
105
 
 
106
 
sub new {
107
 
  my $class = shift;
108
 
  my %params = @_;
109
 
  my $self = {
110
 
    blacklisted => 0,
111
 
    info => undef,
112
 
    extendedinfo => undef,
113
 
  };
114
 
  map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureTemp/, keys %params;
115
 
  $self->{name} = $params{cpqRackCommonEnclosureTempRack}.':'.
116
 
      $params{cpqRackCommonEnclosureTempChassis}.':'.
117
 
      $params{cpqRackCommonEnclosureTempSensorIndex};
118
 
  bless $self, $class;
119
 
  return $self;
120
 
}
121
 
 
122
 
sub check {
123
 
  my $self = shift;
124
 
  $self->blacklist('t', $self->{name});
125
 
  if ($self->{cpqRackCommonEnclosureTempCurrent} > $self->{cpqRackCommonEnclosureTempThreshold}) {
126
 
    $self->add_info(sprintf "%s temperature too high (%d%s)",
127
 
        $self->{cpqRackCommonEnclosureTempLocation}, $self->{cpqRackCommonEnclosureTempCurrent},
128
 
        $self->{runtime}->{options}->{celsius} ? "C" : "F");
129
 
    $self->add_message(CRITICAL, $self->{info});
130
 
  } else {
131
 
    $self->add_info(sprintf "%d %s temperature is %d (%d max)",
132
 
        $self->{name}, $self->{    cpqRackCommonEnclosureTempLocation},
133
 
        $self->{cpqRackCommonEnclosureTempCurrent}, $self->{cpqRackCommonEnclosureTempThreshold});
134
 
  }
135
 
  if ($self->{runtime}->{options}->{perfdata} == 2) {
136
 
    $self->{runtime}->{plugin}->add_perfdata(
137
 
        label => sprintf('temp_%s', $self->{name}),
138
 
        value => $self->{cpqRackCommonEnclosureTempCurrent},
139
 
        warning => $self->{cpqRackCommonEnclosureTempThreshold},
140
 
        critical => $self->{cpqRackCommonEnclosureTempThreshold}
141
 
    );
142
 
  } elsif ($self->{runtime}->{options}->{perfdata} == 1) {
143
 
    $self->{runtime}->{plugin}->add_perfdata(
144
 
        label => sprintf('temp_%s_%s', $self->{name}, $self->{location}),
145
 
        value => $self->{degrees},
146
 
        warning => $self->{threshold},
147
 
        critical => $self->{threshold}
148
 
    );
149
 
  }
150
 
  $self->add_extendedinfo(sprintf "temp_%s=%d", 
151
 
      $self->{name}, $self->{cpqRackCommonEnclosureTempCurrent});
152
 
 
153
 
}
154
 
 
155
 
 
156
 
sub dump {
157
 
  my $self = shift;
158
 
  printf "[TEMP_%s]\n", $self->{name};
159
 
  foreach (qw(cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis
160
 
      cpqRackCommonEnclosureTempSensorIndex cpqRackCommonEnclosureTempSensorEnclosureName
161
 
      cpqRackCommonEnclosureTempLocation
162
 
      cpqRackCommonEnclosureTempCurrent cpqRackCommonEnclosureTempThreshold 
163
 
      cpqRackCommonEnclosureTempCondition cpqRackCommonEnclosureTempType)) {
164
 
    printf "%s: %s\n", $_, $self->{$_};
165
 
  }
166
 
  printf "info: %s\n\n", $self->{info};
167
 
}
168
 
 
169
 
1;
170