$entry) { $entry['index'] = $index; $match = ['measured_match' => ['entity_type' => 'port', 'field' => 'ifIndex', 'match' => '%index%']]; $options = entity_measured_match_definition($device, $match, $entry); $name = $options['port_label']; // Temperature $descr = $name . ' Temperature'; $class = 'temperature'; $oid_name = 'swDdmTemperature'; $oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.2.' . $index; $scale = 1; $value = $entry[$oid_name]; $limits = []; $limit_type = 'temperature'; $limits_oids = ['limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning', 'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning']; foreach ($limits_oids as $limit => $limit_oid) { // Prevent php8 fatal errors if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; } $limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale; } discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, array_merge($options, $limits)); // Voltage $descr = $name . ' Voltage'; $class = 'voltage'; $oid_name = 'swDdmVoltage'; $oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.3.' . $index; $scale = 1; $value = $entry[$oid_name]; $limits = []; $limit_type = 'voltage'; $limits_oids = ['limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning', 'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning']; foreach ($limits_oids as $limit => $limit_oid) { // Prevent php8 fatal errors if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; } $limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale; } discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, array_merge($options, $limits)); // Tx Bias $descr = $name . ' Tx Bias'; $class = 'current'; $oid_name = 'swDdmBiasCurrent'; $oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.4.' . $index; $scale = 0.001; $value = $entry[$oid_name]; $limits = []; $limit_type = 'bias'; $limits_oids = ['limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning', 'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning']; foreach ($limits_oids as $limit => $limit_oid) { // Prevent php8 fatal errors if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; } $limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale; } discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, array_merge($options, $limits)); // Tx Power $descr = $name . ' Tx Power'; $class = $power_unit === 'mw' ? 'power' : 'dbm'; $oid_name = 'swDdmTxPower'; $oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.5.' . $index; $scale = $power_unit === 'mw' ? 0.001 : 1; $value = $entry[$oid_name]; $limits = []; $limit_type = 'txPower'; $limits_oids = ['limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning', 'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning']; foreach ($limits_oids as $limit => $limit_oid) { // Prevent php8 fatal errors if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; } $limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale; } discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, array_merge($options, $limits)); // Rx Power $descr = $name . ' Rx Power'; $class = $power_unit === 'mw' ? 'power' : 'dbm'; $oid_name = 'swDdmRxPower'; $oid_num = '.1.3.6.1.4.1.171.12.72.2.1.1.1.6.' . $index; $scale = $power_unit === 'mw' ? 0.001 : 1; $value = $entry[$oid_name]; $limits = []; $limit_type = 'rxPower'; $limits_oids = ['limit_high' => 'swDdmHighAlarm', 'limit_high_warn' => 'swDdmHighWarning', 'limit_low' => 'swDdmLowAlarm', 'limit_low_warn' => 'swDdmLowWarning']; foreach ($limits_oids as $limit => $limit_oid) { // Prevent php8 fatal errors if (!is_numeric($oids_limit[$index][$limit_type][$limit_oid])) { continue; } $limits[$limit] = $oids_limit[$index][$limit_type][$limit_oid] * $scale; } discover_sensor_ng($device, $class, $mib, $oid_name, $oid_num, $index, $descr, $scale, $value, array_merge($options, $limits)); } // EOF