~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.2/plugins-scripts/HP/Proliant/Component/EventSubsystem/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::EventSubsystem::SNMP;
 
2
our @ISA = qw(HP::Proliant::Component::EventSubsystem
 
3
    HP::Proliant::Component::SNMP);
 
4
 
 
5
use strict;
 
6
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
 
7
use Time::Local;
 
8
 
 
9
sub new {
 
10
  my $class = shift;
 
11
  my %params = @_;
 
12
  my $self = {
 
13
    runtime => $params{runtime},
 
14
    rawdata => $params{rawdata},
 
15
    events => [],
 
16
    blacklisted => 0,
 
17
    info => undef,
 
18
    extendedinfo => undef,
 
19
  };
 
20
  bless $self, $class;
 
21
  $self->overall_init(%params);
 
22
  $self->init(%params);
 
23
  return $self;
 
24
}
 
25
 
 
26
sub overall_init {
 
27
  my $self = shift;
 
28
  my %params = @_;
 
29
  my $snmpwalk = $params{rawdata};
 
30
  # overall
 
31
  my $cpqHeEventLogSupported  = '1.3.6.1.4.1.232.6.2.11.1.0';
 
32
  my $cpqHeEventLogSupportedValue = {
 
33
    1 => 'other',
 
34
    2 => 'notSupported',
 
35
    3 => 'supported',
 
36
    4 => 'clear',
 
37
  };
 
38
  my $cpqHeEventLogCondition  = '1.3.6.1.4.1.232.6.2.11.2.0';
 
39
  my $cpqHeEventLogConditionValue = {
 
40
    1 => 'other',
 
41
    2 => 'ok',
 
42
    3 => 'degraded',
 
43
    4 => 'failed',
 
44
  };
 
45
  $self->{eventsupp} = SNMP::Utils::get_object_value(
 
46
      $snmpwalk, $cpqHeEventLogSupported,
 
47
      $cpqHeEventLogSupportedValue);
 
48
  $self->{eventstatus} = SNMP::Utils::get_object_value(
 
49
      $snmpwalk, $cpqHeEventLogCondition,
 
50
      $cpqHeEventLogConditionValue);
 
51
  $self->{eventsupp} |= lc $self->{eventsupp};
 
52
  $self->{eventstatus} |= lc $self->{eventstatus};
 
53
}
 
54
 
 
55
sub init {
 
56
  my $self = shift;
 
57
  my %params = @_;
 
58
  my $snmpwalk = $self->{rawdata};
 
59
  my $oids = {
 
60
      cpqHeEventLogEntry => "1.3.6.1.4.1.232.6.2.11.3.1",
 
61
      cpqHeEventLogEntryNumber => "1.3.6.1.4.1.232.6.2.11.3.1.1",
 
62
      cpqHeEventLogEntrySeverity => "1.3.6.1.4.1.232.6.2.11.3.1.2",
 
63
      cpqHeEventLogEntryClass => "1.3.6.1.4.1.232.6.2.11.3.1.3",
 
64
      cpqHeEventLogEntryCode => "1.3.6.1.4.1.232.6.2.11.3.1.4",
 
65
      cpqHeEventLogEntryCount => "1.3.6.1.4.1.232.6.2.11.3.1.5",
 
66
      cpqHeEventLogInitialTime => "1.3.6.1.4.1.232.6.2.11.3.1.6",
 
67
      cpqHeEventLogUpdateTime => "1.3.6.1.4.1.232.6.2.11.3.1.7",
 
68
      cpqHeEventLogErrorDesc => "1.3.6.1.4.1.232.6.2.11.3.1.8",
 
69
 
 
70
      cpqHeEventLogEntryClassValue => {
 
71
          #  2 Fan Failure (Fan 1, Location I/O Board)
 
72
          #    Internal Storage System Overheating (Slot 0, Zone 1, Location Storage, Temperature Unknown)
 
73
          #    System Fans Not Redundant (Location I/O Board)
 
74
          #  MY MUSTARD: only critical events should lead to an alert, if at all. The caution events mean "loss of redundancy".
 
75
          #              We monitor temperatures and fan status anyway.
 
76
          #2 => "",
 
77
          #  3 Corrected Memory Error threshold exceeded (System Memory, Memory Module 1)
 
78
          #    Uncorrectable Memory Error detected by ROM-based memory validation (Board 1, Memory Module 4)
 
79
          #  MY MUSTARD: threshold exceeded is caution. Uncorrectable errors are critical. Both should be detected anyway.
 
80
          3 => "Main Memory",
 
81
          #  4 Accelerator Cache Memory Parity Error (Socket 1)
 
82
          #4 => "",
 
83
          #  5 Processor Correctable error threshold exceeded (Board 0, Processor 2)
 
84
          #5 => "",
 
85
          #  6 Unrecoverable Intermodule Bus error (Error code 0x00000000)
 
86
          #6 => "",
 
87
          #  8 PCI Bus Error (Slot 0, Bus 0, Device 0, Function 0)
 
88
          8 => "PCI Bus",
 
89
          # 10 1720-S.M.A.R.T. Hard Drive Detects Imminent Failure
 
90
          #    POST Error: 201-Memory Error Multi-bit error occurred during memory initialization, Board 1, Bank B. Bank containing DIMM(s) has been disabled..
 
91
          #    POST Error: 201-Memory Error Single-bit error occured during memory initialization, Board 1, DIMM 1. Bank containing DIMM(s) has been disabled..
 
92
          #    POST Error: 207-Memory Configuration Warning - memory boards should be installed sequentially.
 
93
          #    POST Error: 210-Memory Board Failure on board 4.
 
94
          #    POST Error: 210-Memory Board Power Fault on board 3.
 
95
          #    POST Error: 207-Memory initialization error on Memory Board 5 DIMM 7. The operating system may not have access to all of the memory installed in the system..         
 
96
          #    POST Error: 207-Invalid Memory Configuration-Mismatched DIMMs within DIMM Bank Memory in Bank A Not Utilized..
 
97
          10 => "POST Messages",
 
98
          11 => "Power Subsystem",
 
99
          13 => "ASR",
 
100
          # 14 Automatic Operating System Shutdown Initiated Due to Overheat Condition
 
101
          #    Automatic Operating System Shutdown Initiated Due to Fan Failure
 
102
          #    Blue Screen Trap (BugCheck, STOP: 0x00000050 (0x9CB2C5B4, 0x00000001, 0x00000004, 0x00000000))
 
103
          #    Operating System failure (BugCheck, STOP: 0x000000AB (0x00000005, 0x00000488, 0x00000000, 0x00000002))
 
104
          14 => "OS Class",
 
105
          # 15 Unknown Event (Class 15, Code 255)
 
106
          #15 => "",
 
107
          # 17 Network Adapter Link Down (Slot 0, Port 4)
 
108
          #    Network Adapters Redundancy Reduced (Slot 0, Port 1)
 
109
          17 => "Network Adapter",
 
110
          # 19 Drive Array Device Failure (Slot 0, Bus 2, Bay 4)
 
111
          #    Internal SAS Enclosure Device Failure (Bay 1, Box 1, Port 2I, Slot 1)
 
112
          #19 => "",
 
113
          # 20 An Unrecoverable System Error (NMI) has occurred
 
114
          #    Unrecoverable System Error has occurred (Error code 0x01AE0E2F, 0x00000000)
 
115
          20 => "Unrecoverable System Error",
 
116
          # 32 ROM flashed (New version: 01/09/2008)
 
117
          32 => "System Revision",
 
118
          # 33 IML Cleared (Administrator)
 
119
          #    IML cleared through HP ProLiant Health Agent (cmahealthd)
 
120
          #    Insight Diagnostics Note: Physisches Festplattenlaufwerk 5, Controller Steckplatz 0-Diagnosis: Fehlgeschlagen
 
121
          33 => "Maintenance Note",
 
122
          # 34 New Chassis Connected (Enclosure Address 27AC)
 
123
          #    Loss Of Chassis Connectivity (Enclosure Serial Number 8004******)
 
124
          #    Server Blade Enclosure Server Blade Inserted (Slot 16, Enclosure Address 0000)
 
125
          #34 => "",
 
126
      },
 
127
      cpqHeEventLogEntrySeverityValue => {
 
128
          2 => "informational",
 
129
          3 => "infoWithAlert",
 
130
          6 => "repaired",
 
131
          9 => "caution",
 
132
          15 => "critical",
 
133
      },
 
134
      # Time 
 
135
      # 07 D8 09 02 11 11
 
136
  };
 
137
  # INDEX { cpqHeEventLogEntryNumber }
 
138
  foreach ($self->get_entries($oids, 'cpqHeEventLogEntry')) {
 
139
    if ($_->{cpqHeEventLogInitialTime} =~ /^(([0-9a-fA-F]{2})( [0-9a-fA-F]{2})*)\s*$/) {
 
140
      $_->{cpqHeEventLogInitialTime} =~ s/ //;
 
141
      my  ($year, $month, $day, $hour, $min) = map { hex($_) } split(/\s+/, $_->{cpqHeEventLogInitialTime});
 
142
      if ($year == 0) {
 
143
        $_->{cpqHeEventLogInitialTime} = 0;
 
144
      } else {
 
145
        eval {
 
146
          $_->{cpqHeEventLogInitialTime} = timelocal(0, $min, $hour, $day, $month - 1, $year);
 
147
        };
 
148
        if ($@) {
 
149
          $_->{cpqHeEventLogInitialTime} = 0;
 
150
        }
 
151
      }
 
152
    } elsif ($_->{cpqHeEventLogInitialTime} =~ /^0x([0-9a-fA-F]{4})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/) {
 
153
      my  ($year, $month, $day, $hour, $min) = map { hex($_) } ($1, $2, $3, $4, $5);
 
154
      if ($year == 0) {
 
155
        $_->{cpqHeEventLogInitialTime} = 0;
 
156
      } else {
 
157
        eval {
 
158
          $_->{cpqHeEventLogInitialTime} = timelocal(0, $min, $hour, $day, $month - 1, $year);
 
159
        };
 
160
        if ($@) {
 
161
          $_->{cpqHeEventLogInitialTime} = 0;
 
162
        }
 
163
      }
 
164
    } elsif ($_->{cpqHeEventLogInitialTime} =~ /^\0\0\0\0\0\0/) {
 
165
      $_->{cpqHeEventLogInitialTime} = 0;
 
166
    }
 
167
    if ($_->{cpqHeEventLogUpdateTime} =~ /^(([0-9a-fA-F]{2})( [0-9a-fA-F]{2})*)\s*$/) {
 
168
      $_->{cpqHeEventLogUpdateTime} =~ s/ //;
 
169
      my  ($year, $month, $day, $hour, $min) = map { hex($_) } split(/\s+/, $_->{cpqHeEventLogUpdateTime});
 
170
      if ($year == 0) {
 
171
        $_->{cpqHeEventLogUpdateTime} = 0;
 
172
      } else {
 
173
        eval {
 
174
          $_->{cpqHeEventLogUpdateTime} = timelocal(0, $min, $hour, $day, $month - 1, $year);
 
175
        };
 
176
        if ($@) {
 
177
          $_->{cpqHeEventLogUpdateTime} = 0;
 
178
        }
 
179
      }
 
180
    } elsif ($_->{cpqHeEventLogUpdateTime} =~ /^0x([0-9a-fA-F]{4})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/) {
 
181
      my  ($year, $month, $day, $hour, $min) = map { hex($_) } ($1, $2, $3, $4, $5);
 
182
      if ($year == 0) {
 
183
        $_->{cpqHeEventLogUpdateTime} = 0;
 
184
      } else {
 
185
        eval {
 
186
          $_->{cpqHeEventLogUpdateTime} = timelocal(0, $min, $hour, $day, $month - 1, $year);
 
187
        };
 
188
        if ($@) {
 
189
          $_->{cpqHeEventLogUpdateTime} = 0;
 
190
        }
 
191
      }
 
192
    } elsif ($_->{cpqHeEventLogUpdateTime} =~ /^\0\0\0\0\0\0/) {
 
193
      $_->{cpqHeEventLogUpdateTime} = 0;
 
194
    }
 
195
    if ($_->{cpqHeEventLogErrorDesc} =~ /^(([0-9a-fA-F]{2})(\s+[0-9a-fA-F]{2})*)\s*$/) {
 
196
      $_->{cpqHeEventLogErrorDesc} = join "", map { chr($_) } map { if (hex($_) > 127) { 20; } else { hex($_) } } split(/\s+/, $_->{cpqHeEventLogErrorDesc});
 
197
    }
 
198
    push(@{$self->{events}},
 
199
        HP::Proliant::Component::EventSubsystem::Event->new(%{$_}));
 
200
  }
 
201
}
 
202
 
 
203
sub overall_check {
 
204
  my $self = shift;
 
205
  my $result = 0;
 
206
  $self->blacklist('oe', '');
 
207
  if ($self->{eventsupp} && $self->{eventsupp} eq "supported") {
 
208
    if ($self->{eventstatus} eq "ok") {
 
209
      $result = 0;
 
210
      $self->add_info('eventlog system is ok');
 
211
    } else {
 
212
      $result = 0;
 
213
      $self->add_info(sprintf "eventlog system is %s", $self->{eventstatus});
 
214
    }
 
215
  } else {
 
216
    $result = 0;
 
217
    $self->add_info('no event status found');
 
218
  }
 
219
}
 
220
 
 
221
1;