mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 23:54:18 +02:00
CTOR-644-plugin-network-moxa-switch-snmp-mode-interfaces-option-add-duplex-status-duplex-unknown (#5420)
Refs: CTOR-644
This commit is contained in:
parent
9115be2fb1
commit
0dae1d9460
201
src/network/moxa/switch/snmp/mode/interfaces.pm
Normal file
201
src/network/moxa/switch/snmp/mode/interfaces.pm
Normal file
@ -0,0 +1,201 @@
|
||||
#
|
||||
# Copyright 2025 Centreon (http://www.centreon.com/)
|
||||
#
|
||||
# Centreon is a full-fledged industry-strength solution that meets
|
||||
# the needs in IT infrastructure and application monitoring for
|
||||
# service performance.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package network::moxa::switch::snmp::mode::interfaces;
|
||||
|
||||
use base qw(snmp_standard::mode::interfaces);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
sub set_oids_status {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::set_oids_status(%options);
|
||||
|
||||
# Standard duplex oid don't work on moxa industrial switches (eds405a)
|
||||
$self->{oid_duplexstatus} = '.1.3.6.1.4.1.8691.7.6.1.10.3.1.3';
|
||||
# Moxa provide a specific oid for speed/duplex, with this values definition:
|
||||
# speed100M-Full(3),
|
||||
# speed100M-Half(2),
|
||||
# speed10M-Full(1),
|
||||
# speed10M-Half(0),
|
||||
# na(-1)
|
||||
$self->{oid_duplexstatus_mapping} = {
|
||||
-1 => 'unknown', 0 => 'halfDuplex', 2 => 'halfDuplex', 3 => 'fullDuplex',1 => 'fullDuplex'
|
||||
};
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
bless $self, $class;
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 MODE
|
||||
|
||||
Check interfaces of moxa industrial switches.
|
||||
|
||||
=over 8
|
||||
|
||||
=item B<--add-global>
|
||||
|
||||
Check global port statistics (by default if no --add-* option is set).
|
||||
|
||||
=item B<--add-status>
|
||||
|
||||
Check interface status.
|
||||
|
||||
=item B<--add-duplex-status>
|
||||
|
||||
Check duplex status (with --warning-status and --critical-status).
|
||||
|
||||
=item B<--add-traffic>
|
||||
|
||||
Check interface traffic.
|
||||
|
||||
=item B<--add-errors>
|
||||
|
||||
Check interface errors.
|
||||
|
||||
=item B<--add-cast>
|
||||
|
||||
Check interface cast.
|
||||
|
||||
=item B<--add-speed>
|
||||
|
||||
Check interface speed.
|
||||
|
||||
=item B<--add-volume>
|
||||
|
||||
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
|
||||
|
||||
=item B<--check-metrics>
|
||||
|
||||
If the expression is true, metrics are checked (default: '%{opstatus} eq "up"').
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Define the conditions to match for the status to be CRITICAL (default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
|
||||
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
|
||||
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
|
||||
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
|
||||
'speed' (b/s).
|
||||
|
||||
=item B<--units-traffic>
|
||||
|
||||
Units of thresholds for the traffic (default: 'percent_delta') ('percent_delta', 'bps', 'counter').
|
||||
|
||||
=item B<--units-errors>
|
||||
|
||||
Units of thresholds for errors/discards (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
|
||||
|
||||
=item B<--units-cast>
|
||||
|
||||
Units of thresholds for communication types (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
|
||||
|
||||
=item B<--nagvis-perfdata>
|
||||
|
||||
Display traffic perfdata to be compatible with NagVis widget.
|
||||
|
||||
=item B<--interface>
|
||||
|
||||
Check only the interfaces with the specified IDs (OID indexes, e.g.: 1,2,...). If empty, all interfaces will be monitored.
|
||||
To filter on interface names, see --name.
|
||||
|
||||
=item B<--name>
|
||||
|
||||
With this option, the interfaces will be filtered by name (given in option --interface) instead of OID index. The name matching mode supports regular expressions.
|
||||
|
||||
=item B<--regex-id>
|
||||
|
||||
With this option, interface IDs will be filtered using the --interface parameter as a regular expression instead of a list of IDs.
|
||||
|
||||
=item B<--speed>
|
||||
|
||||
Set interface speed for incoming/outgoing traffic (in Mb).
|
||||
|
||||
=item B<--speed-in>
|
||||
|
||||
Set interface speed for incoming traffic (in Mb).
|
||||
|
||||
=item B<--speed-out>
|
||||
|
||||
Set interface speed for outgoing traffic (in Mb).
|
||||
|
||||
=item B<--map-speed-dsl>
|
||||
|
||||
Get interface speed configuration for interfaces of type 'ADSL' and 'VDSL2'.
|
||||
|
||||
Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name
|
||||
|
||||
E.g: --map-speed-dsl=Et0.835,Et0-vdsl2
|
||||
|
||||
=item B<--force-counters64>
|
||||
|
||||
Force to use 64 bits counters only. Can be used to improve performance.
|
||||
|
||||
=item B<--force-counters32>
|
||||
|
||||
Force to use 32-bit counters (even with SNMP versions 2c and 3). To use when 64 bits counters are buggy.
|
||||
|
||||
=item B<--reload-cache-time>
|
||||
|
||||
Time in minutes before reloading cache file (default: 180).
|
||||
|
||||
=item B<--oid-filter>
|
||||
|
||||
Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-display>
|
||||
|
||||
Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
|
||||
|
||||
=item B<--oid-extra-display>
|
||||
|
||||
Add an OID to display.
|
||||
|
||||
=item B<--display-transform-src> B<--display-transform-dst>
|
||||
|
||||
Modify the interface name displayed by using a regular expression.
|
||||
|
||||
Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
|
||||
|
||||
=item B<--show-cache>
|
||||
|
||||
Display cache interface data.
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
@ -32,7 +32,7 @@ sub new {
|
||||
$self->{version} = '0.1';
|
||||
%{$self->{modes}} = (
|
||||
'cpu' => 'network::moxa::switch::snmp::mode::cpu',
|
||||
'interfaces' => 'snmp_standard::mode::interfaces',
|
||||
'interfaces' => 'network::moxa::switch::snmp::mode::interfaces',
|
||||
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
|
||||
'memory' => 'network::moxa::switch::snmp::mode::memory',
|
||||
'uptime' => 'snmp_standard::mode::uptime',
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
## Robot tests
|
||||
|
||||
In this project robot is used to order the integration tests.
|
||||
In this project robot Framework is used to order the integration tests.
|
||||
|
||||
### install snmpsim
|
||||
|
||||
@ -30,6 +30,21 @@ robot tests/
|
||||
|
||||
you can filter the tests run by specifying -e to exclude and -i to include a specific tag before the file path.
|
||||
|
||||
## Get new data
|
||||
|
||||
### Http
|
||||
|
||||
Any `curl -v` command should give enough info to create new tests/plugins on new http services.
|
||||
|
||||
If the plugin already exists, you can use the plugin to gater the data with the `--debug --verbose` options.
|
||||
|
||||
### Snmp
|
||||
|
||||
To get snmp data, you can use the snmpwalk command on the host you want to monitor.
|
||||
```bash
|
||||
snmpwalk -ObentU -v2c -c 'public' localhost .1
|
||||
```
|
||||
|
||||
|
||||
## Anonymize tests
|
||||
|
||||
@ -40,7 +55,6 @@ the option `--no-anonymization` allow to not anonymize the data and only remove
|
||||
perl ./tests/scripts/slim_walk.pl --snmpwalk-path=tests/hardware/client.snmpwalk > smaller-file.snmpwalk
|
||||
```
|
||||
|
||||
|
||||
## unit tests
|
||||
|
||||
In this project perl test::v0 is used to run unit tests.
|
||||
|
27
tests/network/moxa/switch/snmp/interfaces.robot
Normal file
27
tests/network/moxa/switch/snmp/interfaces.robot
Normal file
@ -0,0 +1,27 @@
|
||||
*** Settings ***
|
||||
Documentation Network moxa SNMP plugin
|
||||
|
||||
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
|
||||
Suite Setup Ctn Generic Suite Setup
|
||||
|
||||
Test Timeout 120s
|
||||
|
||||
*** Variables ***
|
||||
${CMD} ${CENTREON_PLUGINS}
|
||||
... --plugin=network::moxa::switch::snmp::plugin
|
||||
... --mode=interfaces
|
||||
... --hostname=${HOSTNAME}
|
||||
... --snmp-port=${SNMPPORT}
|
||||
... --snmp-community=network/moxa/switch/snmp/interfaces
|
||||
|
||||
*** Test Cases ***
|
||||
network interface ${tc}
|
||||
[Tags] network moxa snmp
|
||||
${command} Catenate
|
||||
... ${CMD}
|
||||
... ${arguments}
|
||||
|
||||
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
|
||||
|
||||
Examples: tc arguments expected_result --
|
||||
... 1 --verbose --add-duplex-status OK: All interfaces are ok Interface 'lo' Status : up (admin: up) (duplex: fullDuplex) Interface 'eth0' Status : up (admin: up) (duplex: halfDuplex) Interface 'eth1' Status : up (admin: up) (duplex: unknown) Interface 'eth2' Status : up (admin: up) (duplex: fullDuplex) Interface 'eth3' Status : up (admin: up) (duplex: fullDuplex)
|
103
tests/network/moxa/switch/snmp/interfaces.snmpwalk
Normal file
103
tests/network/moxa/switch/snmp/interfaces.snmpwalk
Normal file
@ -0,0 +1,103 @@
|
||||
.1.3.6.1.2.1.1.1.0 = STRING: "Linux server-debian11 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64"
|
||||
.1.3.6.1.2.1.1.3.0 = 8074
|
||||
.1.3.6.1.2.1.2.2.1.2.1 = STRING: "lo"
|
||||
.1.3.6.1.2.1.2.2.1.2.2 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
|
||||
.1.3.6.1.2.1.2.2.1.2.3 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
|
||||
.1.3.6.1.2.1.2.2.1.2.4 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
|
||||
.1.3.6.1.2.1.2.2.1.2.5 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
|
||||
.1.3.6.1.2.1.2.2.1.3.1 = INTEGER: 24
|
||||
.1.3.6.1.2.1.2.2.1.3.2 = INTEGER: 6
|
||||
.1.3.6.1.2.1.2.2.1.3.3 = INTEGER: 6
|
||||
.1.3.6.1.2.1.2.2.1.3.4 = INTEGER: 6
|
||||
.1.3.6.1.2.1.2.2.1.3.5 = INTEGER: 6
|
||||
.1.3.6.1.2.1.2.2.1.5.1 = Gauge32: 10000000
|
||||
.1.3.6.1.2.1.2.2.1.5.2 = Gauge32: 1000000000
|
||||
.1.3.6.1.2.1.2.2.1.5.3 = Gauge32: 1000000000
|
||||
.1.3.6.1.2.1.2.2.1.5.4 = Gauge32: 1000000000
|
||||
.1.3.6.1.2.1.2.2.1.5.5 = Gauge32: 1000000000
|
||||
.1.3.6.1.2.1.2.2.1.6.1 = ""
|
||||
.1.3.6.1.2.1.2.2.1.6.2 = Hex-STRING: 08 00 27 8D C0 4D
|
||||
.1.3.6.1.2.1.2.2.1.6.3 = Hex-STRING: 08 00 27 3C 26 92
|
||||
.1.3.6.1.2.1.2.2.1.6.4 = Hex-STRING: 08 00 27 FE 8E E3
|
||||
.1.3.6.1.2.1.2.2.1.6.5 = Hex-STRING: 08 00 27 A4 62 F7
|
||||
.1.3.6.1.2.1.2.2.1.7.1 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.7.2 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.7.3 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.7.4 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.7.5 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.8.1 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.8.2 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.8.3 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.8.4 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.8.5 = INTEGER: 1
|
||||
.1.3.6.1.2.1.2.2.1.20.1 = Counter32: 0
|
||||
.1.3.6.1.2.1.2.2.1.20.2 = Counter32: 0
|
||||
.1.3.6.1.2.1.2.2.1.20.3 = Counter32: 0
|
||||
.1.3.6.1.2.1.2.2.1.20.4 = Counter32: 0
|
||||
.1.3.6.1.2.1.2.2.1.20.5 = Counter32: 0
|
||||
.1.3.6.1.2.1.2.2.1.21.1 = Gauge32: 0
|
||||
.1.3.6.1.2.1.2.2.1.21.2 = Gauge32: 0
|
||||
.1.3.6.1.2.1.2.2.1.21.3 = Gauge32: 0
|
||||
.1.3.6.1.2.1.2.2.1.21.4 = Gauge32: 0
|
||||
.1.3.6.1.2.1.2.2.1.21.5 = Gauge32: 0
|
||||
.1.3.6.1.2.1.2.2.1.22.1 = OID: .0.0
|
||||
.1.3.6.1.2.1.2.2.1.22.2 = OID: .0.0
|
||||
.1.3.6.1.2.1.2.2.1.22.3 = OID: .0.0
|
||||
.1.3.6.1.2.1.2.2.1.22.4 = OID: .0.0
|
||||
.1.3.6.1.2.1.2.2.1.22.5 = OID: .0.0
|
||||
.1.3.6.1.2.1.25.1.1.0 = 48160
|
||||
.1.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
|
||||
.1.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth0"
|
||||
.1.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth1"
|
||||
.1.3.6.1.2.1.31.1.1.1.1.4 = STRING: "eth2"
|
||||
.1.3.6.1.2.1.31.1.1.1.1.5 = STRING: "eth3"
|
||||
.1.3.6.1.2.1.31.1.1.1.10.1 = Counter64: 1904
|
||||
.1.3.6.1.2.1.31.1.1.1.10.2 = Counter64: 192208
|
||||
.1.3.6.1.2.1.31.1.1.1.10.3 = Counter64: 647510
|
||||
.1.3.6.1.2.1.31.1.1.1.10.4 = Counter64: 1592
|
||||
.1.3.6.1.2.1.31.1.1.1.10.5 = Counter64: 1592
|
||||
.1.3.6.1.2.1.31.1.1.1.11.1 = Counter64: 20
|
||||
.1.3.6.1.2.1.31.1.1.1.11.2 = Counter64: 1339
|
||||
.1.3.6.1.2.1.31.1.1.1.11.3 = Counter64: 5865
|
||||
.1.3.6.1.2.1.31.1.1.1.11.4 = Counter64: 20
|
||||
.1.3.6.1.2.1.31.1.1.1.11.5 = Counter64: 20
|
||||
.1.3.6.1.2.1.31.1.1.1.12.1 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.12.2 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.12.3 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.12.4 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.12.5 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.13.1 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.13.2 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.13.3 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.13.4 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.13.5 = Counter64: 0
|
||||
.1.3.6.1.2.1.31.1.1.1.15.1 = Gauge32: 10
|
||||
.1.3.6.1.2.1.31.1.1.1.15.2 = Gauge32: 1000
|
||||
.1.3.6.1.2.1.31.1.1.1.15.3 = Gauge32: 1000
|
||||
.1.3.6.1.2.1.31.1.1.1.15.4 = Gauge32: 1000
|
||||
.1.3.6.1.2.1.31.1.1.1.15.5 = Gauge32: 1000
|
||||
.1.3.6.1.2.1.31.1.1.1.16.1 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.16.2 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.16.3 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.16.4 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.16.5 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.17.1 = INTEGER: 2
|
||||
.1.3.6.1.2.1.31.1.1.1.17.2 = INTEGER: 1
|
||||
.1.3.6.1.2.1.31.1.1.1.17.3 = INTEGER: 1
|
||||
.1.3.6.1.2.1.31.1.1.1.17.4 = INTEGER: 1
|
||||
.1.3.6.1.2.1.31.1.1.1.17.5 = INTEGER: 1
|
||||
.1.3.6.1.2.1.31.1.1.1.18.1 = ""
|
||||
.1.3.6.1.2.1.31.1.1.1.18.2 = ""
|
||||
.1.3.6.1.2.1.31.1.1.1.18.3 = ""
|
||||
.1.3.6.1.2.1.31.1.1.1.18.4 = ""
|
||||
.1.3.6.1.2.1.31.1.1.1.18.5 = ""
|
||||
.1.3.6.1.2.1.31.1.1.1.19.1 = 0
|
||||
.1.3.6.1.2.1.31.1.1.1.19.2 = 0
|
||||
.1.3.6.1.2.1.31.1.1.1.19.3 = 0
|
||||
.1.3.6.1.2.1.31.1.1.1.19.4 = 0
|
||||
.1.3.6.1.2.1.31.1.1.1.19.5 = 0
|
||||
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.1 = INTEGER: 3
|
||||
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.2 = INTEGER: 2
|
||||
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.3 = INTEGER: -1
|
||||
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.4 = INTEGER: 1
|
||||
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.5 = INTEGER: 3
|
@ -98,6 +98,7 @@ ifAlias
|
||||
ifDesc
|
||||
ifName
|
||||
--ignore-orgs-api-disabled
|
||||
IKS
|
||||
IMEI
|
||||
in-bcast
|
||||
in-crc
|
||||
|
Loading…
x
Reference in New Issue
Block a user