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

« back to all changes in this revision

Viewing changes to check_hpasm/check_hpasm-4.6.3/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
  $self->{tempstatus} |= lc $self->{tempstatus};
 
41
}
 
42
 
 
43
sub init {
 
44
  my $self = shift;
 
45
  my %params = @_;
 
46
  my $snmpwalk = $self->{rawdata};
 
47
  my $oids = {
 
48
      cpqHeTemperatureEntry => "1.3.6.1.4.1.232.6.2.6.8.1",
 
49
      cpqHeTemperatureChassis => "1.3.6.1.4.1.232.6.2.6.8.1.1",
 
50
      cpqHeTemperatureIndex => "1.3.6.1.4.1.232.6.2.6.8.1.2",
 
51
      cpqHeTemperatureLocale => "1.3.6.1.4.1.232.6.2.6.8.1.3",
 
52
      cpqHeTemperatureCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.4",
 
53
      cpqHeTemperatureThresholdCelsius => "1.3.6.1.4.1.232.6.2.6.8.1.5",
 
54
      cpqHeTemperatureCondition => "1.3.6.1.4.1.232.6.2.6.8.1.6",
 
55
      cpqHeTemperatureThresholdType => "1.3.6.1.4.1.232.6.2.6.8.1.7",
 
56
      cpqHeTemperatureLocaleValue => {
 
57
          1 => "other",
 
58
          2 => "unknown",
 
59
          3 => "system",
 
60
          4 => "systemBoard",
 
61
          5 => "ioBoard",
 
62
          6 => "cpu",
 
63
          7 => "memory",
 
64
          8 => "storage",
 
65
          9 => "removableMedia",
 
66
          10 => "powerSupply",
 
67
          11 => "ambient",
 
68
          12 => "chassis",
 
69
          13 => "bridgeCard",
 
70
      },
 
71
      cpqHeTemperatureConditionValue => {
 
72
          1 => 'other',
 
73
          2 => 'ok',
 
74
          3 => 'degraded',
 
75
          4 => 'failed',
 
76
      },
 
77
      cpqHeTemperatureThresholdTypeValue => {
 
78
          1 => 'other',
 
79
          5 => 'blowout',
 
80
          9 => 'caution',
 
81
          15 => 'critical',
 
82
      },
 
83
  };
 
84
  # INDEX { cpqHeTemperatureChassis, cpqHeTemperatureIndex }
 
85
  foreach ($self->get_entries($oids, 'cpqHeTemperatureEntry')) {
 
86
    # sieht aus, als wurden die gar nicht existieren.
 
87
    # im ilo4 werden sie als n/a angezeigt
 
88
    next if $_->{cpqHeTemperatureThresholdType} eq "caution" && $_->{cpqHeTemperatureThresholdCelsius} == 0;
 
89
    push(@{$self->{temperatures}},
 
90
        HP::Proliant::Component::TemperatureSubsystem::Temperature->new(%{$_}));
 
91
  }
 
92
}
 
93
 
 
94
sub overall_check {
 
95
  my $self = shift;
 
96
  my $result = 0;
 
97
  $self->blacklist('ots', '');
 
98
  if ($self->{tempstatus}) {
 
99
    if ($self->{tempstatus} eq "ok") {
 
100
      $result = 0;
 
101
      $self->add_info('all temp sensors are within normal operating range');
 
102
    } elsif ($self->{tempstatus} eq "degraded") {
 
103
      $result = 1;
 
104
      $self->add_info('a temp sensor is outside of normal operating range');
 
105
    } elsif ($self->{tempstatus} eq "failed") {
 
106
      $result = 2;
 
107
      $self->add_info('a temp sensor detects a condition that could permanently
 
108
damage the system');
 
109
    } elsif ($self->{tempstatus} eq "other") {
 
110
      $result = 0;
 
111
      $self->add_info('temp sensing is not supported by this system or driver');
 
112
    }
 
113
  } else {
 
114
    $result = 0;
 
115
    $self->add_info('no global temp status found');
 
116
  }
 
117
}
 
118
 
 
119
1;