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

« back to all changes in this revision

Viewing changes to check_hpasm/check_hpasm-4.5.2/plugins-scripts/HP/Proliant/Component/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::SNMP;
2
 
 
3
 
sub get_entries {
4
 
  my $self = shift;
5
 
  my $oids = shift;
6
 
  my $entry = shift;
7
 
  my $snmpwalk = $self->{rawdata};
8
 
  my @params = ();
9
 
  my @indices = SNMP::Utils::get_indices($snmpwalk, $oids->{$entry});
10
 
  foreach (@indices) {
11
 
    my @idx = @{$_};
12
 
    my %params = ( 
13
 
      runtime => $self->{runtime},
14
 
    );
15
 
    my $maxdimension = scalar(@idx) - 1;
16
 
    foreach my $idxnr (1..scalar(@idx)) {
17
 
      $params{'index'.$idxnr} = $_->[$idxnr - 1];
18
 
    }
19
 
    foreach my $oid (keys %{$oids}) {
20
 
      next if $oid =~ /Entry$/;
21
 
      next if $oid =~ /Value$/;
22
 
      if (exists $oids->{$oid.'Value'}) {
23
 
        $params{$oid} = SNMP::Utils::get_object_value(
24
 
            $snmpwalk, $oids->{$oid}, $oids->{$oid.'Value'}, @idx);
25
 
        if (! defined  $params{$oid}) {
26
 
          my $numerical_value = SNMP::Utils::get_object(
27
 
              $snmpwalk, $oids->{$oid}, @idx);
28
 
          if (! defined $numerical_value) {
29
 
            # maschine liefert schrott
30
 
            $params{$oid} = 'value_unknown';
31
 
          } else {
32
 
            $params{$oid} = 'value_'.SNMP::Utils::get_object(
33
 
                $snmpwalk, $oids->{$oid}, @idx);
34
 
          }
35
 
        }
36
 
      } else {  
37
 
        $params{$oid} = SNMP::Utils::get_object(
38
 
            $snmpwalk, $oids->{$oid}, @idx);
39
 
      }         
40
 
    }     
41
 
    push(@params, \%params);
42
 
  }
43
 
  return @params;
44
 
}
45
 
 
46
 
sub mib {
47
 
  my $self = shift;
48
 
  my $mib = shift;
49
 
  my $condition = {
50
 
      0 => 'other',
51
 
      1 => 'ok',
52
 
      2 => 'degraded',
53
 
      3 => 'failed',
54
 
  };
55
 
  my $MibRevMajor = $mib.'.1.0';
56
 
  my $MibRevMinor = $mib.'.2.0';
57
 
  my $MibRevCondition = $mib.'.3.0';
58
 
  return (
59
 
      $self->SNMP::Utils::get_object($self->{rawdata},
60
 
          $MibRevMajor),
61
 
      $self->SNMP::Utils::get_object($self->{rawdata},
62
 
          $MibRevMinor),
63
 
      $self->SNMP::Utils::get_object_value($self->{rawdata},
64
 
          $MibRevCondition, $condition));
65
 
};
66
 
 
67
 
1;