~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/TemperatureSubsystem/SNMP.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::TemperatureSubsystem::SNMP;
2
 
our @ISA = qw(HP::Proliant::Component::TemperatureSubsystem
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
 
    temperatures => [],
15
 
    blacklisted => 0,
16
 
    info => undef,
17
 
    extendedinfo => undef,
18
 
  };
19
 
  bless $self, $class;
20
 
  $self->overall_init(%params);
21
 
  $self->init(%params);
22
 
  return $self;
23
 
}
24
 
 
25
 
sub overall_init {
26
 
  my $self = shift;
27
 
  my %params = @_;
28
 
  my $snmpwalk = $params{rawdata};
29
 
  # overall
30
 
  my $cpqHeThermalTempStatus  = '1.3.6.1.4.1.232.6.2.6.3.0';
31
 
  my $cpqHeThermalTempStatusValue = {
32
 
    1 => 'other',
33
 
    2 => 'ok',
34
 
    3 => 'degraded',
35
 
    4 => 'failed',
36
 
  };
37
 
  $self->{tempstatus} = lc SNMP::Utils::get_object_value(
38
 
      $snmpwalk, $cpqHeThermalTempStatus,
39
 
      $cpqHeThermalTempStatusValue);
40
 
}
41
 
 
42
 
sub init {
43
 
  my $self = shift;
44
 
  my %params = @_;
45
 
  my $snmpwalk = $self->{rawdata};
46
 
  my $oids = {
47
 
      cpqHeTemperatureEntry => "1.3.6.1.4.1.232.6.2.6.8.1",
48
 
      cpqHeTemperatureChassis => "1.3.6.1.4.1.232.6.2.6.8.1.1",
49
 
      cpqHeTemperatureIndex => "1.3.6.1.4.1.232.6.2.6.8.1.2",
50
 
      cpqHeTemperatureLocale => "1.3.6.1.4.1.232.6.2.6.8.1.3",
51
 
      cpqHeTemperatureCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.4",
52
 
      cpqHeTemperatureThresholdCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.5",
53
 
      cpqHeTemperatureCondition => "1.3.6.1.4.1.232.6.2.6.8.1.6",
54
 
      cpqHeTemperatureLocaleValue => {
55
 
          1 => "other",
56
 
          2 => "unknown",
57
 
          3 => "system",
58
 
          4 => "systemBoard",
59
 
          5 => "ioBoard",
60
 
          6 => "cpu",
61
 
          7 => "memory",
62
 
          8 => "storage",
63
 
          9 => "removableMedia",
64
 
          10 => "powerSupply",
65
 
          11 => "ambient",
66
 
          12 => "chassis",
67
 
          13 => "bridgeCard",
68
 
      },
69
 
      cpqHeTemperatureConditionValue => {
70
 
          1 => 'other',
71
 
          2 => 'ok',
72
 
          3 => 'degraded',
73
 
          4 => 'failed',
74
 
      }
75
 
  };
76
 
  # INDEX { cpqHeTemperatureChassis, cpqHeTemperatureIndex }
77
 
  foreach ($self->get_entries($oids, 'cpqHeTemperatureEntry')) {
78
 
    push(@{$self->{temperatures}},
79
 
        HP::Proliant::Component::TemperatureSubsystem::Temperature->new(%{$_}));
80
 
  }
81
 
}
82
 
 
83
 
sub overall_check {
84
 
  my $self = shift;
85
 
  my $result = 0;
86
 
  $self->blacklist('ots', '');
87
 
  if ($self->{tempstatus}) {
88
 
    if ($self->{tempstatus} eq "ok") {
89
 
      $result = 0;
90
 
      $self->add_info('all temp sensors are within normal operating range');
91
 
    } elsif ($self->{tempstatus} eq "degraded") {
92
 
      $result = 1;
93
 
      $self->add_info('a temp sensor is outside of normal operating range');
94
 
    } elsif ($self->{tempstatus} eq "failed") {
95
 
      $result = 2;
96
 
      $self->add_info('a temp sensor detects a condition that could permanently
97
 
damage the system');
98
 
    } elsif ($self->{tempstatus} eq "other") {
99
 
      $result = 0;
100
 
      $self->add_info('temp sensing is not supported by this system or driver');
101
 
    }
102
 
  } else {
103
 
    $result = 0;
104
 
    $self->add_info('no global temp status found');
105
 
  }
106
 
}
107
 
 
108
 
1;