Skip to content

Commit 0c5a5e1

Browse files
committed
fix(moxa): use the private mib of moxa for duplex status
Refs:CTOR-644
1 parent 3164c6b commit 0c5a5e1

File tree

5 files changed

+349
-3
lines changed

5 files changed

+349
-3
lines changed
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
#
2+
# Copyright 2025 Centreon (http://www.centreon.com/)
3+
#
4+
# Centreon is a full-fledged industry-strength solution that meets
5+
# the needs in IT infrastructure and application monitoring for
6+
# service performance.
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
# See the License for the specific language governing permissions and
18+
# limitations under the License.
19+
#
20+
21+
package network::moxa::switch::snmp::mode::interfaces;
22+
23+
use base qw(snmp_standard::mode::interfaces);
24+
25+
use strict;
26+
use warnings;
27+
sub set_oids_status {
28+
my ($self, %options) = @_;
29+
$self->SUPER::set_oids_status(%options);
30+
31+
# Standard duplex oid don't work on moxa industrial switches (eds405a)
32+
$self->{oid_duplexstatus} = '.1.3.6.1.4.1.8691.7.6.1.10.3.1.3';
33+
# Moxa provide a specific oid for speed/duplex, with this values definition:
34+
# speed100M-Full(3),
35+
# speed100M-Half(2),
36+
# speed10M-Full(1),
37+
# speed10M-Half(0),
38+
# na(-1)
39+
$self->{oid_duplexstatus_mapping} = {
40+
-1 => 'unknown', 0 => 'halfDuplex', 2 => 'halfDuplex', 3 => 'fullDuplex',1 => 'fullDuplex'
41+
};
42+
}
43+
44+
sub new {
45+
my ($class, %options) = @_;
46+
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
47+
bless $self, $class;
48+
49+
return $self;
50+
}
51+
52+
1;
53+
54+
__END__
55+
56+
=head1 MODE
57+
58+
Check interfaces of moxa industrial switches.
59+
60+
=over 8
61+
62+
=item B<--add-global>
63+
64+
Check global port statistics (by default if no --add-* option is set).
65+
66+
=item B<--add-status>
67+
68+
Check interface status.
69+
70+
=item B<--add-duplex-status>
71+
72+
Check duplex status (with --warning-status and --critical-status).
73+
74+
=item B<--add-traffic>
75+
76+
Check interface traffic.
77+
78+
=item B<--add-errors>
79+
80+
Check interface errors.
81+
82+
=item B<--add-cast>
83+
84+
Check interface cast.
85+
86+
=item B<--add-speed>
87+
88+
Check interface speed.
89+
90+
=item B<--add-volume>
91+
92+
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
93+
94+
=item B<--check-metrics>
95+
96+
If the expression is true, metrics are checked (default: '%{opstatus} eq "up"').
97+
98+
=item B<--warning-status>
99+
100+
Define the conditions to match for the status to be WARNING.
101+
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
102+
103+
=item B<--critical-status>
104+
105+
Define the conditions to match for the status to be CRITICAL (default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
106+
You can use the following variables: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
107+
108+
=item B<--warning-*> B<--critical-*>
109+
110+
Thresholds.
111+
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
112+
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
113+
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
114+
'speed' (b/s).
115+
116+
=item B<--units-traffic>
117+
118+
Units of thresholds for the traffic (default: 'percent_delta') ('percent_delta', 'bps', 'counter').
119+
120+
=item B<--units-errors>
121+
122+
Units of thresholds for errors/discards (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
123+
124+
=item B<--units-cast>
125+
126+
Units of thresholds for communication types (default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'deltaps', 'counter').
127+
128+
=item B<--nagvis-perfdata>
129+
130+
Display traffic perfdata to be compatible with NagVis widget.
131+
132+
=item B<--interface>
133+
134+
Check only the interfaces with the specified IDs (OID indexes, e.g.: 1,2,...). If empty, all interfaces will be monitored.
135+
To filter on interface names, see --name.
136+
137+
=item B<--name>
138+
139+
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.
140+
141+
=item B<--regex-id>
142+
143+
With this option, interface IDs will be filtered using the --interface parameter as a regular expression instead of a list of IDs.
144+
145+
=item B<--speed>
146+
147+
Set interface speed for incoming/outgoing traffic (in Mb).
148+
149+
=item B<--speed-in>
150+
151+
Set interface speed for incoming traffic (in Mb).
152+
153+
=item B<--speed-out>
154+
155+
Set interface speed for outgoing traffic (in Mb).
156+
157+
=item B<--map-speed-dsl>
158+
159+
Get interface speed configuration for interfaces of type 'ADSL' and 'VDSL2'.
160+
161+
Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name
162+
163+
E.g: --map-speed-dsl=Et0.835,Et0-vdsl2
164+
165+
=item B<--force-counters64>
166+
167+
Force to use 64 bits counters only. Can be used to improve performance.
168+
169+
=item B<--force-counters32>
170+
171+
Force to use 32-bit counters (even with SNMP versions 2c and 3). To use when 64 bits counters are buggy.
172+
173+
=item B<--reload-cache-time>
174+
175+
Time in minutes before reloading cache file (default: 180).
176+
177+
=item B<--oid-filter>
178+
179+
Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
180+
181+
=item B<--oid-display>
182+
183+
Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
184+
185+
=item B<--oid-extra-display>
186+
187+
Add an OID to display.
188+
189+
=item B<--display-transform-src> B<--display-transform-dst>
190+
191+
Modify the interface name displayed by using a regular expression.
192+
193+
Example: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
194+
195+
=item B<--show-cache>
196+
197+
Display cache interface data.
198+
199+
=back
200+
201+
=cut

src/network/moxa/switch/snmp/plugin.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sub new {
3232
$self->{version} = '0.1';
3333
%{$self->{modes}} = (
3434
'cpu' => 'network::moxa::switch::snmp::mode::cpu',
35-
'interfaces' => 'snmp_standard::mode::interfaces',
35+
'interfaces' => 'network::moxa::switch::snmp::mode::interfaces',
3636
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
3737
'memory' => 'network::moxa::switch::snmp::mode::memory',
3838
'uptime' => 'snmp_standard::mode::uptime',

tests/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Robot tests
44

5-
In this project robot is used to order the integration tests.
5+
In this project robot Framework is used to order the integration tests.
66

77
### install snmpsim
88

@@ -30,6 +30,21 @@ robot tests/
3030

3131
you can filter the tests run by specifying -e to exclude and -i to include a specific tag before the file path.
3232

33+
## Get new data
34+
35+
### Http
36+
37+
Any `curl -v` command should give enough info to create new tests/plugins on new http services.
38+
39+
If the plugin already exists, you can use the plugin to gater the data with the `--debug --verbose` options.
40+
41+
### Snmp
42+
43+
To get snmp data, you can use the snmpwalk command on the host you want to monitor.
44+
```bash
45+
snmpwalk -ObentU -v2c -c 'public' localhost .1
46+
```
47+
3348

3449
## Anonymize tests
3550

@@ -40,7 +55,6 @@ the option `--no-anonymization` allow to not anonymize the data and only remove
4055
perl ./tests/scripts/slim_walk.pl --snmpwalk-path=tests/hardware/client.snmpwalk > smaller-file.snmpwalk
4156
```
4257

43-
4458
## unit tests
4559

4660
In this project perl test::v0 is used to run unit tests.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
*** Settings ***
2+
Documentation Network moxa SNMP plugin
3+
4+
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource
5+
Suite Setup Ctn Generic Suite Setup
6+
7+
Test Timeout 120s
8+
9+
*** Variables ***
10+
${CMD} ${CENTREON_PLUGINS} --plugin=network::moxa::switch::snmp::plugin --hostname=localhost --snmp-port=2024 --snmp-version=2c --snmp-community=network/moxa/switch/snmp/interface --mode=interfaces
11+
${CMD} ${CENTREON_PLUGINS}
12+
... --plugin=network::moxa::switch::snmp::plugin
13+
... --mode=interfaces
14+
... --hostname=${HOSTNAME}
15+
... --snmp-port=${SNMPPORT}
16+
... --snmp-community=network/moxa/switch/snmp/interfaces
17+
18+
*** Test Cases ***
19+
network interface ${tc}
20+
[Tags] network moxa snmp
21+
${command} Catenate
22+
... ${CMD}
23+
... ${arguments}
24+
25+
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
26+
27+
Examples: tc arguments expected_result --
28+
... 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)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
.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"
2+
.1.3.6.1.2.1.1.3.0 = 8074
3+
.1.3.6.1.2.1.2.2.1.2.1 = STRING: "lo"
4+
.1.3.6.1.2.1.2.2.1.2.2 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
5+
.1.3.6.1.2.1.2.2.1.2.3 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
6+
.1.3.6.1.2.1.2.2.1.2.4 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
7+
.1.3.6.1.2.1.2.2.1.2.5 = STRING: "Intel Corporation 82540EM Gigabit Ethernet Controller"
8+
.1.3.6.1.2.1.2.2.1.3.1 = INTEGER: 24
9+
.1.3.6.1.2.1.2.2.1.3.2 = INTEGER: 6
10+
.1.3.6.1.2.1.2.2.1.3.3 = INTEGER: 6
11+
.1.3.6.1.2.1.2.2.1.3.4 = INTEGER: 6
12+
.1.3.6.1.2.1.2.2.1.3.5 = INTEGER: 6
13+
.1.3.6.1.2.1.2.2.1.5.1 = Gauge32: 10000000
14+
.1.3.6.1.2.1.2.2.1.5.2 = Gauge32: 1000000000
15+
.1.3.6.1.2.1.2.2.1.5.3 = Gauge32: 1000000000
16+
.1.3.6.1.2.1.2.2.1.5.4 = Gauge32: 1000000000
17+
.1.3.6.1.2.1.2.2.1.5.5 = Gauge32: 1000000000
18+
.1.3.6.1.2.1.2.2.1.6.1 = ""
19+
.1.3.6.1.2.1.2.2.1.6.2 = Hex-STRING: 08 00 27 8D C0 4D
20+
.1.3.6.1.2.1.2.2.1.6.3 = Hex-STRING: 08 00 27 3C 26 92
21+
.1.3.6.1.2.1.2.2.1.6.4 = Hex-STRING: 08 00 27 FE 8E E3
22+
.1.3.6.1.2.1.2.2.1.6.5 = Hex-STRING: 08 00 27 A4 62 F7
23+
.1.3.6.1.2.1.2.2.1.7.1 = INTEGER: 1
24+
.1.3.6.1.2.1.2.2.1.7.2 = INTEGER: 1
25+
.1.3.6.1.2.1.2.2.1.7.3 = INTEGER: 1
26+
.1.3.6.1.2.1.2.2.1.7.4 = INTEGER: 1
27+
.1.3.6.1.2.1.2.2.1.7.5 = INTEGER: 1
28+
.1.3.6.1.2.1.2.2.1.8.1 = INTEGER: 1
29+
.1.3.6.1.2.1.2.2.1.8.2 = INTEGER: 1
30+
.1.3.6.1.2.1.2.2.1.8.3 = INTEGER: 1
31+
.1.3.6.1.2.1.2.2.1.8.4 = INTEGER: 1
32+
.1.3.6.1.2.1.2.2.1.8.5 = INTEGER: 1
33+
.1.3.6.1.2.1.2.2.1.20.1 = Counter32: 0
34+
.1.3.6.1.2.1.2.2.1.20.2 = Counter32: 0
35+
.1.3.6.1.2.1.2.2.1.20.3 = Counter32: 0
36+
.1.3.6.1.2.1.2.2.1.20.4 = Counter32: 0
37+
.1.3.6.1.2.1.2.2.1.20.5 = Counter32: 0
38+
.1.3.6.1.2.1.2.2.1.21.1 = Gauge32: 0
39+
.1.3.6.1.2.1.2.2.1.21.2 = Gauge32: 0
40+
.1.3.6.1.2.1.2.2.1.21.3 = Gauge32: 0
41+
.1.3.6.1.2.1.2.2.1.21.4 = Gauge32: 0
42+
.1.3.6.1.2.1.2.2.1.21.5 = Gauge32: 0
43+
.1.3.6.1.2.1.2.2.1.22.1 = OID: .0.0
44+
.1.3.6.1.2.1.2.2.1.22.2 = OID: .0.0
45+
.1.3.6.1.2.1.2.2.1.22.3 = OID: .0.0
46+
.1.3.6.1.2.1.2.2.1.22.4 = OID: .0.0
47+
.1.3.6.1.2.1.2.2.1.22.5 = OID: .0.0
48+
.1.3.6.1.2.1.25.1.1.0 = 48160
49+
.1.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo"
50+
.1.3.6.1.2.1.31.1.1.1.1.2 = STRING: "eth0"
51+
.1.3.6.1.2.1.31.1.1.1.1.3 = STRING: "eth1"
52+
.1.3.6.1.2.1.31.1.1.1.1.4 = STRING: "eth2"
53+
.1.3.6.1.2.1.31.1.1.1.1.5 = STRING: "eth3"
54+
.1.3.6.1.2.1.31.1.1.1.10.1 = Counter64: 1904
55+
.1.3.6.1.2.1.31.1.1.1.10.2 = Counter64: 192208
56+
.1.3.6.1.2.1.31.1.1.1.10.3 = Counter64: 647510
57+
.1.3.6.1.2.1.31.1.1.1.10.4 = Counter64: 1592
58+
.1.3.6.1.2.1.31.1.1.1.10.5 = Counter64: 1592
59+
.1.3.6.1.2.1.31.1.1.1.11.1 = Counter64: 20
60+
.1.3.6.1.2.1.31.1.1.1.11.2 = Counter64: 1339
61+
.1.3.6.1.2.1.31.1.1.1.11.3 = Counter64: 5865
62+
.1.3.6.1.2.1.31.1.1.1.11.4 = Counter64: 20
63+
.1.3.6.1.2.1.31.1.1.1.11.5 = Counter64: 20
64+
.1.3.6.1.2.1.31.1.1.1.12.1 = Counter64: 0
65+
.1.3.6.1.2.1.31.1.1.1.12.2 = Counter64: 0
66+
.1.3.6.1.2.1.31.1.1.1.12.3 = Counter64: 0
67+
.1.3.6.1.2.1.31.1.1.1.12.4 = Counter64: 0
68+
.1.3.6.1.2.1.31.1.1.1.12.5 = Counter64: 0
69+
.1.3.6.1.2.1.31.1.1.1.13.1 = Counter64: 0
70+
.1.3.6.1.2.1.31.1.1.1.13.2 = Counter64: 0
71+
.1.3.6.1.2.1.31.1.1.1.13.3 = Counter64: 0
72+
.1.3.6.1.2.1.31.1.1.1.13.4 = Counter64: 0
73+
.1.3.6.1.2.1.31.1.1.1.13.5 = Counter64: 0
74+
.1.3.6.1.2.1.31.1.1.1.15.1 = Gauge32: 10
75+
.1.3.6.1.2.1.31.1.1.1.15.2 = Gauge32: 1000
76+
.1.3.6.1.2.1.31.1.1.1.15.3 = Gauge32: 1000
77+
.1.3.6.1.2.1.31.1.1.1.15.4 = Gauge32: 1000
78+
.1.3.6.1.2.1.31.1.1.1.15.5 = Gauge32: 1000
79+
.1.3.6.1.2.1.31.1.1.1.16.1 = INTEGER: 2
80+
.1.3.6.1.2.1.31.1.1.1.16.2 = INTEGER: 2
81+
.1.3.6.1.2.1.31.1.1.1.16.3 = INTEGER: 2
82+
.1.3.6.1.2.1.31.1.1.1.16.4 = INTEGER: 2
83+
.1.3.6.1.2.1.31.1.1.1.16.5 = INTEGER: 2
84+
.1.3.6.1.2.1.31.1.1.1.17.1 = INTEGER: 2
85+
.1.3.6.1.2.1.31.1.1.1.17.2 = INTEGER: 1
86+
.1.3.6.1.2.1.31.1.1.1.17.3 = INTEGER: 1
87+
.1.3.6.1.2.1.31.1.1.1.17.4 = INTEGER: 1
88+
.1.3.6.1.2.1.31.1.1.1.17.5 = INTEGER: 1
89+
.1.3.6.1.2.1.31.1.1.1.18.1 = ""
90+
.1.3.6.1.2.1.31.1.1.1.18.2 = ""
91+
.1.3.6.1.2.1.31.1.1.1.18.3 = ""
92+
.1.3.6.1.2.1.31.1.1.1.18.4 = ""
93+
.1.3.6.1.2.1.31.1.1.1.18.5 = ""
94+
.1.3.6.1.2.1.31.1.1.1.19.1 = 0
95+
.1.3.6.1.2.1.31.1.1.1.19.2 = 0
96+
.1.3.6.1.2.1.31.1.1.1.19.3 = 0
97+
.1.3.6.1.2.1.31.1.1.1.19.4 = 0
98+
.1.3.6.1.2.1.31.1.1.1.19.5 = 0
99+
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.1 = INTEGER: 3
100+
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.2 = INTEGER: 2
101+
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.3 = INTEGER: -1
102+
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.4 = INTEGER: 1
103+
.1.3.6.1.4.1.8691.7.6.1.10.3.1.3.5 = INTEGER: 3

0 commit comments

Comments
 (0)