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

« back to all changes in this revision

Viewing changes to check_hpasm/check_hpasm-4.6.3/plugins-scripts/HP/Proliant/Component/FanSubsystem/SNMP.pm

  • Committer: Package Import Robot
  • Author(s): Bernd Zeimetz, Bernd Zeimetz, Jan Wagner, Evgeni Golov
  • Date: 2013-06-14 20:53:49 UTC
  • Revision ID: package-import@ubuntu.com-20130614205349-34xiy38pm1hzpjoi
Tags: 7.20130614
[ Bernd Zeimetz ]
* [036816ff] Merge pull request #15 from evgeni/master
  check_packages should find security updates on the official security mirror too
* [658a2e93] Add check_checksums nagios plugin.
* [9d5d2056] Updating check_raid.
* [e3ec1293] Updating check_ssl_cert to 1.14.6
* [779543ef] Updating check_hpasm to 4.6.3.2
* [0c838ee9] Updating check_multipath to 0.1.9
* [bec11251] Updating check_whois to 1.13
* [8e0a65d0] Refreshing patches.
* [c0b88cdb] Auto update of debian/copyright
* [59648a17] Fix src link for check_hpasm
* [8c242d0f] Support pre-Wheezy versions of coretutils in check_checksums.
* [7d3d2a06] Update release date in changelog (gah!).
* [768e463b] Merge pull request #16 from evgeni/master
  check_libs: ignore /var/lib/postgresql/ and /var/log/
* [2b9aace5] Bumping standards-Verison, no changes needed.

[ Jan Wagner ]
* [3bb873e4] disable epn for check_rbl

[ Evgeni Golov ]
* [2a7ab4b8] check_libs: ignore /var/spool/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package HP::Proliant::Component::FanSubsystem::SNMP;
2
 
our @ISA = qw(HP::Proliant::Component::FanSubsystem
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
 
    fans => [],
15
 
    he_fans => [],
16
 
    th_fans => [],
17
 
    blacklisted => 0,
18
 
    info => undef,
19
 
    extendedinfo => undef,
20
 
  };
21
 
  bless $self, $class;
22
 
  $self->overall_init(%params);
23
 
  $self->he_init(%params);
24
 
  $self->te_init(%params);
25
 
  $self->unite();
26
 
  return $self;
27
 
}
28
 
 
29
 
sub overall_init {
30
 
  my $self = shift;
31
 
  my %params = @_;
32
 
  my $snmpwalk = $params{rawdata};
33
 
  # overall
34
 
  my $cpqHeThermalSystemFanStatus = '1.3.6.1.4.1.232.6.2.6.4.0';
35
 
  my $cpqHeThermalSystemFanStatusValue = {
36
 
    1 => 'other',
37
 
    2 => 'ok',
38
 
    3 => 'degraded',
39
 
    4 => 'failed',
40
 
  };
41
 
  my $cpqHeThermalCpuFanStatus = '1.3.6.1.4.1.232.6.2.6.5.0';
42
 
  my $cpqHeThermalCpuFanStatusValue = {
43
 
    1 => 'other',
44
 
    2 => 'ok',
45
 
    4 => 'failed', # shutdown
46
 
  };
47
 
  $self->{sysstatus} = SNMP::Utils::get_object_value(
48
 
      $snmpwalk, $cpqHeThermalSystemFanStatus,
49
 
      $cpqHeThermalSystemFanStatusValue);
50
 
  $self->{cpustatus} = SNMP::Utils::get_object_value(
51
 
      $snmpwalk, $cpqHeThermalCpuFanStatus,
52
 
      $cpqHeThermalCpuFanStatusValue);
53
 
  $self->{sysstatus} |= lc $self->{sysstatus};
54
 
  $self->{cpustatus} |= lc $self->{cpustatus};
55
 
}
56
 
 
57
 
sub te_init {
58
 
  my $self = shift;
59
 
  my %params = @_;
60
 
  my $snmpwalk = $params{rawdata};
61
 
  my $ignore_redundancy = $params{ignore_redundancy};
62
 
  # cpqHeThermalFanTable
63
 
  my $oids = {
64
 
      cpqHeThermalFanEntry => '1.3.6.1.4.1.232.6.2.6.6.1',
65
 
      cpqHeThermalFanIndex => '1.3.6.1.4.1.232.6.2.6.6.1.1',
66
 
      cpqHeThermalFanRequired => '1.3.6.1.4.1.232.6.2.6.6.1.2',
67
 
      cpqHeThermalFanPresent => '1.3.6.1.4.1.232.6.2.6.6.1.3',
68
 
      cpqHeThermalFanCpuFan => '1.3.6.1.4.1.232.6.2.6.6.1.4',
69
 
      cpqHeThermalFanStatus => '1.3.6.1.4.1.232.6.2.6.6.1.5',
70
 
      cpqHeThermalFanHwLocation => '1.3.6.1.4.1.232.6.2.6.6.1.6',
71
 
      cpqHeThermalFanRequiredValue => {
72
 
        1 => 'other',
73
 
        2 => 'nonRequired',
74
 
        3 => 'required',
75
 
      },
76
 
      cpqHeThermalFanPresentValue => {
77
 
        1 => 'other',
78
 
        2 => 'absent',
79
 
        3 => 'present',
80
 
      },
81
 
      cpqHeThermalFanCpuFanValue => {
82
 
        1 => 'other',
83
 
        2 => 'systemFan',
84
 
        3 => 'cpuFan',
85
 
      },
86
 
      cpqHeThermalFanStatusValue => {
87
 
        1 => 'other',
88
 
        2 => 'ok',
89
 
        4 => 'failed',
90
 
      },
91
 
  };
92
 
  # INDEX { cpqHeThermalFanIndex }
93
 
  foreach ($self->get_entries($oids, 'cpqHeThermalFanEntry')) {
94
 
    next if ! $_->{cpqHeThermalFanPresent};
95
 
    push(@{$self->{th_fans}},
96
 
        HP::Proliant::Component::FanSubsystem::Fan->new(%{$_}));
97
 
  }
98
 
}
99
 
 
100
 
sub he_init {
101
 
  my $self = shift;
102
 
  my %params = @_;
103
 
  my $snmpwalk = $params{rawdata};
104
 
  my $ignore_redundancy = $params{ignore_redundancy};
105
 
  # cpqHeFltTolFanTable
106
 
  my $oids = {
107
 
      cpqHeFltTolFanEntry => '1.3.6.1.4.1.232.6.2.6.7.1',
108
 
      cpqHeFltTolFanChassis => '1.3.6.1.4.1.232.6.2.6.7.1.1',
109
 
      cpqHeFltTolFanIndex => '1.3.6.1.4.1.232.6.2.6.7.1.2',
110
 
      cpqHeFltTolFanLocale => '1.3.6.1.4.1.232.6.2.6.7.1.3',
111
 
      cpqHeFltTolFanPresent => '1.3.6.1.4.1.232.6.2.6.7.1.4',
112
 
      cpqHeFltTolFanType => '1.3.6.1.4.1.232.6.2.6.7.1.5',
113
 
      cpqHeFltTolFanSpeed => '1.3.6.1.4.1.232.6.2.6.7.1.6',
114
 
      cpqHeFltTolFanRedundant => '1.3.6.1.4.1.232.6.2.6.7.1.7',
115
 
      cpqHeFltTolFanRedundantPartner => '1.3.6.1.4.1.232.6.2.6.7.1.8',
116
 
      cpqHeFltTolFanCondition => '1.3.6.1.4.1.232.6.2.6.7.1.9',
117
 
      cpqHeFltTolFanHotPlug => '1.3.6.1.4.1.232.6.2.6.7.1.10',
118
 
      cpqHeFltTolFanHwLocation => '1.3.6.1.4.1.232.6.2.6.7.1.11',
119
 
      cpqHeFltTolFanCurrentSpeed => '1.3.6.1.4.1.232.6.2.6.7.1.12',
120
 
      cpqHeFltTolFanLocaleValue => {
121
 
          1 => "other",
122
 
          2 => "unknown",
123
 
          3 => "system",
124
 
          4 => "systemBoard",
125
 
          5 => "ioBoard",
126
 
          6 => "cpu",
127
 
          7 => "memory",
128
 
          8 => "storage",
129
 
          9 => "removableMedia",
130
 
          10 => "powerSupply", 
131
 
          11 => "ambient",
132
 
          12 => "chassis",
133
 
          13 => "bridgeCard",
134
 
      },
135
 
      cpqHeFltTolFanPresentValue => {
136
 
          1 => "other",
137
 
          2 => "absent",
138
 
          3 => "present",
139
 
      },
140
 
      cpqHeFltTolFanSpeedValue => {
141
 
          1 => "other",
142
 
          2 => "normal",
143
 
          3 => "high",
144
 
      },
145
 
      cpqHeFltTolFanRedundantValue => {
146
 
          1 => "other",
147
 
          2 => "notRedundant",
148
 
          3 => "redundant",
149
 
      },
150
 
      cpqHeFltTolFanTypeValue => {
151
 
          1 => "other",
152
 
          2 => "tachInput",
153
 
          3 => "spinDetect",
154
 
      },
155
 
      cpqHeFltTolFanConditionValue => {
156
 
          1 => "other",
157
 
          2 => "ok",
158
 
          3 => "degraded",
159
 
          4 => "failed",
160
 
      },
161
 
      cpqHeFltTolFanHotPlugValue => {
162
 
          1 => "other",
163
 
          2 => "nonHotPluggable",
164
 
          3 => "hotPluggable",
165
 
      },
166
 
  };
167
 
  # INDEX { cpqHeFltTolFanChassis, cpqHeFltTolFanIndex }
168
 
  foreach ($self->get_entries($oids, 'cpqHeFltTolFanEntry')) {
169
 
    next if ! defined $_->{cpqHeFltTolFanIndex};
170
 
    # z.b. USM65201WS hat nur solche fragmente. die werden erst gar nicht
171
 
    # als fans akzeptiert. dafuer gibts dann die overall condition
172
 
    # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.1 = INTEGER: 0
173
 
    # SNMPv2-SMI::enterprises.232.6.2.6.7.1.1.0.2 = INTEGER: 0
174
 
    $_->{cpqHeFltTolFanPctMax} = ($_->{cpqHeFltTolFanPresent} eq 'present') ?
175
 
        50 : 0;
176
 
    push(@{$self->{he_fans}},
177
 
        HP::Proliant::Component::FanSubsystem::Fan->new(%{$_}));
178
 
  }
179
 
 
180
 
}
181
 
 
182
 
sub unite {
183
 
  my $self = shift;
184
 
  my $tmpfans = {};
185
 
  foreach (@{$self->{he_fans}}) {
186
 
    $tmpfans->{$_->{cpqHeFltTolFanIndex}} = $_;
187
 
  }
188
 
  foreach (@{$self->{he_fans}}) {
189
 
    if (exists $tmpfans->{$_->{cpqHeFltTolFanRedundantPartner}}) {
190
 
      $_->{partner} = $tmpfans->{$_->{cpqHeFltTolFanRedundantPartner}};
191
 
    } else {
192
 
      $_->{partner} = undef;
193
 
    }
194
 
  }
195
 
  @{$self->{fans}} = @{$self->{he_fans}};
196
 
}
197
 
 
198
 
sub overall_check {
199
 
  my $self = shift;
200
 
  my $result = 0;
201
 
  $self->blacklist('ofs', '');
202
 
  if ($self->{sysstatus} && $self->{cpustatus}) {
203
 
    if ($self->{sysstatus} eq 'degraded') {
204
 
      $result = 1;
205
 
      $self->add_message(WARNING,
206
 
          sprintf 'system fan overall status is %s', $self->{sysstatus});
207
 
    } elsif ($self->{sysstatus} eq 'failed') {
208
 
      $result = 2;
209
 
      $self->add_message(CRITICAL,
210
 
          sprintf 'system fan overall status is %s', $self->{sysstatus});
211
 
    } 
212
 
    if ($self->{cpustatus} eq 'degraded') {
213
 
      $result = 1;
214
 
      $self->add_message(WARNING,
215
 
          sprintf 'cpu fan overall status is %s', $self->{cpustatus});
216
 
    } elsif ($self->{cpustatus} eq 'failed') {
217
 
      $result = 2;
218
 
      $self->add_message(CRITICAL,
219
 
          sprintf 'cpu fan overall status is %s', $self->{cpustatus});
220
 
    } 
221
 
    $self->add_info(sprintf 'overall fan status: system=%s, cpu=%s',
222
 
        $self->{sysstatus}, $self->{cpustatus});
223
 
  } else {
224
 
    $result = 0;
225
 
    $self->add_info('this system seems to be water-cooled. no fans found');
226
 
  }
227
 
  return $result;
228
 
}
229
 
 
230
 
1;
231