~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/BladeSystem/Component/CommonEnclosureSubsystem/TempSubsystem.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::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem;
2
 
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem);
3
 
 
4
 
use strict;
5
 
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
6
 
 
7
 
sub new {
8
 
  my $class = shift;
9
 
  my %params = @_;
10
 
  my $self = {
11
 
    runtime => $params{runtime},
12
 
    rawdata => $params{rawdata},
13
 
    method => $params{method},
14
 
    condition => $params{condition},
15
 
    status => $params{status},
16
 
    temperatures => [],
17
 
    blacklisted => 0,
18
 
    info => undef,
19
 
    extendedinfo => undef,
20
 
  };
21
 
  bless $self, $class;
22
 
  if ($params{runtime}->{options}->{customthresholds}) {
23
 
    if (-f $params{runtime}->{options}->{customthresholds}) {
24
 
      open CT, $params{runtime}->{options}->{customthresholds};
25
 
      $params{runtime}->{options}->{customthresholds} = <CT>;
26
 
      close CT;
27
 
    }
28
 
    foreach my $ct_items
29
 
        (split(/\//, $params{runtime}->{options}->{customthresholds})) {
30
 
      if ($ct_items =~ /^(\d+):(\d+)$/) {
31
 
        my $temp = $2;
32
 
        $params{runtime}->{options}->{thresholds}->{$1} = $temp;
33
 
      } else {
34
 
        die sprintf "invalid threshold %s", $ct_items;
35
 
      }
36
 
    }
37
 
  }
38
 
  $self->init();
39
 
  return $self;
40
 
}
41
 
 
42
 
sub init {
43
 
  my $self = shift;
44
 
  my %params = @_;
45
 
  my $snmpwalk = $self->{rawdata};
46
 
  my $oids = {
47
 
      cpqRackCommonEnclosureTempEntry => '1.3.6.1.4.1.232.22.2.3.1.2.1',
48
 
      cpqRackCommonEnclosureTempRack => '1.3.6.1.4.1.232.22.2.3.1.2.1.1',
49
 
      cpqRackCommonEnclosureTempChassis => '1.3.6.1.4.1.232.22.2.3.1.2.1.2',
50
 
      cpqRackCommonEnclosureTempSensorIndex => '1.3.6.1.4.1.232.22.2.3.1.2.1.3',
51
 
      cpqRackCommonEnclosureTempSensorEnclosureName => '1.3.6.1.4.1.232.22.2.3.1.2.1.4',
52
 
      cpqRackCommonEnclosureTempLocation => '1.3.6.1.4.1.232.22.2.3.1.2.1.5',
53
 
      cpqRackCommonEnclosureTempCurrent => '1.3.6.1.4.1.232.22.2.3.1.2.1.6',
54
 
      cpqRackCommonEnclosureTempThreshold => '1.3.6.1.4.1.232.22.2.3.1.2.1.7',
55
 
      cpqRackCommonEnclosureTempCondition => '1.3.6.1.4.1.232.22.2.3.1.2.1.8',
56
 
      cpqRackCommonEnclosureTempType => '1.3.6.1.4.1.232.22.2.3.1.2.1.9',
57
 
      cpqRackCommonEnclosureTempConditionValue => {
58
 
          1 => 'other',
59
 
          2 => 'ok',
60
 
          3 => 'degraded',
61
 
          4 => 'failed',
62
 
      },
63
 
      cpqRackCommonEnclosureTempTypeValue => {
64
 
          1 => 'other',
65
 
          5 => 'blowout',
66
 
          9 => 'caution',
67
 
          15 => 'critical',
68
 
      },
69
 
  };
70
 
  # INDEX { cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis
71
 
  #         cpqRackCommonEnclosureTempSensorIndex }
72
 
  foreach ($self->get_entries($oids, 'cpqRackCommonEnclosureTempEntry')) {
73
 
    push(@{$self->{temperatures}},
74
 
       HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem::Temp->new(%{$_}))  if (($_->{cpqRackCommonEnclosureTempCurrent} != -1 && $_->{cpqRackCommonEnclosureTempThreshold} != -1) && ($_->{cpqRackCommonEnclosureTempThreshold} != 0));
75
 
  }
76
 
 
77
 
}
78
 
 
79
 
 
80
 
sub check {
81
 
  my $self = shift;
82
 
  my $errorfound = 0;
83
 
  if (scalar (@{$self->{temperatures}}) == 0) {
84
 
    #$self->overall_check();
85
 
  } else {
86
 
    foreach (@{$self->{temperatures}}) {
87
 
      $_->check();
88
 
    }
89
 
  }
90
 
}
91
 
 
92
 
sub dump {
93
 
  my $self = shift;
94
 
  foreach (@{$self->{temperatures}}) {
95
 
    $_->dump();
96
 
  }
97
 
}
98
 
 
99
 
 
100
 
package HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem::Temp;
101
 
our @ISA = qw(HP::BladeSystem::Component::CommonEnclosureSubsystem::TempSubsystem);
102
 
 
103
 
use strict;
104
 
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };
105
 
 
106
 
sub new {
107
 
  my $class = shift;
108
 
  my %params = @_;
109
 
  my $self = {
110
 
    runtime => $params{runtime},
111
 
    rawdata => $params{rawdata},
112
 
    method => $params{method},
113
 
    blacklisted => 0,
114
 
    info => undef,
115
 
    extendedinfo => undef,
116
 
  };
117
 
  map { $self->{$_} = $params{$_} } grep /cpqRackCommonEnclosureTemp/, keys %params;
118
 
  $self->{name} = $params{cpqRackCommonEnclosureTempRack}.':'.
119
 
      $params{cpqRackCommonEnclosureTempChassis}.':'.
120
 
      $params{cpqRackCommonEnclosureTempSensorIndex};
121
 
  bless $self, $class;
122
 
  return $self;
123
 
}
124
 
 
125
 
sub check {
126
 
  my $self = shift;
127
 
  $self->blacklist('t', $self->{name});
128
 
  if ($self->{cpqRackCommonEnclosureTempCurrent} > $self->{cpqRackCommonEnclosureTempThreshold}) {
129
 
    $self->add_info(sprintf "%s temperature too high (%d%s)",
130
 
        $self->{cpqRackCommonEnclosureTempLocation},
131
 
        $self->{cpqRackCommonEnclosureTempCurrent},
132
 
        $self->{runtime}->{options}->{celsius} ? "C" : "F");
133
 
    $self->add_message(CRITICAL, $self->{info});
134
 
  } else {
135
 
    $self->add_info(sprintf "%s temperature is %d%s (%d max)",
136
 
        $self->{cpqRackCommonEnclosureTempLocation},
137
 
        $self->{cpqRackCommonEnclosureTempCurrent},
138
 
        $self->{runtime}->{options}->{celsius} ? "C" : "F",
139
 
        $self->{cpqRackCommonEnclosureTempThreshold});
140
 
  }
141
 
  if ($self->{runtime}->{options}->{perfdata} == 2) {
142
 
    $self->{runtime}->{plugin}->add_perfdata(
143
 
        label => sprintf('temp_%s', $self->{name}),
144
 
        value => $self->{cpqRackCommonEnclosureTempCurrent},
145
 
        warning => $self->{cpqRackCommonEnclosureTempThreshold},
146
 
        critical => $self->{cpqRackCommonEnclosureTempThreshold}
147
 
    );
148
 
  } elsif ($self->{runtime}->{options}->{perfdata} == 1) {
149
 
    $self->{runtime}->{plugin}->add_perfdata(
150
 
        label => sprintf('temp_%s_%s', $self->{name},
151
 
            $self->{cpqRackCommonEnclosureTempLocation}),
152
 
        value => $self->{cpqRackCommonEnclosureTempCurrent},
153
 
        warning => $self->{cpqRackCommonEnclosureTempThreshold},
154
 
        critical => $self->{cpqRackCommonEnclosureTempThreshold}
155
 
    );
156
 
  }
157
 
  $self->add_extendedinfo(sprintf "temp_%s=%d", 
158
 
      $self->{name}, $self->{cpqRackCommonEnclosureTempCurrent});
159
 
 
160
 
}
161
 
 
162
 
 
163
 
sub dump {
164
 
  my $self = shift;
165
 
  printf "[TEMP_%s]\n", $self->{name};
166
 
  foreach (qw(cpqRackCommonEnclosureTempRack cpqRackCommonEnclosureTempChassis
167
 
      cpqRackCommonEnclosureTempSensorIndex cpqRackCommonEnclosureTempSensorEnclosureName
168
 
      cpqRackCommonEnclosureTempLocation
169
 
      cpqRackCommonEnclosureTempCurrent cpqRackCommonEnclosureTempThreshold 
170
 
      cpqRackCommonEnclosureTempCondition cpqRackCommonEnclosureTempType)) {
171
 
    printf "%s: %s\n", $_, $self->{$_};
172
 
  }
173
 
  printf "info: %s\n\n", $self->{info};
174
 
}
175
 
 
176
 
1;
177