git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/nagios-plugins-contrib-24.20190301~bpo9+1/check_hpasm/check_hpasm-4.8/plugins-scripts/HP/Proliant/Component/NicSubsystem/SNMP.pm
blob: 85f1fd446a3ca833b52ad292ed71b224df770c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
package HP::Proliant::Component::NicSubsystem::SNMP;
our  _æ_ ISA = qw(HP::Proliant::Component::NicSubsystem
    HP::Proliant::Component::SNMP);

use strict;
use constant { OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 };

sub new {
  my $class = shift;
  my %params =  _æ_ _;
  my $self = {
    runtime => $params{runtime},
    rawdata => $params{rawdata},
    blacklisted => 0,
    info => undef,
    extendedinfo => undef,
    logical_nics => [],
    physical_nics => [],
  };
  bless $self, $class;
  $self->overall_init(%params);
  $self->init();
  return $self;
}

sub overall_init {
  my $self = shift;
  my %params =  _æ_ _;
  my $snmpwalk = $self->{rawdata};
  # overall
  my $cpqNicIfLogMapOverallCondition  = '1.3.6.1.4.1.232.18.2.2.2.0';
  my $cpqNicIfLogMapOverallConditionValue = {
    1 => 'other',
    2 => 'ok',
    3 => 'degraded',
    4 => 'failed',
  };
  $self->{lognicstatus} = SNMP::Utils::get_object_value(
      $snmpwalk, $cpqNicIfLogMapOverallCondition,
      $cpqNicIfLogMapOverallConditionValue);
}

sub init {
  my $self = shift;
  my $snmpwalk = $self->{rawdata};
  my $ifconnect = {};
  # CPQNIC-MIB
  my $oids = {
      cpqNicIfLogMapEntry => '1.3.6.1.4.1.232.18.2.2.1.1',
      cpqNicIfLogMapIndex => '1.3.6.1.4.1.232.18.2.2.1.1.1',
      cpqNicIfLogMapIfNumber => '1.3.6.1.4.1.232.18.2.2.1.1.2',
      cpqNicIfLogMapDescription => '1.3.6.1.4.1.232.18.2.2.1.1.3',
      cpqNicIfLogMapGroupType => '1.3.6.1.4.1.232.18.2.2.1.1.4',
      cpqNicIfLogMapAdapterCount => '1.3.6.1.4.1.232.18.2.2.1.1.5',
      cpqNicIfLogMapAdapterOKCount => '1.3.6.1.4.1.232.18.2.2.1.1.6',
      cpqNicIfLogMapPhysicalAdapters => '1.3.6.1.4.1.232.18.2.2.1.1.7',
      cpqNicIfLogMapMACAddress => '1.3.6.1.4.1.232.18.2.2.1.1.8',
      cpqNicIfLogMapSwitchoverMode => '1.3.6.1.4.1.232.18.2.2.1.1.9',
      cpqNicIfLogMapCondition => '1.3.6.1.4.1.232.18.2.2.1.1.10',
      cpqNicIfLogMapStatus => '1.3.6.1.4.1.232.18.2.2.1.1.11',
      cpqNicIfLogMapNumSwitchovers => '1.3.6.1.4.1.232.18.2.2.1.1.12',
      cpqNicIfLogMapHwLocation => '1.3.6.1.4.1.232.18.2.2.1.1.13',
      cpqNicIfLogMapSpeed => '1.3.6.1.4.1.232.18.2.2.1.1.14',
      cpqNicIfLogMapVlanCount => '1.3.6.1.4.1.232.18.2.2.1.1.15',
      cpqNicIfLogMapVlans => '1.3.6.1.4.1.232.18.2.2.1.1.16',

      cpqNicIfLogMapGroupTypeValue => {
          1 => "unknown",
          2 => "none",
          3 => "redundantPair",
          4 => "nft",
          5 => "alb",
          6 => "fec",
          7 => "gec",
          8 => "ad",
          9 => "slb",
          10 => "tlb",
          11 => "redundancySet",
      },
      cpqNicIfLogMapConditionValue => {
          1 => "other",
          2 => "ok",
          3 => "degraded",
          4 => "failed",
      },
      cpqNicIfLogMapStatusValue => {
          1 => "unknown",
          2 => "ok",
          3 => "primaryFailed",
          4 => "standbyFailed",
          5 => "groupFailed",
          6 => "redundancyReduced",
          7 => "redundancyLost",
      },
      cpqNicIfLogMapSwitchoverModeValue => {
          1 => "unknown",
          2 => "none",
          3 => "manual",
          4 => "switchOnFail",
          5 => "preferredPrimary",
      },
  };

  # INDEX { cpqNicIfLogMapIndex }
  foreach ($self->get_entries($oids, 'cpqNicIfLogMapEntry')) {
    push( _æ_ {$self->{logical_nics}}, 
        HP::Proliant::Component::NicSubsystem::LogicalNic->new(%{$_})
    );
  }

  $oids = {
      cpqNicIfPhysAdapterEntry => '1.3.6.1.4.1.232.18.2.3.1.1',
      cpqNicIfPhysAdapterIndex => '1.3.6.1.4.1.232.18.2.3.1.1.1',
      cpqNicIfPhysAdapterIfNumber => '1.3.6.1.4.1.232.18.2.3.1.1.2',
      cpqNicIfPhysAdapterRole => '1.3.6.1.4.1.232.18.2.3.1.1.3',
      cpqNicIfPhysAdapterMACAddress => '1.3.6.1.4.1.232.18.2.3.1.1.4',
      cpqNicIfPhysAdapterSlot => '1.3.6.1.4.1.232.18.2.3.1.1.5',
      cpqNicIfPhysAdapterIoAddr => '1.3.6.1.4.1.232.18.2.3.1.1.6',
      cpqNicIfPhysAdapterIrq => '1.3.6.1.4.1.232.18.2.3.1.1.7',
      cpqNicIfPhysAdapterDma => '1.3.6.1.4.1.232.18.2.3.1.1.8',
      cpqNicIfPhysAdapterMemAddr => '1.3.6.1.4.1.232.18.2.3.1.1.9',
      cpqNicIfPhysAdapterPort => '1.3.6.1.4.1.232.18.2.3.1.1.10',
      cpqNicIfPhysAdapterDuplexState => '1.3.6.1.4.1.232.18.2.3.1.1.11',
      cpqNicIfPhysAdapterCondition => '1.3.6.1.4.1.232.18.2.3.1.1.12',
      cpqNicIfPhysAdapterState => '1.3.6.1.4.1.232.18.2.3.1.1.13',
      cpqNicIfPhysAdapterStatus => '1.3.6.1.4.1.232.18.2.3.1.1.14',
      cpqNicIfPhysAdapterStatsValid => '1.3.6.1.4.1.232.18.2.3.1.1.15',
      cpqNicIfPhysAdapterGoodTransmits => '1.3.6.1.4.1.232.18.2.3.1.1.16',
      cpqNicIfPhysAdapterGoodReceives => '1.3.6.1.4.1.232.18.2.3.1.1.17',
      cpqNicIfPhysAdapterBadTransmits => '1.3.6.1.4.1.232.18.2.3.1.1.18',
      cpqNicIfPhysAdapterBadReceives => '1.3.6.1.4.1.232.18.2.3.1.1.19',
      cpqNicIfPhysAdapterAlignmentErrors => '1.3.6.1.4.1.232.18.2.3.1.1.20',
      cpqNicIfPhysAdapterFCSErrors => '1.3.6.1.4.1.232.18.2.3.1.1.21',
      cpqNicIfPhysAdapterSingleCollisionFrames => '1.3.6.1.4.1.232.18.2.3.1.1.22',
      cpqNicIfPhysAdapterMultipleCollisionFrames => '1.3.6.1.4.1.232.18.2.3.1.1.23',
      cpqNicIfPhysAdapterDeferredTransmissions => '1.3.6.1.4.1.232.18.2.3.1.1.24',
      cpqNicIfPhysAdapterLateCollisions => '1.3.6.1.4.1.232.18.2.3.1.1.25',
      cpqNicIfPhysAdapterExcessiveCollisions => '1.3.6.1.4.1.232.18.2.3.1.1.26',
      cpqNicIfPhysAdapterInternalMacTransmitErrors => '1.3.6.1.4.1.232.18.2.3.1.1.27',
      cpqNicIfPhysAdapterCarrierSenseErrors => '1.3.6.1.4.1.232.18.2.3.1.1.28',
      cpqNicIfPhysAdapterFrameTooLongs => '1.3.6.1.4.1.232.18.2.3.1.1.29',
      cpqNicIfPhysAdapterInternalMacReceiveErrors => '1.3.6.1.4.1.232.18.2.3.1.1.30',
      cpqNicIfPhysAdapterHwLocation => '1.3.6.1.4.1.232.18.2.3.1.1.31',
      cpqNicIfPhysAdapterPartNumber => '1.3.6.1.4.1.232.18.2.3.1.1.32',
      cpqNicIfPhysAdapterRoleValue => {
          1 => "unknown",
          2 => "primary",
          3 => "secondary",
          4 => "member",
          5 => "txRx",
          6 => "tx",
          7 => "standby",
          8 => "none",
          255 => "notApplicable",
      },
      cpqNicIfPhysAdapterDuplexStateValue => {
          1 => "unknown",
          2 => "half",
          3 => "full",
      },
      cpqNicIfPhysAdapterConditionValue => {
          1 => "other",
          2 => "ok",
          3 => "degraded",
          4 => "failed",
      },
      cpqNicIfPhysAdapterStateValue => {
          1 => "unknown",
          2 => "ok",
          3 => "standby",
          4 => "failed",
      },
      cpqNicIfPhysAdapterStatusValue => {
          1 => "unknown",
          2 => "ok",
          3 => "generalFailure",
          4 => "linkFailure",
      },

  };
  # INDEX { cpqNicIfPhysAdapterIndex }
  foreach ($self->get_entries($oids, 'cpqNicIfPhysAdapterEntry')) {
    push( _æ_ {$self->{physical_nics}},
        HP::Proliant::Component::NicSubsystem::PhysicalNic->new(%{$_}));
  }

}

1;