mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Miscellaneous cleanup, mostly undefined variables - part2 (#14445)
* Miscellaneous cleanup, mostly undefined variables - part2 * wip * Update Number.php * Update BridgeMib.php * Update Xdsl.php * Update cisco.inc.php * Update Cisco.php * Update entity-sensor.inc.php * Update entity-sensor.inc.php * Update entity-sensor.inc.php * Update avtech.inc.php * Update functions.inc.php * Update HostResources.php * Update ports.inc.php * Update route.inc.php * Update cisco.inc.php * Update Cisco.php
This commit is contained in:
@@ -75,8 +75,8 @@ class Airos extends OS implements
|
||||
|
||||
// fix having an extra - in the middle after the decimal point
|
||||
$regex = '/(-?\d+)\.-?(\d+)/';
|
||||
$location->lng = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lng']);
|
||||
$location->lat = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lat']);
|
||||
$location->lng = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lng'] ?? '');
|
||||
$location->lat = (float) preg_replace($regex, '$1.$2', $location->getAttributes()['lat'] ?? '');
|
||||
|
||||
return $location;
|
||||
}
|
||||
@@ -242,7 +242,7 @@ class Airos extends OS implements
|
||||
'airos',
|
||||
$index,
|
||||
'RSSI: Chain ' . str_replace('1.', '', $index),
|
||||
$entry['ubntRadioRssi.1']
|
||||
$entry['ubntRadioRssi']
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -97,8 +97,8 @@ class AirosAfLtu extends OS implements
|
||||
$oids = snmpwalk_cache_oid($this->getDeviceArray(), 'afLTUStaRxPowerLevel1', $oids, 'UBNT-AFLTU-MIB', null, '-OteQUsb');
|
||||
|
||||
foreach ($oids as $index => $entry) {
|
||||
$sensors[] = new WirelessSensor('quality', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.10.1.4.1.9.' . $index, 'airos-af-ltu-level-rx-chain-0', 1, 'Signal Level Chain 0', $entry['afLTUStaRxPower0']); //UBNT-AFLTU-MIB::afLTUStaRxPowerLevel0
|
||||
$sensors[] = new WirelessSensor('quality', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.10.1.4.1.10.' . $index, 'airos-af-ltu-level-rx-chain-1', 1, 'Signal Level Chain 1', $entry['afLTUStaRxPower1']); //UBNT-AFLTU-MIB::afLTUStaRxPowerLevel1
|
||||
$sensors[] = new WirelessSensor('quality', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.10.1.4.1.9.' . $index, 'airos-af-ltu-level-rx-chain-0', 1, 'Signal Level Chain 0', $entry['afLTUStaRxPowerLevel0']); //UBNT-AFLTU-MIB::afLTUStaRxPowerLevel0
|
||||
$sensors[] = new WirelessSensor('quality', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.10.1.4.1.10.' . $index, 'airos-af-ltu-level-rx-chain-1', 1, 'Signal Level Chain 1', $entry['afLTUStaRxPowerLevel1']); //UBNT-AFLTU-MIB::afLTUStaRxPowerLevel1
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -101,9 +101,9 @@ class Allied extends OS implements OSDiscovery
|
||||
$hardware = $e;
|
||||
}
|
||||
|
||||
$device->version = str_replace(['"', ','], '', $version ?? null);
|
||||
$device->features = str_replace('"', '', $features ?? null);
|
||||
$device->hardware = str_replace('"', '', $hardware ?? null);
|
||||
$device->version = isset($version) ? str_replace(['"', ','], '', $version) : null;
|
||||
$device->features = isset($features) ? str_replace('"', '', $features) : null;
|
||||
$device->hardware = isset($hardware) ? str_replace('"', '', $hardware) : null;
|
||||
$device->serial = $serial ?? null;
|
||||
}
|
||||
}
|
||||
|
@@ -262,9 +262,9 @@ class ArubaInstant extends OS implements
|
||||
return $sensors;
|
||||
}
|
||||
|
||||
protected function decodeChannel($channel)
|
||||
protected function decodeChannel($channel): int
|
||||
{
|
||||
return $channel & 255; // mask off the channel width information
|
||||
return cast_number($channel) & 255; // mask off the channel width information
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -303,7 +303,7 @@ class ArubaInstant extends OS implements
|
||||
$snmp_data = snmp_get_multi_oid($this->getDeviceArray(), $oids);
|
||||
|
||||
foreach ($oids as $id => $oid) {
|
||||
$data[$id] = $snmp_data[$oid];
|
||||
$data[$id] = $snmp_data[$oid] ?? null;
|
||||
}
|
||||
} else {
|
||||
// version is lower than 8.4.0.0
|
||||
|
@@ -237,14 +237,14 @@ class Cisco extends OS implements
|
||||
}
|
||||
|
||||
if (isset($entry['cpmCPUTotalPhysicalIndex'])) {
|
||||
$descr = $this->getCacheByIndex('entPhysicalName', 'ENTITY-MIB')[$entry['cpmCPUTotalPhysicalIndex']];
|
||||
$descr = $this->getCacheByIndex('entPhysicalName', 'ENTITY-MIB')[$entry['cpmCPUTotalPhysicalIndex']] ?? null;
|
||||
}
|
||||
|
||||
if (empty($descr)) {
|
||||
$descr = "Processor $index";
|
||||
}
|
||||
|
||||
if (is_array($entry['cpmCore5min'])) {
|
||||
if (isset($entry['cpmCore5min']) && is_array($entry['cpmCore5min'])) {
|
||||
// This CPU has data per individual core
|
||||
foreach ($entry['cpmCore5min'] as $core_index => $core_usage) {
|
||||
$processors[] = Processor::discover(
|
||||
|
@@ -67,9 +67,10 @@ trait BridgeMib
|
||||
return new Collection;
|
||||
}
|
||||
|
||||
\Log::debug('VLAN: ' . ($vlan ?: 1) . " Bridge: {$stp['BRIDGE-MIB::dot1dBaseBridgeAddress.0']} DR: {$stp['BRIDGE-MIB::dot1dStpDesignatedRoot.0']}");
|
||||
$bridge = Rewrite::macToHex($stp['BRIDGE-MIB::dot1dBaseBridgeAddress.0'] ?? '');
|
||||
$drBridge = Rewrite::macToHex($stp['BRIDGE-MIB::dot1dStpDesignatedRoot.0'] ?? '');
|
||||
\Log::debug('VLAN: ' . ($vlan ?: 1) . " Bridge: {$bridge} DR: {$drBridge}");
|
||||
|
||||
$instance = new \App\Models\Stp([
|
||||
'vlan' => $vlan,
|
||||
'rootBridge' => $bridge == $drBridge ? 1 : 0,
|
||||
|
@@ -87,7 +87,7 @@ trait HostResources
|
||||
|
||||
foreach ($hrProcessorLoad as $index => $usage) {
|
||||
$usage_oid = '.1.3.6.1.2.1.25.3.3.1.2.' . $index;
|
||||
$descr = $hrDeviceDescr[$index];
|
||||
$descr = $hrDeviceDescr[$index] ?? null;
|
||||
|
||||
if (! is_numeric($usage)) {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user