Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/nokia opticalpower multilane #13165

46 changes: 46 additions & 0 deletions includes/discovery/sensors/dbm/timos.inc.php
Expand Up @@ -47,3 +47,49 @@
discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'tx-' . $index, 'timos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $value, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured, $user_func);
}
}
//new code follows for multi-lane optics

$numlanes = snmpwalk_cache_multi_oid($device, 'tmnxPortEntry', [], 'TIMETRA-PORT-MIB', 'timos');
$lanes = snmpwalk_cache_multi_oid($device, 'tmnxDDMLaneEntry', [], 'TIMETRA-PORT-MIB', 'timos');

foreach ($numlanes as $index => $entry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we walk tmnxPortTable first and not just walk tmnxDDMLaneTable?

If you think we need to walk tmnxPortTable, you really only use tmnxPortSFPNumLanes, so just walk that.

if (is_numeric($entry['tmnxPortSFPNumLanes']) && $entry['tmnxPortSFPNumLanes'] > 1) {
for ($x = 1; $x <= $entry['tmnxPortSFPNumLanes']; $x++) {
$lane = $lanes[$index . '.' . $x];
if (is_numeric($lane['tmnxDDMLaneRxOpticalPower']) && $lane['tmnxDDMLaneRxOpticalPower'] != 0 && $lane['tmnxDDMLaneTxOutputPower'] != 0) {
$oid = '.1.3.6.1.4.1.6527.3.1.2.2.4.66.1.17.' . $index . '.' . $x;
$value = round(10 * log10($lane['tmnxDDMLaneRxOpticalPower'] / $divisor), 2);
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
$descr = $port_descr['ifName'] . ' RX Power Lane ' . $x;

$limit_low = round(10 * log10($lane['tmnxDDMLaneRxOpticalPwrLowAlarm'] / $divisor), 2);
murrant marked this conversation as resolved.
Show resolved Hide resolved
$limit = round(10 * log10($lane['tmnxDDMLaneRxOpticalPwrHiAlarm'] / $divisor), 2);

$warn_limit_low = $lane['tmnxDDMLaneRxOpticalPwrLowWarn'] / $divisor;
$warn_limit = $lane['tmnxDDMLaneRxOpticalPwrHiWarn'] / $divisor;

$current = $lane['tmnxDDMLaneRxOpticalPower'] / $divisor;
$entPhysicalIndex = $index;
$entPhysicalIndex_measured = 'ports';
discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'rx-' . $index . '.' . $x, 'timos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $value, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured, $user_func);
}
if (is_numeric($lane['tmnxDDMLaneTxOutputPower']) && $lane['tmnxDDMLaneTxOutputPower'] != 0 && $lane['tmnxDDMLaneRxOpticalPower'] != 0) {
$oid = '.1.3.6.1.4.1.6527.3.1.2.2.4.66.1.12.' . $index . '.' . $x;
$value = round(10 * log10($lane['tmnxDDMLaneTxOutputPower'] / $divisor), 2);
$port_descr = get_port_by_index_cache($device['device_id'], str_replace('1.', '', $index));
$descr = $port_descr['ifName'] . ' TX Power Lane ' . $x;

$limit_low = round(10 * log10($lane[' tmnxDDMLaneTxOutputPowerLowAlarm'] / $divisor), 2);
$limit = round(10 * log10($lane[' tmnxDDMLaneTxOutputPowerHiAlarm'] / $divisor), 2);

$warn_limit_low = $lane[' tmnxDDMLaneTxOutputPowerLowWarn'] / $divisor;
$warn_limit = $lane['tmnxDDMLaneTxOutputPowerHiWarn'] / $divisor;

$current = $lane['tmnxDDMLaneTxOutputPower'] / $divisor;
$entPhysicalIndex = $index;
$entPhysicalIndex_measured = 'ports';
discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'tx-' . $index . '.' . $x, 'timos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $value, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured, $user_func);
}
}
}
}