Files
27c124f19f FabOS remove disabled dbm sensors (#12877)
* add check if adminstatus is up

* added testdata

* Changed ifAdminStatus state detection

* updated testdata

* updated testdata2

* Update fabos_6520.json

* Update fabos.json

* Update fabos_6520.json

* Update fabos.json

* fix fabos.json

* fix bug in discovery include

Co-authored-by: Erik <[email protected]>
Co-authored-by: Tony Murray <[email protected]>
2021-10-20 18:51:49 -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(
$valid['sensor'],
'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(
$valid['sensor'],
'dbm',
$device,
".$oid.$index",
'swSfpTxPower.' . $index,
'brocade',
makeshortif($ifDescr[$ifIndex]) . ' TX',
1,
1,
-5,
null,
null,
0,
$current,
'snmp',
$ifIndex,
'ports',
null,
'Transmit Power'
);
}
}
}
}