Skip to content

Commit 7b48a9d

Browse files
authored
bdcom: improve transceiver support (librenms#18684)
1 parent 43740c5 commit 7b48a9d

File tree

3 files changed

+789
-193
lines changed

3 files changed

+789
-193
lines changed

LibreNMS/OS/Bdcom.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* Bdcom.php
5+
*
6+
* BDCOM OS
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
* @link https://www.librenms.org
22+
*
23+
* @copyright 2025 Frederik Kriewitz
24+
* @author Frederik Kriewitz <[email protected]>
25+
*/
26+
27+
namespace LibreNMS\OS;
28+
29+
use App\Facades\PortCache;
30+
use App\Models\Transceiver;
31+
use Illuminate\Support\Collection;
32+
use LibreNMS\Interfaces\Discovery\TransceiverDiscovery;
33+
use LibreNMS\OS;
34+
use SnmpQuery;
35+
36+
class Bdcom extends OS implements TransceiverDiscovery
37+
{
38+
public function discoverTransceivers(): Collection
39+
{
40+
return SnmpQuery::cache()->walk('NMS-IF-MIB::ifSfpParameterTable')->mapTable(function ($data, $index) {
41+
$ifIndex = $data['NMS-IF-MIB::ifSfpIndex'];
42+
if ($data['NMS-IF-MIB::sfpPresentStatus'] != 1) {
43+
return null;
44+
}
45+
46+
$types = [
47+
1 => 'SFP',
48+
2 => 'DAC',
49+
3 => null,
50+
];
51+
52+
$type = $types[$data['NMS-IF-MIB::type']] ?? 'unknown type ' . $data['NMS-IF-MIB::type'];
53+
54+
return new Transceiver([
55+
'port_id' => (int) PortCache::getIdFromIfIndex($ifIndex, $this->getDevice()),
56+
'index' => $ifIndex,
57+
'entity_physical_index' => $ifIndex,
58+
'type' => $type,
59+
'vendor' => $data['NMS-IF-MIB::vendname'] ?? null,
60+
'model' => $data['NMS-IF-MIB::vendorPN'] ?? null,
61+
'serial' => $data['NMS-IF-MIB::sfpSeqNum'] ?? null,
62+
'distance' => $data['NMS-IF-MIB::transDist'] ?? null,
63+
'wavelength' => $data['NMS-IF-MIB::waveLen'] ?? null,
64+
]);
65+
})->filter();
66+
}
67+
}

resources/definitions/os_discovery/bdcom.yaml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ modules:
4848
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.4.{{ $index }}'
4949
descr: '{{ IF-MIB::ifName }} temperature'
5050
index: 'ifSfpParameterTable.temperature.{{ $index }}'
51-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
51+
group: transceiver
5252
entPhysicalIndex: '{{ $index }}'
5353
entPhysicalIndex_measured: ports
5454
divisor: 256
@@ -69,7 +69,7 @@ modules:
6969
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.5.{{ $index }}'
7070
descr: '{{ IF-MIB::ifName }} voltage'
7171
index: 'ifSfpParameterTable.vlotage.{{ $index }}'
72-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
72+
group: transceiver
7373
entPhysicalIndex: '{{ $index }}'
7474
entPhysicalIndex_measured: ports
7575
divisor: 10000
@@ -86,7 +86,7 @@ modules:
8686
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.6.{{ $index }}'
8787
descr: '{{ IF-MIB::ifName }} current1'
8888
index: 'ifSfpParameterTable.curr1.{{ $index }}'
89-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
89+
group: transceiver
9090
entPhysicalIndex: '{{ $index }}'
9191
entPhysicalIndex_measured: ports
9292
divisor: 500000
@@ -101,7 +101,7 @@ modules:
101101
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.10.{{ $index }}'
102102
descr: '{{ IF-MIB::ifName }} current2'
103103
index: 'ifSfpParameterTable.curr2.{{ $index }}'
104-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
104+
group: transceiver
105105
entPhysicalIndex: '{{ $index }}'
106106
entPhysicalIndex_measured: ports
107107
divisor: 500000
@@ -116,7 +116,7 @@ modules:
116116
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.13.{{ $index }}'
117117
descr: '{{ IF-MIB::ifName }} current3'
118118
index: 'ifSfpParameterTable.curr3.{{ $index }}'
119-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
119+
group: transceiver
120120
entPhysicalIndex: '{{ $index }}'
121121
entPhysicalIndex_measured: ports
122122
divisor: 500000
@@ -131,7 +131,7 @@ modules:
131131
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.16.{{ $index }}'
132132
descr: '{{ IF-MIB::ifName }} current4'
133133
index: 'ifSfpParameterTable.curr4.{{ $index }}'
134-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
134+
group: transceiver
135135
entPhysicalIndex: '{{ $index }}'
136136
entPhysicalIndex_measured: ports
137137
divisor: 500000
@@ -148,7 +148,7 @@ modules:
148148
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.3.{{ $index }}'
149149
descr: '{{ IF-MIB::ifName }} rxPower1'
150150
index: 'ifSfpParameterTable.rxPower1.{{ $index }}'
151-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
151+
group: transceiver
152152
entPhysicalIndex: '{{ $index }}'
153153
entPhysicalIndex_measured: ports
154154
divisor: 100
@@ -163,7 +163,7 @@ modules:
163163
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.9.{{ $index }}'
164164
descr: '{{ IF-MIB::ifName }} rxPower2'
165165
index: 'ifSfpParameterTable.rxPower2.{{ $index }}'
166-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
166+
group: transceiver
167167
entPhysicalIndex: '{{ $index }}'
168168
entPhysicalIndex_measured: ports
169169
divisor: 100
@@ -178,7 +178,7 @@ modules:
178178
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.12.{{ $index }}'
179179
descr: '{{ IF-MIB::ifName }} rxPower3'
180180
index: 'ifSfpParameterTable.rxPower3.{{ $index }}'
181-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
181+
group: transceiver
182182
entPhysicalIndex: '{{ $index }}'
183183
entPhysicalIndex_measured: ports
184184
divisor: 100
@@ -193,7 +193,7 @@ modules:
193193
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.15.{{ $index }}'
194194
descr: '{{ IF-MIB::ifName }} rxPower4'
195195
index: 'ifSfpParameterTable.rxPower4.{{ $index }}'
196-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
196+
group: transceiver
197197
entPhysicalIndex: '{{ $index }}'
198198
entPhysicalIndex_measured: ports
199199
divisor: 100
@@ -208,7 +208,7 @@ modules:
208208
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.2.{{ $index }}'
209209
descr: '{{ IF-MIB::ifName }} txPower1'
210210
index: 'ifSfpParameterTable.txPower1.{{ $index }}'
211-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
211+
group: transceiver
212212
entPhysicalIndex: '{{ $index }}'
213213
entPhysicalIndex_measured: ports
214214
divisor: 100
@@ -223,7 +223,7 @@ modules:
223223
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.8.{{ $index }}'
224224
descr: '{{ IF-MIB::ifName }} txPower2'
225225
index: 'ifSfpParameterTable.txPower2.{{ $index }}'
226-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
226+
group: transceiver
227227
entPhysicalIndex: '{{ $index }}'
228228
entPhysicalIndex_measured: ports
229229
divisor: 100
@@ -238,7 +238,7 @@ modules:
238238
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.11.{{ $index }}'
239239
descr: '{{ IF-MIB::ifName }} txPower3'
240240
index: 'ifSfpParameterTable.txPower3.{{ $index }}'
241-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
241+
group: transceiver
242242
entPhysicalIndex: '{{ $index }}'
243243
entPhysicalIndex_measured: ports
244244
divisor: 100
@@ -253,7 +253,7 @@ modules:
253253
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.14.{{ $index }}'
254254
descr: '{{ IF-MIB::ifName }} txPower4'
255255
index: 'ifSfpParameterTable.txPower4.{{ $index }}'
256-
group: 'Transceiver: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
256+
group: transceiver
257257
entPhysicalIndex: '{{ $index }}'
258258
entPhysicalIndex_measured: ports
259259
divisor: 100
@@ -290,9 +290,9 @@ modules:
290290
oid: ifSfpParameterTable
291291
value: sfpLostStatus
292292
num_oid: '.1.3.6.1.4.1.3320.9.63.1.7.1.21.{{ $index }}'
293-
descr: 'LOS'
293+
descr: '{{ IF-MIB::ifName }} LOS'
294294
index: 'ifSfpParameterTable.sfpLostStatus.{{ $index }}'
295-
group: 'Transceiverr: {{ IF-MIB::ifName }} (Vendor: {{ $vendname }} PN: {{ $vendorPN }} S/N: {{ $sfpSeqNum }} {{ $waveLen }}nm)'
295+
group: transceiver
296296
entPhysicalIndex: '{{ $index }}'
297297
entPhysicalIndex_measured: ports
298298
states:

0 commit comments

Comments
 (0)