Files
librenms-librenms/includes/discovery/sensors/dbm/fabos.inc.php
Tony Murray f15f8fa63a Sensors remove reliance on global variable (#16344)
* Sensors remove reliance on global variable

* Apply fixes from StyleCI

* Clear the instance instead of reset.
Remove $valid['sensors'] from docs

---------

Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
2024-09-03 21:04:34 -05:00

71 lines
2.2 KiB
PHP

<?php
$fabosSfpRxPower = snmpwalk_array_num($device, '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.4'); // FA-EXT-MIB::swSfpRxPower
$fabosSfpTxPower = snmpwalk_array_num($device, '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.5'); // FA-EXT-MIB::swSfpTxPower
if (! empty($fabosSfpRxPower) || ! empty($fabosSfpTxPower)) {
$ifDescr = snmpwalk_group($device, 'ifDescr', 'IF-MIB', 0)['ifDescr'] ?? [];
$ifAdminStatus = snmpwalk_group($device, 'ifAdminStatus', 'IF-MIB', 0)['ifAdminStatus'] ?? [];
}
foreach ($fabosSfpRxPower as $oid => $entry) {
foreach ($entry as $index => $current) {
if (is_numeric($current)) {
$ifIndex = $index + 1073741823;
if ($ifAdminStatus[$ifIndex] == '1') {
discover_sensor(
null,
'dbm',
$device,
".$oid.$index",
'swSfpRxPower.' . $index,
'brocade',
makeshortif($ifDescr[$ifIndex]) . ' RX',
1,
1,
-5,
null,
null,
0,
$current,
'snmp',
$ifIndex,
'ports',
null,
'Receive Power'
);
}
}
}
}
foreach ($fabosSfpTxPower as $oid => $entry) {
foreach ($entry as $index => $current) {
if (is_numeric($current)) {
$ifIndex = $index + 1073741823;
if ($ifAdminStatus[$ifIndex] == '1') {
discover_sensor(
null,
'dbm',
$device,
".$oid.$index",
'swSfpTxPower.' . $index,
'brocade',
makeshortif($ifDescr[$ifIndex]) . ' TX',
1,
1,
-5,
null,
null,
0,
$current,
'snmp',
$ifIndex,
'ports',
null,
'Transmit Power'
);
}
}
}
}