mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
* 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>
71 lines
2.2 KiB
PHP
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'
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|