diff --git a/LibreNMS/Modules/Isis.php b/LibreNMS/Modules/Isis.php index 27eca2b610..b11de878a8 100644 --- a/LibreNMS/Modules/Isis.php +++ b/LibreNMS/Modules/Isis.php @@ -180,7 +180,7 @@ class Isis implements Module protected function parseAdjacencyTime($data): int { - return (int) max($data['isisISAdjLastUpTime'] ?? 1, 1) / 100; + return (int) (max($data['isisISAdjLastUpTime'] ?? 1, 1) / 100); } /** diff --git a/LibreNMS/OS/ArubaInstant.php b/LibreNMS/OS/ArubaInstant.php index 4499612cff..6047c7b1c9 100644 --- a/LibreNMS/OS/ArubaInstant.php +++ b/LibreNMS/OS/ArubaInstant.php @@ -264,7 +264,10 @@ class ArubaInstant extends OS implements protected function decodeChannel($channel): int { - return cast_number($channel) & 255; // mask off the channel width information + // Trim off everything not a digit, like channel "116e" + $channel = preg_replace("/\D/", '', $channel); + + return $channel & 255; // mask off the channel width information } /** diff --git a/LibreNMS/OS/Ciscosb.php b/LibreNMS/OS/Ciscosb.php index c00646fbaf..eeead4feab 100644 --- a/LibreNMS/OS/Ciscosb.php +++ b/LibreNMS/OS/Ciscosb.php @@ -62,6 +62,8 @@ class Ciscosb extends OS implements OSDiscovery if ($firmware) { $device->version .= ", Firmware $firmware"; } - $device->version = trim($device->version, ', '); + if ($device->version) { + $device->version = trim($device->version, ', '); + } } } diff --git a/LibreNMS/OS/Junose.php b/LibreNMS/OS/Junose.php index 948462b1f8..f29e42551b 100644 --- a/LibreNMS/OS/Junose.php +++ b/LibreNMS/OS/Junose.php @@ -31,7 +31,7 @@ class Junose extends \LibreNMS\OS { public function discoverOS(Device $device): void { - if (strpos($device->sysDescr, 'olive')) { + if (is_string($device->sysDescr) && strpos($device->sysDescr, 'olive')) { $device->hardware = 'Olive'; return; diff --git a/LibreNMS/OS/Lcos.php b/LibreNMS/OS/Lcos.php index 043862152b..30a7581339 100644 --- a/LibreNMS/OS/Lcos.php +++ b/LibreNMS/OS/Lcos.php @@ -226,7 +226,7 @@ class Lcos extends OS implements 'lcos', $bssid, 'CCQ ' . $entry['lcsStatusWlanCompetingNetworksEntryInterpointPeerName'] . " $bssid", - $entry['lcsStatusWlanCompetingNetworksEntryPhySigal'] + $entry['lcsStatusWlanCompetingNetworksEntryPhySignal'] ); } diff --git a/LibreNMS/OS/Shared/Cisco.php b/LibreNMS/OS/Shared/Cisco.php index c1ac8fdc4a..c5009037b1 100755 --- a/LibreNMS/OS/Shared/Cisco.php +++ b/LibreNMS/OS/Shared/Cisco.php @@ -118,7 +118,7 @@ class Cisco extends OS implements $hardware = $data[1000]['entPhysicalModelName']; } elseif (empty($hardware) && ! empty($data[1000]['entPhysicalContainedIn'])) { $hardware = $data[$data[1000]['entPhysicalContainedIn']]['entPhysicalName']; - } elseif ((preg_match('/stack/i', $hardware) || empty($hardware)) && ! empty($data[1001]['entPhysicalModelName'])) { + } elseif ((preg_match('/stack/i', $hardware ?? '') || empty($hardware)) && ! empty($data[1001]['entPhysicalModelName'])) { $hardware = $data[1001]['entPhysicalModelName']; } elseif (empty($hardware) && ! empty($data[1001]['entPhysicalContainedIn'])) { $hardware = $data[$data[1001]['entPhysicalContainedIn']]['entPhysicalName']; @@ -294,7 +294,7 @@ class Cisco extends OS implements * Could be dynamically changed to appropriate value if config had pol interval value */ $qfp_usage_oid = '.1.3.6.1.4.1.9.9.715.1.1.6.1.14.' . $entQfpPhysicalIndex . '.3'; - $qfp_usage = $entry['fiveMinute']; + $qfp_usage = $entry['fiveMinute'] ?? null; if ($entQfpPhysicalIndex) { $qfp_descr = $this->getCacheByIndex('entPhysicalName', 'ENTITY-MIB')[$entQfpPhysicalIndex]; diff --git a/LibreNMS/OS/Shared/Foundry.php b/LibreNMS/OS/Shared/Foundry.php index b0450fbf30..b0be7f0774 100644 --- a/LibreNMS/OS/Shared/Foundry.php +++ b/LibreNMS/OS/Shared/Foundry.php @@ -61,8 +61,12 @@ class Foundry extends OS implements ProcessorDiscovery continue; } - $module_description = $module_descriptions[$entry['snAgentCpuUtilSlotNum']]; - [$module_description] = explode(' ', $module_description); + $module_description = null; + if (isset($module_descriptions[$entry['snAgentCpuUtilSlotNum']])) { + $module_description = $module_descriptions[$entry['snAgentCpuUtilSlotNum']]; + [$module_description] = explode(' ', $module_description); + } + $descr = "Slot {$entry['snAgentCpuUtilSlotNum']} $module_description [{$entry['snAgentCpuUtilSlotNum']}]"; $processors[] = Processor::discover( diff --git a/LibreNMS/OS/Traits/CiscoCellular.php b/LibreNMS/OS/Traits/CiscoCellular.php index 45c2572133..b2292b226d 100644 --- a/LibreNMS/OS/Traits/CiscoCellular.php +++ b/LibreNMS/OS/Traits/CiscoCellular.php @@ -61,7 +61,7 @@ trait CiscoCellular 'ios', $index, 'RSSI: ' . $this->profileApn($index), - $entry['c3gCurrentGsmRssi.1'] + $entry['c3gCurrentGsmRssi'] ); } @@ -87,7 +87,7 @@ trait CiscoCellular 'ios', $index, 'SNR: ' . $this->profileApn($index), - $entry['cwceLteCurrSnr.1'], + $entry['cwceLteCurrSnr'], 1, 10 ); @@ -115,7 +115,7 @@ trait CiscoCellular 'ios', $index, 'RSRQ: ' . $this->profileApn($index), - $entry['cwceLteCurrRsrq.1'], + $entry['cwceLteCurrRsrq'], 1, 10 ); @@ -143,7 +143,7 @@ trait CiscoCellular 'ios', $index, 'RSRP: ' . $this->profileApn($index), - $entry['cwceLteCurrRsrp.1'] + $entry['cwceLteCurrRsrp'] ); } @@ -169,7 +169,7 @@ trait CiscoCellular 'ios', $index, 'ChannelRx: ' . $this->profileApn($index), - $entry['c3gGsmChannelNumber.1'] + $entry['c3gGsmChannelNumber'] ); } @@ -195,7 +195,7 @@ trait CiscoCellular 'ios', $index, 'Cell: ' . $this->profileApn($index), - $entry['c3gGsmCurrentCellId.1'] + $entry['c3gGsmCurrentCellId'] ); } diff --git a/includes/common.php b/includes/common.php index b1af79c039..fadc37e513 100644 --- a/includes/common.php +++ b/includes/common.php @@ -636,7 +636,7 @@ function get_port_id($ports_mapped, $port, $port_association_mode) $maps = $ports_mapped['maps']; if (in_array($port_association_mode, ['ifIndex', 'ifName', 'ifDescr', 'ifAlias'])) { - $port_id = $maps[$port_association_mode][$port[$port_association_mode]]; + $port_id = $maps[$port_association_mode][$port[$port_association_mode]] ?? null; } return $port_id; diff --git a/includes/discovery/ports.inc.php b/includes/discovery/ports.inc.php index 72fc729174..befbb5efdb 100644 --- a/includes/discovery/ports.inc.php +++ b/includes/discovery/ports.inc.php @@ -86,7 +86,7 @@ $default_port_group = Config::get('default_port_group'); // New interface detection foreach ($port_stats as $ifIndex => $snmp_data) { $snmp_data['ifIndex'] = $ifIndex; // Store ifIndex in port entry - $snmp_data['ifAlias'] = StringHelpers::inferEncoding($snmp_data['ifAlias']); + $snmp_data['ifAlias'] = StringHelpers::inferEncoding($snmp_data['ifAlias'] ?? null); // Get port_id according to port_association_mode used for this device $port_id = get_port_id($ports_mapped, $snmp_data, $port_association_mode); @@ -95,7 +95,7 @@ foreach ($port_stats as $ifIndex => $snmp_data) { port_fill_missing_and_trim($snmp_data, $device); // Port newly discovered? - if (! is_array($ports_db[$port_id])) { + if (! isset($ports_db[$port_id]) || ! is_array($ports_db[$port_id])) { $snmp_data['device_id'] = $device['device_id']; $port_id = dbInsert($snmp_data, 'ports'); @@ -121,7 +121,7 @@ foreach ($port_stats as $ifIndex => $snmp_data) { } } else { // Port vanished (mark as deleted) - if (is_array($ports_db[$port_id])) { + if (isset($ports_db[$port_id]) && is_array($ports_db[$port_id])) { if ($ports_db[$port_id]['deleted'] != 1) { dbUpdate(['deleted' => 1], 'ports', '`port_id` = ?', [$port_id]); $ports_db[$port_id]['deleted'] = 1; diff --git a/includes/discovery/sensors/ber/infinera-groove.inc.php b/includes/discovery/sensors/ber/infinera-groove.inc.php index b828c90143..1dd8c0230b 100644 --- a/includes/discovery/sensors/ber/infinera-groove.inc.php +++ b/includes/discovery/sensors/ber/infinera-groove.inc.php @@ -25,7 +25,7 @@ * Modified for FEC, Magnus Bergroth */ foreach ($pre_cache['infineragroove_portTable'] as $index => $data) { - if (is_numeric($data['ochOsPreFecBer']) && $data['ochOsPreFecBer'] > 0) { + if (isset($data['ochOsPreFecBer']) && is_numeric($data['ochOsPreFecBer']) && $data['ochOsPreFecBer'] > 0) { $descr = $data['portAlias'] . ' PreFecBer'; $oid = '.1.3.6.1.4.1.42229.1.2.4.1.19.1.1.26.' . $index; $value = $data['ochOsPreFecBer']; diff --git a/includes/discovery/sensors/chromatic_dispersion/infinera-groove.inc.php b/includes/discovery/sensors/chromatic_dispersion/infinera-groove.inc.php index d86735ab72..909b5ac6b0 100644 --- a/includes/discovery/sensors/chromatic_dispersion/infinera-groove.inc.php +++ b/includes/discovery/sensors/chromatic_dispersion/infinera-groove.inc.php @@ -23,7 +23,7 @@ * @author Nick Hilliard */ foreach ($pre_cache['infineragroove_portTable'] as $index => $data) { - if (is_numeric($data['ochOsCD']) && $data['ochOsCD'] != -99) { + if (isset($data['ochOsCD']) && is_numeric($data['ochOsCD']) && $data['ochOsCD'] != -99) { $descr = $data['portAlias'] . ' CD'; $oid = '.1.3.6.1.4.1.42229.1.2.4.1.19.1.1.23.' . $index; $value = $data['ochOsCD']; diff --git a/includes/discovery/sensors/cisco-entity-sensor.inc.php b/includes/discovery/sensors/cisco-entity-sensor.inc.php index c4579ad13d..0619d65bc1 100644 --- a/includes/discovery/sensors/cisco-entity-sensor.inc.php +++ b/includes/discovery/sensors/cisco-entity-sensor.inc.php @@ -63,7 +63,7 @@ if ($device['os_group'] == 'cisco') { } // Set description based on measured entity if it exists - if (is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) { + if (isset($entry['entSensorMeasuredEntity']) && is_numeric($entry['entSensorMeasuredEntity']) && $entry['entSensorMeasuredEntity']) { $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalName']; if (! $measured_descr) { $measured_descr = $entity_array[$entry['entSensorMeasuredEntity']]['entPhysicalDescr']; @@ -136,7 +136,7 @@ if ($device['os_group'] == 'cisco') { $warn_limit_low = null; // Check thresholds for this entry (bit dirty, but it works!) - if (is_array($t_oids[$index])) { + if (isset($t_oids[$index]) && is_array($t_oids[$index])) { foreach ($t_oids[$index] as $t_index => $key) { // Skip invalid treshold values if ($key['entSensorThresholdValue'] == '-32768') { diff --git a/includes/discovery/sensors/count/cisco.inc.php b/includes/discovery/sensors/count/cisco.inc.php index 724371a1bb..9ae11f3768 100644 --- a/includes/discovery/sensors/count/cisco.inc.php +++ b/includes/discovery/sensors/count/cisco.inc.php @@ -26,9 +26,10 @@ foreach ($tables as $tablevalue) { $state_name = $tablevalue['state_name']; foreach ($temp as $index => $entry) { //Discover Sensors - $descr = ucwords($temp[$index][$tablevalue['descr']]); if ($state_name == 'c3gGsmNumberOfNearbyCell' || $state_name == 'cwceLteCurrOperatingBand') { $descr = snmp_get($device, 'entPhysicalName.' . $index, '-Oqv', 'ENTITY-MIB') . ' - ' . $tablevalue['descr']; + } else { + $descr = ucwords($temp[$index][$tablevalue['descr']]); } discover_sensor($valid['sensor'], 'count', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index][$tablevalue['state_name']], 'snmp', $index); } diff --git a/includes/discovery/sensors/current/ciscosb.inc.php b/includes/discovery/sensors/current/ciscosb.inc.php index d6206db7bc..f234e15563 100644 --- a/includes/discovery/sensors/current/ciscosb.inc.php +++ b/includes/discovery/sensors/current/ciscosb.inc.php @@ -16,14 +16,17 @@ $multiplier = 1; $divisor = 1000000; foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) { foreach ($ciscosb_data as $key => $value) { + if (! isset($value['rlPhyTestTableTransceiverTemp']) || $value['rlPhyTestTableTransceiverTemp'] == 0) { + continue; + } $oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.' . $index . '.7'; $sensor_type = 'rlPhyTestTableTxBias'; $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_descr['ifDescr'] . ' Bias Current'); + $descr = trim(($port_descr['ifDescr'] ?? '') . ' Bias Current'); $current = $value['rlPhyTestTableTxBias'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; - if (is_numeric($current) && ($value['rlPhyTestTableTransceiverTemp'] != 0)) { + if (is_numeric($current)) { discover_sensor($valid['sensor'], 'current', $device, $oid, $index, $sensor_type, $descr, $divisor, $multiplier, null, null, null, null, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/current/comware.inc.php b/includes/discovery/sensors/current/comware.inc.php index 1e61db7455..6bb930c8bd 100644 --- a/includes/discovery/sensors/current/comware.inc.php +++ b/includes/discovery/sensors/current/comware.inc.php @@ -18,6 +18,11 @@ $divisor = 100000; $divisor_alarm = 1000000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverBiasCurrent']) && $entry['hh3cTransceiverBiasCurrent'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { + $interface = get_port_by_index_cache($device['device_id'], $index); + if ($interface['ifAdminStatus'] != 'up') { + continue; + } + $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.17.' . $index; $limit_low = $entry['hh3cTransceiverBiasLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverBiasLoWarn'] / $divisor_alarm; @@ -26,10 +31,8 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $current = $entry['hh3cTransceiverBiasCurrent'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; - $interface = get_port_by_index_cache($device['device_id'], $index); - if ($interface['ifAdminStatus'] == 'up') { - $descr = makeshortif($interface['ifDescr']) . ' Bias Current'; - discover_sensor($valid['sensor'], 'current', $device, $oid, 'bias-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); - } + + $descr = makeshortif($interface['ifDescr']) . ' Bias Current'; + discover_sensor($valid['sensor'], 'current', $device, $oid, 'bias-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/dbm/ciscosb.inc.php b/includes/discovery/sensors/dbm/ciscosb.inc.php index 615ff61b99..cc54ec00fa 100644 --- a/includes/discovery/sensors/dbm/ciscosb.inc.php +++ b/includes/discovery/sensors/dbm/ciscosb.inc.php @@ -16,21 +16,21 @@ $multiplier = 1; $divisor = 1000; foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) { foreach ($ciscosb_data as $key => $value) { - if (is_numeric($value['rlPhyTestTableTxOutput']) && ($value['rlPhyTestTableRxOpticalPower'] != 0)) { + if (isset($value['rlPhyTestTableTxOutput']) && is_numeric($value['rlPhyTestTableTxOutput']) && ($value['rlPhyTestTableRxOpticalPower'] != 0)) { $oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.' . $index . '.8'; $sensor_type = 'rlPhyTestTableTxOutput'; $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_descr['ifDescr'] . ' Transmit Power'); + $descr = trim(($port_descr['ifDescr'] ?? null) . ' Transmit Power'); $dbm = $value['rlPhyTestTableTxOutput'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'tx-' . $index, $sensor_type, $descr, $divisor, $multiplier, null, null, null, null, $dbm, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } - if (is_numeric($value['rlPhyTestTableRxOpticalPower']) && ($value['rlPhyTestTableTxOutput'] != 0)) { + if (isset($value['rlPhyTestTableRxOpticalPower']) && is_numeric($value['rlPhyTestTableRxOpticalPower']) && ($value['rlPhyTestTableTxOutput'] != 0)) { $oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.' . $index . '.9'; $sensor_type = 'rlPhyTestTableRxOpticalPower'; $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_descr['ifDescr'] . ' Receive Power'); + $descr = trim(($port_descr['ifDescr'] ?? null) . ' Receive Power'); $dbm = $value['rlPhyTestTableRxOpticalPower'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; diff --git a/includes/discovery/sensors/dbm/comware.inc.php b/includes/discovery/sensors/dbm/comware.inc.php index 3ce5012239..f40fe1e7c7 100644 --- a/includes/discovery/sensors/dbm/comware.inc.php +++ b/includes/discovery/sensors/dbm/comware.inc.php @@ -17,6 +17,11 @@ $multiplier = 1; $divisor = 100; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverCurRXPower']) && $entry['hh3cTransceiverCurRXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { + $interface = get_port_by_index_cache($device['device_id'], $index); + if ($interface['ifAdminStatus'] != 'up') { + continue; + } + $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.12.' . $index; $limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoAlarm'] / 10), 2); $warn_limit_low = round(uw_to_dbm($entry['hh3cTransceiverRcvPwrLoWarn'] / 10), 2); @@ -25,11 +30,8 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $current = $entry['hh3cTransceiverCurRXPower'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; - $interface = get_port_by_index_cache($device['device_id'], $index); - if ($interface['ifAdminStatus'] == 'up') { - $descr = makeshortif($interface['ifDescr']) . ' Receive Power'; - discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'rx-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); - } + $descr = makeshortif($interface['ifDescr']) . ' Receive Power'; + discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'rx-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } if (is_numeric($entry['hh3cTransceiverCurTXPower']) && $entry['hh3cTransceiverCurTXPower'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { diff --git a/includes/discovery/sensors/dbm/junos.inc.php b/includes/discovery/sensors/dbm/junos.inc.php index cc96d8a89f..2d46920251 100644 --- a/includes/discovery/sensors/dbm/junos.inc.php +++ b/includes/discovery/sensors/dbm/junos.inc.php @@ -43,7 +43,7 @@ foreach ($pre_cache['junos_oids'] as $index => $entry) { $entPhysicalIndex_measured = 'ports'; discover_sensor($valid['sensor'], 'dbm', $device, $oid, 'tx-' . $index, 'junos', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } - if (is_numeric($entry['jnxDomCurrentModuleLaneCount']) && $entry['jnxDomCurrentModuleLaneCount'] > 1) { + if (isset($entry['jnxDomCurrentModuleLaneCount']) && is_numeric($entry['jnxDomCurrentModuleLaneCount']) && $entry['jnxDomCurrentModuleLaneCount'] > 1) { for ($x = 0; $x < $entry['jnxDomCurrentModuleLaneCount']; $x++) { $lane = $pre_cache['junos_multilane_oids'][$index . '.' . $x]; if (is_numeric($lane['jnxDomCurrentLaneRxLaserPower']) && $lane['jnxDomCurrentLaneRxLaserPower'] != 0 && $lane['jnxDomCurrentLaneTxLaserOutputPower'] != 0) { diff --git a/includes/discovery/sensors/delay/infinera-groove.inc.php b/includes/discovery/sensors/delay/infinera-groove.inc.php index 97e3a540fa..8da76e05f9 100644 --- a/includes/discovery/sensors/delay/infinera-groove.inc.php +++ b/includes/discovery/sensors/delay/infinera-groove.inc.php @@ -25,7 +25,7 @@ * Modified for DGD, Magnus Bergroth */ foreach ($pre_cache['infineragroove_portTable'] as $index => $data) { - if (is_numeric($data['ochOsDGD']) && $data['ochOsDGD'] != 0) { + if (isset($data['ochOsDGD']) && is_numeric($data['ochOsDGD']) && $data['ochOsDGD'] != 0) { $descr = $data['portAlias'] . ' Differential Group Delay'; $oid = '.1.3.6.1.4.1.42229.1.2.4.1.19.1.1.22.' . $index; $value = $data['ochOsDGD']; diff --git a/includes/discovery/sensors/entity-sensor.inc.php b/includes/discovery/sensors/entity-sensor.inc.php index f20537d965..e4c8ec1a46 100644 --- a/includes/discovery/sensors/entity-sensor.inc.php +++ b/includes/discovery/sensors/entity-sensor.inc.php @@ -48,6 +48,14 @@ if (! empty($entity_oids)) { $low_warn_limit = null; $warn_limit = null; $high_limit = null; + $group = null; + $type = null; + $oid = null; + $descr = null; + $divisor = null; + $multiplier = null; + $current = null; + $entPhysicalIndex = null; // Fix for Cisco ASR920, 15.5(2)S if ($entry['entPhySensorType'] == 'other' && Str::contains($entity_array[$index]['entPhysicalName'], ['Rx Power Sensor', 'Tx Power Sensor'])) { @@ -64,7 +72,7 @@ if (! empty($entity_oids)) { } elseif (count($card) === 4) { $card = $card[0] . $card[1] . '00'; } - $descr = ucwords($entity_array[$card]['entPhysicalName']) . ' ' . ucwords($entity_array[$index]['entPhysicalDescr']); + $descr = ucwords($entity_array[$card]['entPhysicalName'] ?? '') . ' ' . ucwords($entity_array[$index]['entPhysicalDescr'] ?? ''); } else { $descr = ucwords($entity_array[$index]['entPhysicalName']); } @@ -75,7 +83,13 @@ if (! empty($entity_oids)) { if ($device['os'] === 'arista_eos') { $descr = $entity_array[$index]['entPhysicalDescr']; if (preg_match('/(Input|Output) (voltage|current) sensor/i', $descr) || Str::startsWith($descr, 'Power supply') || preg_match('/^(Power Supply|Hotspot|Inlet|Board)/i', $descr)) { - $descr = ucwords($entity_array[substr_replace($index, '000', -3)]['entPhysicalDescr']) . ' ' . preg_replace('/(Voltage|Current|Power Supply) Sensor$/i', '', ucwords($entity_array[$index]['entPhysicalDescr'])); + $descr = (ucwords($entity_array[substr_replace($index, '000', -3)]['entPhysicalDescr'] ?? '')) + . ' ' + . preg_replace( + '/(Voltage|Current|Power Supply) Sensor$/i', + '', + ucwords($entity_array[$index]['entPhysicalDescr']) + ); } if (preg_match('/(temp|temperature) sensor$/i', $descr)) { $descr = preg_replace('/(temp|temperature) sensor$/i', '', $descr); @@ -217,7 +231,7 @@ if (! empty($entity_oids)) { // End grouping sensors } $descr = trim($descr); - discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity'], null, $group); + discover_sensor($valid['sensor'], $type, $device, $oid, $index, 'entity-sensor', $descr, $divisor, $multiplier, $low_limit, $low_warn_limit, $warn_limit, $high_limit, $current, 'snmp', $entPhysicalIndex, $entry['entSensorMeasuredEntity'] ?? null, null, $group); } }//end if }//end foreach diff --git a/includes/discovery/sensors/fanspeed/apc.inc.php b/includes/discovery/sensors/fanspeed/apc.inc.php index 79276da685..e4af6fa897 100644 --- a/includes/discovery/sensors/fanspeed/apc.inc.php +++ b/includes/discovery/sensors/fanspeed/apc.inc.php @@ -25,8 +25,8 @@ foreach ($pre_cache['cooling_unit_analog'] as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index; $descr = $data['coolingUnitStatusAnalogDescription']; - $scale = $data['coolingUnitStatusAnalogScale']; - $value = $data['coolingUnitStatusAnalogValue']; + $scale = $data['coolingUnitStatusAnalogScale'] ?? null; + $value = $data['coolingUnitStatusAnalogValue'] ?? null; if (preg_match('/Fan Speed/', $descr) && $data['coolingUnitStatusAnalogUnits'] == '%' && $value >= 0) { discover_sensor($valid['sensor'], 'fanspeed', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value); } diff --git a/includes/discovery/sensors/gw-eydfa.inc.php b/includes/discovery/sensors/gw-eydfa.inc.php index 049e05f256..a9d084d334 100644 --- a/includes/discovery/sensors/gw-eydfa.inc.php +++ b/includes/discovery/sensors/gw-eydfa.inc.php @@ -79,7 +79,7 @@ foreach (explode("\n", $oids) as $data) { unset($oids, $split_oid, $index, $divisor, $descr, $low_limit, $low_warn, $high_warn, $sensor_index); } -$oids = snmp_walk($device, 'oaDCPowerTable', '-Osq', 'NSCRTV-HFCEMS-OPTICALAMPLIFIER-MIB'); +$oids = trim(snmp_walk($device, 'oaDCPowerTable', '-Osq', 'NSCRTV-HFCEMS-OPTICALAMPLIFIER-MIB')); d_echo($oids . "\n"); if ($oids) { diff --git a/includes/discovery/sensors/humidity/liebert.inc.php b/includes/discovery/sensors/humidity/liebert.inc.php index ed4b12f46d..ea46547408 100644 --- a/includes/discovery/sensors/humidity/liebert.inc.php +++ b/includes/discovery/sensors/humidity/liebert.inc.php @@ -25,14 +25,14 @@ $lib_data = snmpwalk_cache_oid($device, 'lgpEnvHumidityEntryRel', [], 'LIEBERT-GP-ENVIRONMENTAL-MIB'); foreach ($lib_data as $index => $data) { - if (is_numeric($data['lgpEnvHumidityMeasurementRelTenths'])) { + if (isset($data['lgpEnvHumidityMeasurementRelTenths']) && is_numeric($data['lgpEnvHumidityMeasurementRelTenths'])) { $oid = '.1.3.6.1.4.1.476.1.42.3.4.2.2.3.1.50.' . $index; $low_limit = $data['lgpEnvHumidityLowThresholdRelTenths']; $high_limit = $data['lgpEnvHumidityHighThresholdRelTenths']; $current = $data['lgpEnvHumidityMeasurementRelTenths']; $divisor = 10; $new_index = 'lgpEnvHumidityMeasurementRelTenths.' . $index; - } elseif (is_numeric($data['lgpEnvHumidityMeasurementRel'])) { + } elseif (isset($data['lgpEnvHumidityMeasurementRel']) && is_numeric($data['lgpEnvHumidityMeasurementRel'])) { $oid = '.1.3.6.1.4.1.476.1.42.3.4.2.2.3.1.3.' . $index; $low_limit = $data['lgpEnvHumidityLowThresholdRel']; $high_limit = $data['lgpEnvHumidityHighThresholdRel']; diff --git a/includes/discovery/sensors/load/infinera-groove.inc.php b/includes/discovery/sensors/load/infinera-groove.inc.php index ad9e54bf71..b16d4fae2b 100644 --- a/includes/discovery/sensors/load/infinera-groove.inc.php +++ b/includes/discovery/sensors/load/infinera-groove.inc.php @@ -23,7 +23,7 @@ * @author Nick Hilliard */ foreach ($pre_cache['infineragroove_slotTable'] as $index => $data) { - if (is_numeric($data['cardFanSpeedRate']) && $data['cardFanSpeedRate'] != -99) { + if (isset($data['cardFanSpeedRate']) && is_numeric($data['cardFanSpeedRate']) && $data['cardFanSpeedRate'] != -99) { $infinera_slot = 'slot-' . str_replace('.', '/', $index); $descr = 'Chassis fan ' . $infinera_slot; $oid = '.1.3.6.1.4.1.42229.1.2.3.3.1.1.7.' . $index; diff --git a/includes/discovery/sensors/load/rfc1628.inc.php b/includes/discovery/sensors/load/rfc1628.inc.php index 6a73a805d1..b9dfb50259 100644 --- a/includes/discovery/sensors/load/rfc1628.inc.php +++ b/includes/discovery/sensors/load/rfc1628.inc.php @@ -14,7 +14,7 @@ foreach ($load_data as $index => $data) { $value = $data['upsOutputPercentLoad']; } - $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'], 'load', $load_oid); + $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'] ?? 0, 'load', $load_oid); $descr = 'Percentage load'; if (count($load_data) > 1) { $descr .= " $index"; diff --git a/includes/discovery/sensors/power/apc.inc.php b/includes/discovery/sensors/power/apc.inc.php index 3949e174c1..1e5c685b76 100644 --- a/includes/discovery/sensors/power/apc.inc.php +++ b/includes/discovery/sensors/power/apc.inc.php @@ -25,8 +25,8 @@ foreach ($pre_cache['cooling_unit_analog'] as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index; $descr = $data['coolingUnitStatusAnalogDescription']; - $scale = $data['coolingUnitStatusAnalogScale']; - $value = $data['coolingUnitStatusAnalogValue']; + $scale = $data['coolingUnitStatusAnalogScale'] ?? null; + $value = $data['coolingUnitStatusAnalogValue'] ?? null; if (preg_match('/Cool/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'kW' && $value >= 0) { discover_sensor($valid['sensor'], 'power', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value); } diff --git a/includes/discovery/sensors/power/ciscosb.inc.php b/includes/discovery/sensors/power/ciscosb.inc.php index 2d329db8a1..f21847baa7 100644 --- a/includes/discovery/sensors/power/ciscosb.inc.php +++ b/includes/discovery/sensors/power/ciscosb.inc.php @@ -19,7 +19,7 @@ if (is_array($temp)) { if (is_numeric($temp[$index]['rlPethPsePortOutputPower']) && $temp[$index]['rlPethPsePortOutputPower'] > 0) { $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); $descr = trim($port_descr['ifDescr'] . ' PoE'); - $highlimit = $temp[$index]['rlPethPsePortOperPowerLimit'] / $divisor; + $highlimit = isset($temp[$index]['rlPethPsePortOperPowerLimit']) ? $temp[$index]['rlPethPsePortOperPowerLimit'] / $divisor : null; discover_sensor($valid['sensor'], 'power', $device, $cur_oid . $index, $index, 'ciscosb', $descr, $divisor, '1', null, null, null, $highlimit, $temp[$index]['rlPethPsePortOutputPower'] / $divisor, 'snmp', $index); } } diff --git a/includes/discovery/sensors/pre-cache/ifotec.inc.php b/includes/discovery/sensors/pre-cache/ifotec.inc.php index 73cd2e5652..71ca4cf71b 100644 --- a/includes/discovery/sensors/pre-cache/ifotec.inc.php +++ b/includes/discovery/sensors/pre-cache/ifotec.inc.php @@ -39,7 +39,6 @@ if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.21362.100.')) { // .ifoTemperatureTable.ifoTemperatureEntry. $data = snmp_walk($device, 'ifoTemperatureEntry', '-OQn', 'IFOTEC-SMI'); - var_dump($data); foreach (explode(PHP_EOL, $data) as $line) { [$oid, $value] = explode(' = ', $line); diff --git a/includes/discovery/sensors/pre-cache/infinera-groove.inc.php b/includes/discovery/sensors/pre-cache/infinera-groove.inc.php index 0b1dfda25e..43eb23599f 100644 --- a/includes/discovery/sensors/pre-cache/infinera-groove.inc.php +++ b/includes/discovery/sensors/pre-cache/infinera-groove.inc.php @@ -22,7 +22,7 @@ * @copyright 2019 Nick Hilliard * @author Nick Hilliard */ -if (! is_array($pre_cache['infineragroove_portTable'])) { +if (! isset($pre_cache['infineragroove_portTable']) || ! is_array($pre_cache['infineragroove_portTable'])) { echo 'Caching OIDs:'; $pre_cache['infineragroove_portTable'] = []; echo ' portTable'; @@ -44,7 +44,7 @@ foreach (array_keys($pre_cache['infineragroove_portTable']) as $index) { unset($indexids); } -if (! is_array($pre_cache['infineragroove_slotTable'])) { +if (! isset($pre_cache['infineragroove_slotTable']) || ! is_array($pre_cache['infineragroove_slotTable'])) { $pre_cache['infineragroove_slotTable'] = []; echo ' slotTable'; $pre_cache['infineragroove_slotTable'] = snmpwalk_cache_multi_oid($device, 'slotTable', $pre_cache['infineragroove_slotTable'], 'CORIANT-GROOVE-MIB'); diff --git a/includes/discovery/sensors/pre-cache/ipoman.inc.php b/includes/discovery/sensors/pre-cache/ipoman.inc.php index 85acd0b187..6858770980 100644 --- a/includes/discovery/sensors/pre-cache/ipoman.inc.php +++ b/includes/discovery/sensors/pre-cache/ipoman.inc.php @@ -1,10 +1,10 @@ */ foreach ($pre_cache['infineragroove_portTable'] as $index => $data) { - if (is_numeric($data['ochOsOSNR']) && $data['ochOsOSNR'] != -99) { + if (isset($data['ochOsOSNR']) && is_numeric($data['ochOsOSNR']) && $data['ochOsOSNR'] != -99) { $descr = $data['portAlias'] . ' Optical SNR'; $oid = '.1.3.6.1.4.1.42229.1.2.4.1.19.1.1.24.' . $index; $value = $data['ochOsOSNR']; diff --git a/includes/discovery/sensors/state/apc.inc.php b/includes/discovery/sensors/state/apc.inc.php index 0b587f9df3..d63d9a9a80 100644 --- a/includes/discovery/sensors/state/apc.inc.php +++ b/includes/discovery/sensors/state/apc.inc.php @@ -38,8 +38,8 @@ foreach ($cooling_status as $index => $data) { $tmp_states = explode(',', $data['coolingUnitStatusDiscreteIntegerReferenceKey']); $states = []; - foreach ($tmp_states as $k => $ref) { - preg_match('/([\w]+)\\(([\d]+)\\)/', $ref, $matches); + foreach ($tmp_states as $ref) { + preg_match('/([\w]+) ?\\(([\d]+)\\)/', $ref, $matches); $nagios_state = get_nagios_state($matches[1]); $states[] = ['value' => 0, 'generic' => $nagios_state, 'graph' => 0, $matches[2], 'descr' => $matches[1]]; } diff --git a/includes/discovery/sensors/state/ciscosb.inc.php b/includes/discovery/sensors/state/ciscosb.inc.php index 192bcd97fa..729fa0b608 100644 --- a/includes/discovery/sensors/state/ciscosb.inc.php +++ b/includes/discovery/sensors/state/ciscosb.inc.php @@ -26,7 +26,7 @@ if (is_array($temp)) { foreach ($temp as $index => $entry) { $port_data = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_data['ifDescr'] . ' Suspended Status'); + $descr = trim(($port_data['ifDescr'] ?? '') . ' Suspended Status'); if (Str::contains($descr, ['ethernet', 'Ethernet']) && $port_data['ifOperStatus'] !== 'notPresent') { //Discover Sensors discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, $index, $state_name, $descr, 1, 1, null, null, null, null, $temp[$index]['swIfOperSuspendedStatus'], 'snmp', $index); diff --git a/includes/discovery/sensors/temperature/apc.inc.php b/includes/discovery/sensors/temperature/apc.inc.php index df8c518988..8bd2b0ba41 100644 --- a/includes/discovery/sensors/temperature/apc.inc.php +++ b/includes/discovery/sensors/temperature/apc.inc.php @@ -165,8 +165,8 @@ foreach ($cooling_unit as $index => $data) { foreach ($pre_cache['cooling_unit_analog'] as $index => $data) { $cur_oid = '.1.3.6.1.4.1.318.1.1.27.1.4.1.2.1.3.' . $index; $descr = $data['coolingUnitStatusAnalogDescription']; - $scale = $data['coolingUnitStatusAnalogScale']; - $value = $data['coolingUnitStatusAnalogValue']; + $scale = $data['coolingUnitStatusAnalogScale'] ?? null; + $value = $data['coolingUnitStatusAnalogValue'] ?? null; if (preg_match('/Temperature/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'C' && $value >= 0) { discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value); } diff --git a/includes/discovery/sensors/temperature/cisco.inc.php b/includes/discovery/sensors/temperature/cisco.inc.php index bb5f1d422d..dcd7f93587 100644 --- a/includes/discovery/sensors/temperature/cisco.inc.php +++ b/includes/discovery/sensors/temperature/cisco.inc.php @@ -14,6 +14,9 @@ $temp = snmpwalk_cache_multi_oid($device, 'ciscoEnvMonTemperatureStatusTable', [ if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.9.13.1.3.1.3.'; foreach ($temp as $index => $entry) { + if (! isset($temp[$index]['ciscoEnvMonTemperatureStatusValue'])) { + continue; + } if ($temp[$index]['ciscoEnvMonTemperatureState'] != 'notPresent' && ! empty($temp[$index]['ciscoEnvMonTemperatureStatusDescr'])) { $descr = ucwords($temp[$index]['ciscoEnvMonTemperatureStatusDescr']); discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid . $index, $index, 'cisco', $descr, '1', '1', null, null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], $temp[$index]['ciscoEnvMonTemperatureStatusValue'], 'snmp', $index); @@ -26,6 +29,6 @@ if (is_array($temp)) { $cur_oid = '.1.3.6.1.4.1.9.9.661.1.1.1.12.'; foreach ($temp as $index => $entry) { $descr = snmp_get($device, 'entPhysicalName.' . $index, '-Oqv', 'ENTITY-MIB'); - discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid . $index, $index, 'cisco', $descr, '1', '1', null, null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'], $temp[$index]['c3gModemTemperature'], 'snmp', $index); + discover_sensor($valid['sensor'], 'temperature', $device, $cur_oid . $index, $index, 'cisco', $descr, '1', '1', null, null, null, $temp[$index]['ciscoEnvMonTemperatureThreshold'] ?? null, $temp[$index]['c3gModemTemperature'], 'snmp', $index); } } diff --git a/includes/discovery/sensors/temperature/ciscosb.inc.php b/includes/discovery/sensors/temperature/ciscosb.inc.php index ca9537da12..de80ccde9f 100644 --- a/includes/discovery/sensors/temperature/ciscosb.inc.php +++ b/includes/discovery/sensors/temperature/ciscosb.inc.php @@ -16,10 +16,14 @@ $multiplier = 1; $divisor = 1; foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) { foreach ($ciscosb_data as $key => $value) { + if (! isset($value['rlPhyTestTableTransceiverTemp'])) { + continue; + } + $oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.' . $index . '.5'; $sensor_type = 'rlPhyTestTableTransceiverTemp'; $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_descr['ifDescr'] . ' Module'); + $descr = trim(($port_descr['ifDescr'] ?? null) . ' Module'); $temperature = $value['rlPhyTestTableTransceiverTemp']; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; diff --git a/includes/discovery/sensors/temperature/comware.inc.php b/includes/discovery/sensors/temperature/comware.inc.php index a036085254..13021aac1f 100644 --- a/includes/discovery/sensors/temperature/comware.inc.php +++ b/includes/discovery/sensors/temperature/comware.inc.php @@ -59,6 +59,11 @@ $divisor = 1; $divisor_alarm = 1000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverTemperature']) && $entry['hh3cTransceiverTemperature'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { + $interface = get_port_by_index_cache($device['device_id'], $index); + if ($interface['ifAdminStatus'] != 'up') { + continue; + } + $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.15.' . $index; $limit_low = $entry['hh3cTransceiverTempLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverTempLoWarn'] / $divisor_alarm; @@ -67,10 +72,8 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $current = $entry['hh3cTransceiverTemperature']; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; - $interface = get_port_by_index_cache($device['device_id'], $index); - if ($interface['ifAdminStatus'] == 'up') { - $descr = makeshortif($interface['ifDescr']) . ' Module'; - discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'temp-trans-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); - } + + $descr = makeshortif($interface['ifDescr']) . ' Module'; + discover_sensor($valid['sensor'], 'temperature', $device, $oid, 'temp-trans-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/temperature/liebert.inc.php b/includes/discovery/sensors/temperature/liebert.inc.php index 9d698e5cbc..c7867d7efb 100644 --- a/includes/discovery/sensors/temperature/liebert.inc.php +++ b/includes/discovery/sensors/temperature/liebert.inc.php @@ -25,17 +25,17 @@ $lib_data = snmpwalk_cache_oid($device, 'lgpEnvTemperatureEntryDegC', [], 'LIEBERT-GP-ENVIRONMENTAL-MIB'); foreach ($lib_data as $index => $data) { - if (is_numeric($data['lgpEnvTemperatureMeasurementTenthsDegC'])) { + if (isset($data['lgpEnvTemperatureMeasurementTenthsDegC']) && is_numeric($data['lgpEnvTemperatureMeasurementTenthsDegC'])) { $oid = '.1.3.6.1.4.1.476.1.42.3.4.1.3.3.1.50.' . $index; $low_limit = $data['lgpEnvTemperatureLowThresholdTenthsDegC']; $high_limit = $data['lgpEnvTemperatureHighThresholdTenthsDegC']; $current = $data['lgpEnvTemperatureMeasurementTenthsDegC']; $divisor = 10; $new_index = 'lgpEnvTemperatureMeasurementTenthsDegC.' . $index; - } elseif (is_numeric($data['lgpEnvTemperatureMeasurementDegC'])) { + } elseif (isset($data['lgpEnvTemperatureMeasurementDegC']) && is_numeric($data['lgpEnvTemperatureMeasurementDegC'])) { $oid = '.1.3.6.1.4.1.476.1.42.3.4.1.3.3.1.3.' . $index; - $low_limit = $data['lgpEnvTemperatureLowThresholdDegC']; - $high_limit = $data['lgpEnvTemperatureHighThresholdDegC']; + $low_limit = $data['lgpEnvTemperatureLowThresholdDegC'] ?? null; + $high_limit = $data['lgpEnvTemperatureHighThresholdDegC'] ?? null; $current = $data['lgpEnvTemperatureMeasurementDegC']; $divisor = 1; $new_index = 'lgpEnvTemperatureDescrDegC.' . $index; diff --git a/includes/discovery/sensors/voltage/ciscosb.inc.php b/includes/discovery/sensors/voltage/ciscosb.inc.php index b1518fad24..7bdb286cb5 100644 --- a/includes/discovery/sensors/voltage/ciscosb.inc.php +++ b/includes/discovery/sensors/voltage/ciscosb.inc.php @@ -16,10 +16,14 @@ $multiplier = 1; $divisor = 1000000; foreach ($pre_cache['ciscosb_rlPhyTestGetResult'] as $index => $ciscosb_data) { foreach ($ciscosb_data as $key => $value) { + if (! isset($value['rlPhyTestTableTransceiverSupply'])) { + continue; + } + $oid = '.1.3.6.1.4.1.9.6.1.101.90.1.2.1.3.' . $index . '.6'; $sensor_type = 'rlPhyTestTableTransceiverSupply'; $port_descr = get_port_by_index_cache($device['device_id'], preg_replace('/^\d+\./', '', $index)); - $descr = trim($port_descr['ifDescr'] . ' Supply Voltage'); + $descr = trim(($port_descr['ifDescr'] ?? null) . ' Supply Voltage'); $voltage = $value['rlPhyTestTableTransceiverSupply'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; diff --git a/includes/discovery/sensors/voltage/comware.inc.php b/includes/discovery/sensors/voltage/comware.inc.php index 236afaf8d0..21dccb415e 100644 --- a/includes/discovery/sensors/voltage/comware.inc.php +++ b/includes/discovery/sensors/voltage/comware.inc.php @@ -18,6 +18,11 @@ $divisor = 100; $divisor_alarm = 10000; foreach ($pre_cache['comware_oids'] as $index => $entry) { if (is_numeric($entry['hh3cTransceiverVoltage']) && $entry['hh3cTransceiverVoltage'] != 2147483647 && isset($entry['hh3cTransceiverDiagnostic'])) { + $interface = get_port_by_index_cache($device['device_id'], $index); + if ($interface['ifAdminStatus'] != 'up') { + continue; + } + $oid = '.1.3.6.1.4.1.25506.2.70.1.1.1.16.' . $index; $limit_low = $entry['hh3cTransceiverVccLoAlarm'] / $divisor_alarm; $warn_limit_low = $entry['hh3cTransceiverVccLoWarn'] / $divisor_alarm; @@ -26,10 +31,8 @@ foreach ($pre_cache['comware_oids'] as $index => $entry) { $current = $entry['hh3cTransceiverVoltage'] / $divisor; $entPhysicalIndex = $index; $entPhysicalIndex_measured = 'ports'; - $interface = get_port_by_index_cache($device['device_id'], $index); - if ($interface['ifAdminStatus'] == 'up') { - $descr = makeshortif($interface['ifDescr']) . ' Supply Voltage'; - discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'volt-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); - } + + $descr = makeshortif($interface['ifDescr']) . ' Supply Voltage'; + discover_sensor($valid['sensor'], 'voltage', $device, $oid, 'volt-' . $index, 'comware', $descr, $divisor, $multiplier, $limit_low, $warn_limit_low, $warn_limit, $limit, $current, 'snmp', $entPhysicalIndex, $entPhysicalIndex_measured); } } diff --git a/includes/discovery/sensors/voltage/rfc1628.inc.php b/includes/discovery/sensors/voltage/rfc1628.inc.php index dec23272c2..e87f9b8a3a 100644 --- a/includes/discovery/sensors/voltage/rfc1628.inc.php +++ b/includes/discovery/sensors/voltage/rfc1628.inc.php @@ -5,7 +5,7 @@ echo 'RFC1628 '; $battery_volts = snmp_get($device, 'upsBatteryVoltage.0', '-OqvU', 'UPS-MIB'); if (is_numeric($battery_volts)) { $volt_oid = '.1.3.6.1.2.1.33.1.2.5.0'; - $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'], 'voltage', $volt_oid); + $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'] ?? 0, 'voltage', $volt_oid); discover_sensor( $valid['sensor'], @@ -28,7 +28,7 @@ if (is_numeric($battery_volts)) { $output_volts = snmpwalk_group($device, 'upsOutputVoltage', 'UPS-MIB'); foreach ($output_volts as $index => $data) { $volt_oid = ".1.3.6.1.2.1.33.1.4.4.1.2.$index"; - $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'], 'voltage', $volt_oid); + $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'] ?? 0, 'voltage', $volt_oid); $descr = 'Output'; if (count($output_volts) > 1) { $descr .= " Phase $index"; @@ -62,7 +62,7 @@ foreach ($output_volts as $index => $data) { $input_volts = snmpwalk_group($device, 'upsInputVoltage', 'UPS-MIB'); foreach ($input_volts as $index => $data) { $volt_oid = ".1.3.6.1.2.1.33.1.3.3.1.3.$index"; - $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'], 'voltage', $volt_oid); + $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'] ?? 0, 'voltage', $volt_oid); $descr = 'Input'; if (count($input_volts) > 1) { $descr .= " Phase $index"; @@ -96,7 +96,7 @@ foreach ($input_volts as $index => $data) { $bypass_volts = snmpwalk_group($device, 'upsBypassVoltage', 'UPS-MIB'); foreach ($bypass_volts as $index => $data) { $volt_oid = ".1.3.6.1.2.1.33.1.5.3.1.2.$index"; - $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'], 'voltage', $volt_oid); + $divisor = get_device_divisor($device, $pre_cache['poweralert_serial'] ?? 0, 'voltage', $volt_oid); $descr = 'Bypass'; if (count($bypass_volts) > 1) { $descr .= " Phase $index"; diff --git a/includes/discovery/storage/cisco-flash.inc.php b/includes/discovery/storage/cisco-flash.inc.php index 6ad3c129b7..a8997d5ffb 100644 --- a/includes/discovery/storage/cisco-flash.inc.php +++ b/includes/discovery/storage/cisco-flash.inc.php @@ -31,7 +31,8 @@ if ($device['os_group'] == 'cisco') { foreach ($ciscoFlashPartitionName as $index => $partitionName) { $name = array_shift($ciscoFlashDeviceName[$index[0]]) . '(' . array_shift($partitionName) . '):'; $oids = array('ciscoFlashPartitionSize.' . $index, 'ciscoFlashPartitionFreeSpace.' . $index, 'ciscoFlashPartitionSizeExtended.' . $index, 'ciscoFlashPartitionFreeSpaceExtended.' . $index); - $entry = array_shift(snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB')); + $entry = snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB'); + $entry = array_shift($entry); $storage_size = (Number::cast($entry['ciscoFlashPartitionSize']) === 4294967295 ? $entry['ciscoFlashPartitionSizeExtended'] : $entry['ciscoFlashPartitionSize']); $storage_free = (Number::cast($entry['ciscoFlashPartitionFreeSpace']) === 4294967295 ? $entry['ciscoFlashPartitionFreeSpaceExtended'] : $entry['ciscoFlashPartitionFreeSpace']); $storage_used = $storage_size - $storage_free; diff --git a/includes/discovery/storage/hpe-ilo.inc.php b/includes/discovery/storage/hpe-ilo.inc.php index 4d9b752173..bdba29fd2d 100644 --- a/includes/discovery/storage/hpe-ilo.inc.php +++ b/includes/discovery/storage/hpe-ilo.inc.php @@ -9,7 +9,7 @@ if (in_array($device['os'], ['windows', 'hpe-ilo']) || $device['os_group'] == 'u $type = $storage['cpqHoFileSysDesc']; preg_match_all('/\[.*?:(.*?)\]/', $type, $matches); - $fstype = $matches[1][0]; + $fstype = $matches[1][0] ?? null; $descr = $storage['cpqHoFileSysDesc']; $size = $storage['cpqHoFileSysSpaceTotal']; $used = $storage['cpqHoFileSysSpaceUsed']; diff --git a/includes/discovery/storage/hrstorage.inc.php b/includes/discovery/storage/hrstorage.inc.php index 426de55f30..ce3a94292e 100644 --- a/includes/discovery/storage/hrstorage.inc.php +++ b/includes/discovery/storage/hrstorage.inc.php @@ -32,7 +32,7 @@ if (is_array($hrstorage_array)) { $fstype = $storage['hrStorageType'] ?? null; $descr = $storage['hrStorageDescr']; $storage['hrStorageSize'] = fix_integer_value($storage['hrStorageSize']); - $storage['hrStorageUsed'] = fix_integer_value($storage['hrStorageUsed']); + $storage['hrStorageUsed'] = isset($storage['hrStorageUsed']) ? fix_integer_value($storage['hrStorageUsed']) : 0; $size = ($storage['hrStorageSize'] * $storage['hrStorageAllocationUnits']); $used = ($storage['hrStorageUsed'] * $storage['hrStorageAllocationUnits']); $units = $storage['hrStorageAllocationUnits']; diff --git a/includes/discovery/vlans.inc.php b/includes/discovery/vlans.inc.php index 189394b897..aa224f3efa 100644 --- a/includes/discovery/vlans.inc.php +++ b/includes/discovery/vlans.inc.php @@ -44,6 +44,10 @@ if (empty($device['vlans']) === true) { foreach ($device['vlans'] as $domain_id => $vlans) { foreach ($vlans as $vlan_id => $vlan) { // grab the populated data for this vlan + if (! isset($per_vlan_data[$vlan_id])) { + continue; + } + $vlan_data = $per_vlan_data[$vlan_id]; echo "VLAN $vlan_id \n"; @@ -57,21 +61,26 @@ foreach ($device['vlans'] as $domain_id => $vlans) { $db_w = [ 'device_id' => $device['device_id'], - 'port_id' => $port['port_id'], + 'port_id' => $port['port_id'] ?? null, 'vlan' => $vlan_id, ]; - $db_a['baseport'] = $index_to_base[$ifIndex]; + $db_a['baseport'] = $index_to_base[$ifIndex] ?? ''; $db_a['priority'] = isset($vlan_port['dot1dStpPortPriority']) ? $vlan_port['dot1dStpPortPriority'] : 0; $db_a['state'] = isset($vlan_port['dot1dStpPortState']) ? $vlan_port['dot1dStpPortState'] : 'unknown'; $db_a['cost'] = isset($vlan_port['dot1dStpPortPathCost']) ? $vlan_port['dot1dStpPortPathCost'] : 0; $db_a['untagged'] = isset($vlan_port['untagged']) ? $vlan_port['untagged'] : 0; - echo str_pad($db_a['baseport'], 10) . str_pad($ifIndex, 10) . str_pad($port['ifName'] ?: $port['ifDescr'], 25) . str_pad($db_a['priority'], 10) . str_pad($db_a['state'], 15) . str_pad($db_a['cost'], 10); + echo str_pad($db_a['baseport'], 10); + echo str_pad($ifIndex, 10); + echo str_pad($port['ifName'] ?? $port['ifDescr'] ?? '', 25); + echo str_pad($db_a['priority'], 10); + echo str_pad($db_a['state'], 15); + echo str_pad($db_a['cost'], 10); - $from_db = dbFetchRow('SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?', [$device['device_id'], $port['port_id'], $vlan_id]); + $from_db = dbFetchRow('SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?', [$device['device_id'], $port['port_id'] ?? null, $vlan_id]); - if ($from_db['port_vlan_id']) { + if ($from_db && $from_db['port_vlan_id']) { $db_id = $from_db['port_vlan_id']; dbUpdate($db_a, 'ports_vlans', '`port_vlan_id` = ?', [$db_id]); echo 'Updated'; diff --git a/includes/discovery/vlans/boss.inc.php b/includes/discovery/vlans/boss.inc.php index 9a6b37d962..03fbe00106 100644 --- a/includes/discovery/vlans/boss.inc.php +++ b/includes/discovery/vlans/boss.inc.php @@ -11,7 +11,7 @@ if ($device['os'] == 'boss') { foreach ($vlans as $vlan_id => $vlan) { d_echo(" $vlan_id"); - if (is_array($vlans_db[$vtpdomain_id][$vlan_id])) { + if (! empty($vlans_db) && is_array($vlans_db[$vtpdomain_id][$vlan_id])) { $vlan_data = $vlans_db[$vtpdomain_id][$vlan_id]; if ($vlan_data['vlan_name'] != $vlan['rcVlanName']) { $vlan_upd['vlan_name'] = $vlan['rcVlanName']; @@ -43,7 +43,7 @@ if ($device['os'] == 'boss') { } foreach ($egress_ids as $port_id) { - $ifIndex = $base_to_index[$port_id - 1]; // -1 fixes off by one error + $ifIndex = $base_to_index[$port_id - 1] ?? null; // -1 fixes off by one error $per_vlan_data[$vlan_id][$ifIndex]['untagged'] = (in_array($port_id - 1, $untagged_ids) ? 1 : 0); // -1 fixes off by one error } } diff --git a/includes/discovery/vlans/cisco-vtp.inc.php b/includes/discovery/vlans/cisco-vtp.inc.php index 82cdfa0785..8264418012 100644 --- a/includes/discovery/vlans/cisco-vtp.inc.php +++ b/includes/discovery/vlans/cisco-vtp.inc.php @@ -18,7 +18,7 @@ if ($device['os_group'] == 'cisco') { echo 'VTP Domain ' . $vtpdomain_id . ' ' . $vtpdomain['managementDomainName'] . ' '; foreach ($vlans[$vtpdomain_id] as $vlan_id => $vlan) { d_echo(" $vlan_id"); - if (is_array($vlans_db[$vtpdomain_id][$vlan_id])) { + if (isset($vlans_db[$vtpdomain_id][$vlan_id]) && is_array($vlans_db[$vtpdomain_id][$vlan_id])) { $vlan_data = $vlans_db[$vtpdomain_id][$vlan_id]; if ($vlan_data['vlan_name'] != $vlan['vtpVlanName']) { $vlan_upd['vlan_name'] = $vlan['vtpVlanName']; @@ -69,8 +69,8 @@ if ($device['os_group'] == 'cisco') { } else { $vlan_id = $data['vlanTrunkPortNativeVlan']; } - $base = $index_to_base[$ifIndex]; - echo "Vlan: $vlan_id tagged on $base (ifIndex $ifIndex)\n"; + //$base = $index_to_base[$ifIndex]; + //echo "Vlan: $vlan_id tagged on $base (ifIndex $ifIndex)\n"; $per_vlan_data[$vlan_id][$ifIndex]['untagged'] = 1; } unset( diff --git a/includes/discovery/vlans/jetstream.inc.php b/includes/discovery/vlans/jetstream.inc.php index 84bfb1b90c..ecb00376cd 100644 --- a/includes/discovery/vlans/jetstream.inc.php +++ b/includes/discovery/vlans/jetstream.inc.php @@ -69,7 +69,7 @@ if ($vlanversion == 'version1' || $vlanversion == '2') { foreach ($jet_vlanDb as $jet_vlan_id => $jet_vlan_data) { d_echo(" $jet_vlan_id "); - if (is_array($vlans_db[$vtpdomain_id][$jet_vlan_id])) { + if (isset($vlans_db[$vtpdomain_id][$jet_vlan_id]) && is_array($vlans_db[$vtpdomain_id][$jet_vlan_id])) { $vlan_data = $vlans_db[$vtpdomain_id][$jet_vlan_id]; if ($vlan_data['vlan_name'] != $jet_vlan_data['dot1qVlanDescription']) { @@ -89,7 +89,7 @@ if ($vlanversion == 'version1' || $vlanversion == '2') { 'vlan_type' => ['NULL'], ], 'vlans'); - log_event('VLAN added: ' . $jet_vlan_data['dot1qVlanDescription'] . ", $vlan_id", $device, 'vlan'); + log_event('VLAN added: ' . $jet_vlan_data['dot1qVlanDescription'] . ", $jet_vlan_id", $device, 'vlan'); echo '+'; } $device['vlans'][$vtpdomain_id][$jet_vlan_id] = $jet_vlan_id; diff --git a/includes/discovery/vlans/q-bridge-mib.inc.php b/includes/discovery/vlans/q-bridge-mib.inc.php index 3eb360e0b0..a704176f01 100644 --- a/includes/discovery/vlans/q-bridge-mib.inc.php +++ b/includes/discovery/vlans/q-bridge-mib.inc.php @@ -81,9 +81,9 @@ if ($vlanversion == 'version1' || $vlanversion == '2') { $device['vlans'][$vtpdomain_id][$vlan_id] = $vlan_id; //populate device['vlans'] with ID's //portmap for untagged ports - $untagged_ids = q_bridge_bits2indices($vlan['Q-BRIDGE-MIB::dot1qVlanCurrentUntaggedPorts'] ?? $vlan['Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts']); + $untagged_ids = q_bridge_bits2indices($vlan['Q-BRIDGE-MIB::dot1qVlanCurrentUntaggedPorts'] ?? $vlan['Q-BRIDGE-MIB::dot1qVlanStaticUntaggedPorts'] ?? ''); //portmap for members ports (might be tagged) - $egress_ids = q_bridge_bits2indices($vlan['Q-BRIDGE-MIB::dot1qVlanCurrentEgressPorts'] ?? $vlan['Q-BRIDGE-MIB::dot1qVlanStaticEgressPorts']); + $egress_ids = q_bridge_bits2indices($vlan['Q-BRIDGE-MIB::dot1qVlanCurrentEgressPorts'] ?? $vlan['Q-BRIDGE-MIB::dot1qVlanStaticEgressPorts'] ?? ''); foreach ($egress_ids as $port_id) { if (isset($base_to_index[$port_id])) { $ifIndex = $base_to_index[$port_id]; diff --git a/includes/polling/applications/asterisk.inc.php b/includes/polling/applications/asterisk.inc.php index dedfb80e7b..66f4378b46 100644 --- a/includes/polling/applications/asterisk.inc.php +++ b/includes/polling/applications/asterisk.inc.php @@ -3,6 +3,7 @@ use LibreNMS\RRD\RrdDefinition; $name = 'asterisk'; +$app_id = $app->app_id; if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; @@ -73,4 +74,4 @@ update_application($app, $rawdata, $asterisk_metrics); unset($rrd_name, $rrd_def, $iax2_fields, $iax2_tags); -unset($asterisk, $asterisk_metrics, $rawdata); // these are used for all rrds +unset($asterisk, $asterisk_metrics, $rawdata, $app_id); // these are used for all rrds diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index 83c31bed7f..0910be6c3f 100644 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -55,10 +55,10 @@ if ($device['os_group'] == 'cisco') { $mac_entries++; - $b_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['input']; - $b_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['output']; - $p_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['input']; - $p_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['output']; + $b_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['input'] ?? null; + $b_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedBytes']['output'] ?? null; + $p_in = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['input'] ?? null; + $p_out = $cip_array[$ifIndex][$mac]['cipMacHCSwitchedPkts']['output'] ?? null; $this_ma = &$cip_array[$ifIndex][$mac]; @@ -66,10 +66,10 @@ if ($device['os_group'] == 'cisco') { foreach ($cip_oids as $oid) { foreach (['input', 'output'] as $dir) { $oid_dir = $oid . '_' . $dir; - $acc['update'][$oid_dir] = $this_ma[$oid][$dir]; + $acc['update'][$oid_dir] = $this_ma[$oid][$dir] ?? null; $acc['update'][$oid_dir . '_prev'] = $acc[$oid_dir]; $oid_prev = $oid_dir . '_prev'; - if ($this_ma[$oid][$dir]) { + if (isset($this_ma[$oid][$dir])) { $oid_diff = ($this_ma[$oid][$dir] - $acc[$oid_dir]); $oid_rate = ($oid_diff / $polled_period); $acc['update'][$oid_dir . '_rate'] = $oid_rate; @@ -79,7 +79,7 @@ if ($device['os_group'] == 'cisco') { } } - d_echo("\n" . $acc['hostname'] . ' ' . $acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); + d_echo("\nDevice id: " . $acc['device_id'] . ' -> ' . $acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); $rrd_name = ['cip', $ifIndex, $mac]; $rrd_def = RrdDefinition::make() diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 3bdb43aeb3..30290f501c 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -75,7 +75,7 @@ function poll_sensor($device, $class) if ($sensor['poller_type'] == 'snmp') { $mibdir = null; - $sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']])); + $sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']] ?? '')); if (file_exists('includes/polling/sensors/' . $class . '/' . $device['os'] . '.inc.php')) { require 'includes/polling/sensors/' . $class . '/' . $device['os'] . '.inc.php'; diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index d9cefadca6..36b3e4f55d 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -842,19 +842,19 @@ foreach ($ports as $port) { $fields = [ 'INOCTETS' => $this_port['ifInOctets'] ?? null, 'OUTOCTETS' => $this_port['ifOutOctets'] ?? null, - 'INERRORS' => $this_port['ifInErrors'], - 'OUTERRORS' => $this_port['ifOutErrors'], + 'INERRORS' => $this_port['ifInErrors'] ?? null, + 'OUTERRORS' => $this_port['ifOutErrors'] ?? null, 'INUCASTPKTS' => $this_port['ifInUcastPkts'] ?? null, 'OUTUCASTPKTS' => $this_port['ifOutUcastPkts'] ?? null, 'INNUCASTPKTS' => $this_port['ifInNUcastPkts'] ?? null, 'OUTNUCASTPKTS' => $this_port['ifOutNUcastPkts'] ?? null, - 'INDISCARDS' => $this_port['ifInDiscards'], - 'OUTDISCARDS' => $this_port['ifOutDiscards'], + 'INDISCARDS' => $this_port['ifInDiscards'] ?? null, + 'OUTDISCARDS' => $this_port['ifOutDiscards'] ?? null, 'INUNKNOWNPROTOS' => $this_port['ifInUnknownProtos'] ?? null, - 'INBROADCASTPKTS' => $this_port['ifInBroadcastPkts'], - 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'], - 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'], - 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'], + 'INBROADCASTPKTS' => $this_port['ifInBroadcastPkts'] ?? null, + 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'] ?? null, + 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'] ?? null, + 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'] ?? null, ]; // non rrd stats (will be filtered) diff --git a/includes/polling/ports/os/airos-af-ltu.inc.php b/includes/polling/ports/os/airos-af-ltu.inc.php index 9a1b400284..3e5f7aebc6 100644 --- a/includes/polling/ports/os/airos-af-ltu.inc.php +++ b/includes/polling/ports/os/airos-af-ltu.inc.php @@ -28,10 +28,10 @@ foreach ($port_stats as $index => $afport_stats) { if ($afport_stats['ifDescr'] == 'eth0') { if (isset($airos_stats[0]['afLTUethConnected'])) { $port_stats[$index]['ifOperStatus'] = ($airos_stats[0]['afLTUethConnected'] == 'connected' ? 'up' : 'down'); - $port_stats[$index]['ifHCInOctets'] = $airos_stats[0]['afLTUethRxBytes']; - $port_stats[$index]['ifHCOutOctets'] = $airos_stats[0]['afLTUethTxBytes']; - $port_stats[$index]['ifHCInUcastPkts'] = $airos_stats[0]['afLTUethRxPps']; - $port_stats[$index]['ifHCOutUcastPkts'] = $airos_stats[0]['afLTUethTxPps']; + $port_stats[$index]['ifHCInOctets'] = $airos_stats[0]['afLTUethRxBytes'] ?? null; + $port_stats[$index]['ifHCOutOctets'] = $airos_stats[0]['afLTUethTxBytes'] ?? null; + $port_stats[$index]['ifHCInUcastPkts'] = $airos_stats[0]['afLTUethRxPps'] ?? null; + $port_stats[$index]['ifHCOutUcastPkts'] = $airos_stats[0]['afLTUethTxPps'] ?? null; $port_stats[$index]['ifHighSpeed'] = '1000'; } else { /** diff --git a/includes/polling/ports/os/ciena-sds.inc.php b/includes/polling/ports/os/ciena-sds.inc.php index ea13507641..365cba9d88 100644 --- a/includes/polling/ports/os/ciena-sds.inc.php +++ b/includes/polling/ports/os/ciena-sds.inc.php @@ -38,6 +38,11 @@ if (in_array($device['hardware'], $bad_HC_counter_devices)) { // PM index for port 1/1 -- 1000001 // if index for port 1/1 -- 100001 + // Ignore ports with index of example 61.1000001 + if (Str::contains($index, '.')) { + continue; + } + $nms_index = $index - 900000; if (isset($port_stats[$nms_index])) { diff --git a/includes/polling/ports/os/infinera-groove.inc.php b/includes/polling/ports/os/infinera-groove.inc.php index 09be4a4291..4d447b284f 100644 --- a/includes/polling/ports/os/infinera-groove.inc.php +++ b/includes/polling/ports/os/infinera-groove.inc.php @@ -29,7 +29,7 @@ foreach (['eth100g', 'eth40g', 'eth10g', 'fc16g', 'fc8g'] as $infineratype) { preg_match('/[a-z]+(\d+)g/i', $infineratype, $matches); $infspeed = $matches[1]; - $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype . 'Entry', $cg_stats, 'CORIANT-GROOVE-MIB'); + $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype . 'Entry', [], 'CORIANT-GROOVE-MIB'); $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype . 'Statistics', $cg_stats, 'CORIANT-GROOVE-MIB'); $required = [ diff --git a/includes/polling/storage/cisco-flash.inc.php b/includes/polling/storage/cisco-flash.inc.php index f2a092a23e..c38d8dfb35 100644 --- a/includes/polling/storage/cisco-flash.inc.php +++ b/includes/polling/storage/cisco-flash.inc.php @@ -26,7 +26,8 @@ use LibreNMS\Util\Number; $oids = array('ciscoFlashPartitionSize.' . $storage['storage_index'], 'ciscoFlashPartitionFreeSpace.' . $storage['storage_index'], 'ciscoFlashPartitionSizeExtended.' . $storage['storage_index'], 'ciscoFlashPartitionFreeSpaceExtended.' . $storage['storage_index']); -$entry = array_shift(snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB')); +$entry = snmp_get_multi($device, $oids, '-OQUs', 'CISCO-FLASH-MIB'); +$entry = array_shift($entry); $storage['size'] = (Number::cast($entry['ciscoFlashPartitionSize']) === 4294967295 ? $entry['ciscoFlashPartitionSizeExtended'] : $entry['ciscoFlashPartitionSize']); $storage['free'] = (Number::cast($entry['ciscoFlashPartitionFreeSpace']) === 4294967295 ? $entry['ciscoFlashPartitionFreeSpaceExtended'] : $entry['ciscoFlashPartitionFreeSpace']); $storage['used'] = $storage['size'] - $storage['free']; diff --git a/includes/polling/storage/hrstorage.inc.php b/includes/polling/storage/hrstorage.inc.php index 84c42017cb..abf24345b4 100644 --- a/includes/polling/storage/hrstorage.inc.php +++ b/includes/polling/storage/hrstorage.inc.php @@ -9,7 +9,7 @@ if (! isset($storage_cache['hrstorage'])) { $entry = $storage_cache['hrstorage'][$storage['storage_index']]; $storage['units'] = $entry['hrStorageAllocationUnits']; -$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed']); +$entry['hrStorageUsed'] = fix_integer_value($entry['hrStorageUsed'] ?? 0); $entry['hrStorageSize'] = fix_integer_value($entry['hrStorageSize']); $storage['used'] = ($entry['hrStorageUsed'] * $storage['units']); $storage['size'] = ($entry['hrStorageSize'] * $storage['units']); diff --git a/includes/port-descr-parser.inc.php b/includes/port-descr-parser.inc.php index e55ad510fc..f8ad231532 100644 --- a/includes/port-descr-parser.inc.php +++ b/includes/port-descr-parser.inc.php @@ -8,9 +8,10 @@ echo $this_port['ifAlias']; $split = preg_split('/[:\[\]{}()]/', $this_port['ifAlias']); $type = isset($split[0]) ? trim($split[0]) : null; $descr = isset($split[1]) ? trim($split[1]) : null; -$circuit = trim(preg_split('/[{}]/', $this_port['ifAlias'])[1]) ?? null; -$notes = trim(preg_split('/[()]/', $this_port['ifAlias'])[1]) ?? null; -$speed = preg_split('/[\[\]]/', $this_port['ifAlias'])[1] ?? null; + +$circuit = trim(preg_split('/[{}]/', $this_port['ifAlias'])[1] ?? ''); +$notes = trim(preg_split('/[()]/', $this_port['ifAlias'])[1] ?? ''); +$speed = trim(preg_split('/[\[\]]/', $this_port['ifAlias'])[1] ?? ''); if ($type && $descr) { $type = strtolower($type);