Commit version 24.12.13800
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage discovery
|
||||
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2021 Observium Limited
|
||||
* @copyright (C) Adam Armstrong
|
||||
*
|
||||
*/
|
||||
|
||||
@ -23,80 +23,72 @@
|
||||
|
||||
$flags = OBS_SNMP_ALL_NUMERIC_INDEX;
|
||||
|
||||
$oids = snmpwalk_cache_oid($device, 'swSfpStatTable', array(), 'FA-EXT-MIB', NULL, $flags);
|
||||
$oids = snmpwalk_cache_oid($device, 'swSfpStatTable', [], 'FA-EXT-MIB', NULL, $flags);
|
||||
if (!safe_count($oids)) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
$oids = snmpwalk_cache_oid($device, 'connUnitPortIndex', $oids, 'FCMGMT-MIB', NULL, $flags);
|
||||
//$oids = snmpwalk_cache_oid($device, 'connUnitPortName', $oids, 'FCMGMT-MIB', NULL, $flags);
|
||||
$oids = snmpwalk_cache_oid($device, 'connUnitPortIndex', $oids, 'FCMGMT-MIB', NULL, $flags);
|
||||
//$oids = snmpwalk_cache_oid($device, 'connUnitPortName', $oids, 'FCMGMT-MIB', NULL, $flags);
|
||||
|
||||
$port_sw = snmpwalk_cache_oid($device, 'swFCPortSpecifier', array(), 'SW-MIB');
|
||||
$port_sw = snmpwalk_cache_oid($device, 'swFCPortSpecifier', [], 'SW-MIB');
|
||||
|
||||
//print_vars($oids);
|
||||
foreach ($oids as $index => $entry)
|
||||
{
|
||||
if (isset($port_sw[$entry['connUnitPortIndex']])) {
|
||||
$entry = array_merge($entry, $port_sw[$entry['connUnitPortIndex']]);
|
||||
}
|
||||
$port_fc = $entry['swFCPortSpecifier'];
|
||||
foreach ($oids as $index => $entry) {
|
||||
if (isset($port_sw[$entry['connUnitPortIndex']])) {
|
||||
$entry = array_merge($entry, $port_sw[$entry['connUnitPortIndex']]);
|
||||
}
|
||||
$port_fc = $entry['swFCPortSpecifier'];
|
||||
|
||||
$port = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND (`ifName` = ? OR `ifDescr` REGEXP ?)', array($device['device_id'], $port_fc, '^FC[[:alnum:]]* port '.$port_fc.'$'));
|
||||
if (!$port && is_numeric($port_fc))
|
||||
{
|
||||
// non-bladed
|
||||
$port_fc = '0/' . $port_fc;
|
||||
$port = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND (`ifName` = ? OR `ifDescr` REGEXP ?)', array($device['device_id'], $port_fc, '^FC[[:alnum:]]* port '.$port_fc.'$'));
|
||||
}
|
||||
$port = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND (`ifName` = ? OR `ifDescr` REGEXP ?)', [$device['device_id'], $port_fc, '^FC[[:alnum:]]* port ' . $port_fc . '$']);
|
||||
if (!$port && is_numeric($port_fc)) {
|
||||
// non-bladed
|
||||
$port_fc = '0/' . $port_fc;
|
||||
$port = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND (`ifName` = ? OR `ifDescr` REGEXP ?)', [$device['device_id'], $port_fc, '^FC[[:alnum:]]* port ' . $port_fc . '$']);
|
||||
}
|
||||
|
||||
$options = array('entPhysicalIndex' => $entry['connUnitPortIndex']);
|
||||
if ($port)
|
||||
{
|
||||
$name = $port['ifDescr'];
|
||||
$options['measured_class'] = 'port';
|
||||
$options['measured_entity'] = $port['port_id'];
|
||||
} else {
|
||||
$name = $entry['connUnitPortName'];
|
||||
}
|
||||
$options = ['entPhysicalIndex' => $entry['connUnitPortIndex']];
|
||||
if ($port) {
|
||||
$name = $port['ifDescr'];
|
||||
$options['measured_class'] = 'port';
|
||||
$options['measured_entity'] = $port['port_id'];
|
||||
} else {
|
||||
$name = $entry['connUnitPortName'];
|
||||
}
|
||||
|
||||
$descr = $name . ' Temperature';
|
||||
$oid_name = 'swSfpTemperature';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.1.'.$index;
|
||||
$type = $mib . '-' . $oid_name;
|
||||
$value = $entry[$oid_name];
|
||||
$descr = $name . ' Temperature';
|
||||
$oid_name = 'swSfpTemperature';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.1.' . $index;
|
||||
$value = $entry[$oid_name];
|
||||
|
||||
discover_sensor_ng($device,'temperature', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], NULL, $descr, 1, $value, $options);
|
||||
discover_sensor_ng($device, 'temperature', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], $descr, 1, $value, $options);
|
||||
|
||||
$descr = $name . ' Voltage';
|
||||
$oid_name = 'swSfpVoltage';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.2.'.$index;
|
||||
$type = $mib . '-' . $oid_name;
|
||||
$value = $entry[$oid_name];
|
||||
$descr = $name . ' Voltage';
|
||||
$oid_name = 'swSfpVoltage';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.2.' . $index;
|
||||
$value = $entry[$oid_name];
|
||||
|
||||
discover_sensor_ng($device,'voltage', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], NULL, $descr, 0.001, $value, $options);
|
||||
discover_sensor_ng($device, 'voltage', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], $descr, 0.001, $value, $options);
|
||||
|
||||
$descr = $name . ' Bias Current';
|
||||
$oid_name = 'swSfpCurrent';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.3.'.$index;
|
||||
$type = $mib . '-' . $oid_name;
|
||||
$value = $entry[$oid_name];
|
||||
$descr = $name . ' Bias Current';
|
||||
$oid_name = 'swSfpCurrent';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.3.' . $index;
|
||||
$value = $entry[$oid_name];
|
||||
|
||||
discover_sensor_ng($device,'current', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], NULL, $descr, 0.001, $value, $options);
|
||||
discover_sensor_ng($device, 'current', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], $descr, 0.001, $value, $options);
|
||||
|
||||
$descr = $name . ' Receive Power';
|
||||
$oid_name = 'swSfpRxPower';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.4.'.$index;
|
||||
$type = $mib . '-' . $oid_name;
|
||||
$value = str_replace('-inf', '-40', $entry[$oid_name]);
|
||||
$descr = $name . ' Receive Power';
|
||||
$oid_name = 'swSfpRxPower';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.4.' . $index;
|
||||
$value = str_replace('-inf', '-40', $entry[$oid_name]);
|
||||
|
||||
discover_sensor_ng($device,'dbm', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], NULL, $descr, 1, $value, $options);
|
||||
discover_sensor_ng($device, 'dbm', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], $descr, 1, $value, $options);
|
||||
|
||||
$descr = $name . ' Transmit Power';
|
||||
$oid_name = 'swSfpTxPower';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.5.'.$index;
|
||||
$type = $mib . '-' . $oid_name;
|
||||
$value = $entry[$oid_name];
|
||||
$descr = $name . ' Transmit Power';
|
||||
$oid_name = 'swSfpTxPower';
|
||||
$oid_num = '.1.3.6.1.4.1.1588.2.1.1.1.28.1.1.5.' . $index;
|
||||
$value = $entry[$oid_name];
|
||||
|
||||
discover_sensor_ng($device,'dbm', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], NULL, $descr, 1, $value, $options);
|
||||
discover_sensor_ng($device, 'dbm', $mib, $oid_name, $oid_num, $entry['connUnitPortIndex'], $descr, 1, $value, $options);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user