~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/EventSubsystem/CLI.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::EventSubsystem::CLI;
 
2
our @ISA = qw(HP::Proliant::Component::EventSubsystem);
 
3
 
 
4
use strict;
 
5
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
 
6
use Time::Local;
 
7
 
 
8
sub new {
 
9
  my $class = shift;
 
10
  my %params = @_;
 
11
  my $self = {
 
12
    runtime => $params{runtime},
 
13
    rawdata => $params{rawdata},
 
14
    events => [],
 
15
    blacklisted => 0,
 
16
    info => undef,
 
17
    extendedinfo => undef,
 
18
  };
 
19
  bless $self, $class;
 
20
  $self->init(%params);
 
21
  return $self;
 
22
}
 
23
 
 
24
 
 
25
sub init {
 
26
  my $self = shift;
 
27
  my %params = @_;
 
28
  my %tmpevent = (
 
29
    runtime => $params{runtime},
 
30
  );
 
31
  my $inblock = 0;
 
32
  foreach (grep(/^iml/, split(/\n/, $self->{rawdata}))) {
 
33
    s/^iml\s*//g;
 
34
    if (/^Event:\s+(\d+)\s+[\w]+:\s+(\d+)\/(\d+)\/(\d+)\s+(\d+):(\d+)/) {
 
35
      # Event: 31 Added: 09/22/2011 05:11
 
36
      #         1         2  3    4  5  6
 
37
      $tmpevent{cpqHeEventLogEntryNumber} = $1;
 
38
      if ($4 == 0) {
 
39
        # Event: 29 Added: 00/00/0000 00:00
 
40
        $tmpevent{cpqHeEventLogUpdateTime} = 0;
 
41
      } else {
 
42
        eval {
 
43
          $tmpevent{cpqHeEventLogUpdateTime} = timelocal(0, $6, $5, $3, $2 - 1, $4);
 
44
        };
 
45
        if ($@) {
 
46
          # Event: 10 Added: 27/27/2027 27:27
 
47
          $tmpevent{cpqHeEventLogUpdateTime} = 0;
 
48
        }
 
49
      }
 
50
      $inblock = 1;
 
51
    } elsif (/^(\w+):\s+(.*?)\s+\-\s+(.*)/) {
 
52
      $tmpevent{cpqHeEventLogEntrySeverity} = $1;
 
53
      $tmpevent{cpqHeEventLogEntryClass} = $2;
 
54
      $tmpevent{cpqHeEventLogErrorDesc} = $3;
 
55
      if ($tmpevent{cpqHeEventLogErrorDesc} =~ /.*?:\s+(\d+)/) {
 
56
          $tmpevent{cpqHeEventLogEntryCode} = $1;
 
57
      } else {
 
58
          $tmpevent{cpqHeEventLogEntryCode} = 0;
 
59
      }
 
60
    } elsif (/^\s*$/) {
 
61
      if ($inblock) {
 
62
        $inblock = 0;
 
63
        push(@{$self->{events}},
 
64
            HP::Proliant::Component::EventSubsystem::Event->new(%tmpevent));
 
65
        %tmpevent = (
 
66
          runtime => $params{runtime},
 
67
        );
 
68
      }
 
69
    }
 
70
  }
 
71
  if ($inblock) {
 
72
    push(@{$self->{events}},
 
73
        HP::Proliant::Component::EventSubsystem::Event->new(%tmpevent));
 
74
  }
 
75
}
 
76
 
 
77
1;
 
78