~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/AsrSubsystem/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::AsrSubsystem::SNMP;
 
2
our @ISA = qw(HP::Proliant::Component::AsrSubsystem
 
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
    blacklisted => 0,
 
15
    info => undef,
 
16
    extendedinfo => undef,
 
17
  };
 
18
  bless $self, $class;
 
19
  $self->overall_init(%params);
 
20
  return $self;
 
21
}
 
22
 
 
23
sub overall_init {
 
24
  my $self = shift;
 
25
  my %params = @_;
 
26
  my $snmpwalk = $params{rawdata};
 
27
  my $cpqHeAsrStatus = "1.3.6.1.4.1.232.6.2.5.1.0";
 
28
  my $cpqHeAsrStatusValue = {
 
29
    1 => "other",
 
30
    2 => "notAvailable",
 
31
    3 => "disabled",
 
32
    4 => "enabled",
 
33
  };
 
34
  my $cpqHeAsrCondition = "1.3.6.1.4.1.232.6.2.5.17.0";
 
35
  my $cpqHeAsrConditionValue = {
 
36
    1 => "other",
 
37
    2 => "ok",
 
38
    3 => "degraded",
 
39
    4 => "failed",
 
40
  };
 
41
  $self->{asrcondition} = SNMP::Utils::get_object_value(
 
42
      $snmpwalk, $cpqHeAsrCondition,
 
43
      $cpqHeAsrConditionValue);
 
44
  $self->{asrstatus} = SNMP::Utils::get_object_value(
 
45
      $snmpwalk, $cpqHeAsrStatus,
 
46
      $cpqHeAsrStatusValue);
 
47
  $self->{asrcondition} |= lc $self->{asrcondition};
 
48
  $self->{asrstatus} |= lc $self->{asrstatus};
 
49
}
 
50
 
 
51
sub overall_check {
 
52
  my $self = shift;
 
53
  my $result = 0;
 
54
  $self->blacklist('asr', '');
 
55
  if ($self->{asrstatus} and $self->{asrstatus} eq "enabled") {
 
56
    my $info = sprintf 'ASR overall condition is %s', $self->{asrcondition};
 
57
    if ($self->{asrcondition} eq "degraded") {
 
58
      $self->add_message(WARNING, $info);
 
59
    } elsif ($self->{asrcondition} eq "failed") {
 
60
      $self->add_message(CRITICAL, $info);
 
61
    }
 
62
    $self->add_info($info);
 
63
  } else {
 
64
    $self->add_info('This system does not have ASR.');
 
65
  }
 
66
}
 
67
 
 
68
1;