mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +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:
parent
1c9234adf1
commit
34a58c3f9f
@ -253,7 +253,7 @@ class WirelessSensor extends Sensor
|
||||
* @param int $channel
|
||||
* @return int
|
||||
*/
|
||||
public static function channelToFrequency($channel)
|
||||
public static function channelToFrequency($channel): int
|
||||
{
|
||||
$channels = [
|
||||
1 => 2412,
|
||||
@ -300,6 +300,6 @@ class WirelessSensor extends Sensor
|
||||
165 => 5825,
|
||||
];
|
||||
|
||||
return $channels[$channel];
|
||||
return $channels[$channel] ?? 0;
|
||||
}
|
||||
}
|
||||
|
@ -145,9 +145,13 @@ abstract class Model
|
||||
$params
|
||||
);
|
||||
|
||||
$this->$key = $row[$key];
|
||||
if (is_array($row)) {
|
||||
$this->$key = $row[$key];
|
||||
|
||||
return $row;
|
||||
return $row;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@ class Xdsl implements Module
|
||||
|
||||
// trim SnmpAdminStrings
|
||||
foreach ($this->trimAdminString as $oid) {
|
||||
$portAdsl->$oid = rtrim($portAdsl->$oid, '.');
|
||||
$portAdsl->$oid = rtrim($portAdsl->$oid ?? '', '.');
|
||||
}
|
||||
|
||||
$portAdsl->port_id = $os->ifIndexToId($ifIndex);
|
||||
|
@ -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;
|
||||
|
@ -90,14 +90,14 @@ class Number
|
||||
* Cast string to int or float.
|
||||
* Returns 0 if string is not numeric
|
||||
*
|
||||
* @param string $number
|
||||
* @param mixed $number
|
||||
* @return float|int
|
||||
*/
|
||||
public static function cast($number)
|
||||
{
|
||||
if (! is_numeric($number)) {
|
||||
// match pre-PHP8 behavior
|
||||
if (! preg_match('/^-?\d+(\.\d+)?/', $number, $matches)) {
|
||||
if (! preg_match('/^-?\d+(\.\d+)?/', $number ?? '', $matches)) {
|
||||
return 0;
|
||||
}
|
||||
$number = $matches[0];
|
||||
|
@ -861,6 +861,11 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
|
||||
|
||||
foreach ($discovery[$sensor_class]['data'] as $data) {
|
||||
$tmp_name = $data['oid'];
|
||||
|
||||
if (! isset($pre_cache[$tmp_name])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$raw_data = (array) $pre_cache[$tmp_name];
|
||||
|
||||
d_echo("Data $tmp_name: ");
|
||||
|
@ -39,6 +39,8 @@ $create_row = [];
|
||||
$update_row = [];
|
||||
$delete_row = [];
|
||||
|
||||
$mixed = [];
|
||||
|
||||
//store timestamp so all update / creation will be synced on same timestamp
|
||||
$update_timestamp = dbFetchRows('select now() as now')[0]['now'];
|
||||
|
||||
@ -175,42 +177,43 @@ if (isset($ipForwardNb['0']['inetCidrRouteNumber']) && $ipForwardNb['0']['inetCi
|
||||
|
||||
// IP-FORWARD-MIB with ipCidrRouteTable in case ipCidrRouteTable has more entries than inetCidrRouteTable (Some older routers)
|
||||
|
||||
if (isset($ipForwardNb['0']['ipCidrRouteNumber']) && $ipForwardNb['0']['ipCidrRouteNumber'] > $ipForwardNb['0']['inetCidrRouteNumber'] && $ipForwardNb['0']['ipCidrRouteNumber'] < $max_routes) {
|
||||
//device uses only ipCidrRoute and not inetCidrRoute
|
||||
d_echo('IP FORWARD MIB (without inetCidr support)');
|
||||
$ipCidrTable = SnmpQuery::walk('IP-FORWARD-MIB::ipCidrRouteTable')->table(6);
|
||||
echo 'ipCidrRouteTable ';
|
||||
// we need to translate the values to inetCidr structure;
|
||||
//d_echo($ipCidrTable);
|
||||
foreach ($ipCidrTable as $inetCidrRouteDest => $next1) {
|
||||
foreach ($next1 as $ipCidrRouteMask => $next2) {
|
||||
foreach ($next2 as $ipCidrRouteTos => $next3) {
|
||||
foreach ($next3 as $inetCidrRouteNextHop => $entry) {
|
||||
unset($entryClean);
|
||||
$entryClean['inetCidrRouteDestType'] = 'ipv4';
|
||||
$entryClean['inetCidrRouteDest'] = $inetCidrRouteDest;
|
||||
$inetCidrRoutePfxLen = IPv4::netmask2cidr($entry['IP-FORWARD-MIB::ipCidrRouteMask']); //CONVERT
|
||||
$entryClean['inetCidrRoutePfxLen'] = $inetCidrRoutePfxLen;
|
||||
$entryClean['inetCidrRoutePolicy'] = $entry['IP-FORWARD-MIB::ipCidrRouteInfo'];
|
||||
$entryClean['inetCidrRouteNextHopType'] = 'ipv4';
|
||||
$entryClean['inetCidrRouteNextHop'] = $inetCidrRouteNextHop;
|
||||
$entryClean['inetCidrRouteMetric1'] = $entry['IP-FORWARD-MIB::ipCidrRouteMetric1'];
|
||||
$entryClean['inetCidrRouteProto'] = $entry['IP-FORWARD-MIB::ipCidrRouteProto'];
|
||||
$entryClean['inetCidrRouteType'] = $entry['IP-FORWARD-MIB::ipCidrRouteType'];
|
||||
$entryClean['inetCidrRouteIfIndex'] = $entry['IP-FORWARD-MIB::ipCidrRouteIfIndex'];
|
||||
$entryClean['inetCidrRouteNextHopAS'] = $entry['IP-FORWARD-MIB::ipCidrRouteNextHopAS'];
|
||||
$entryClean['context_name'] = '';
|
||||
$entryClean['device_id'] = $device['device_id'];
|
||||
$entryClean['port_id'] = Device::find($device['device_id'])->ports()->where('ifIndex', '=', $entryClean['inetCidrRouteIfIndex'])->first()->port_id;
|
||||
$entryClean['updated_at'] = $update_timestamp;
|
||||
$current = $mixed['']['ipv4'][$inetCidrRouteDest][$inetCidrRoutePfxLen][$entryClean['inetCidrRoutePolicy']]['ipv4'][$inetCidrRouteNextHop];
|
||||
if (isset($current) && isset($current['db']) && count($current['db']) > 0 && $delete_row[$current['db']['route_id']] != 1) {
|
||||
//we already have a row in DB
|
||||
$entryClean['route_id'] = $current['db']['route_id'];
|
||||
$update_row[] = $entryClean;
|
||||
} else {
|
||||
$entryClean['created_at'] = ['NOW()'];
|
||||
$create_row[] = $entryClean;
|
||||
if (isset($ipForwardNb['0']['ipCidrRouteNumber']) && $ipForwardNb['0']['ipCidrRouteNumber'] < $max_routes) {
|
||||
if (! isset($ipForwardNb['0']['inetCidrRouteNumber']) || $ipForwardNb['0']['ipCidrRouteNumber'] > $ipForwardNb['0']['inetCidrRouteNumber']) {
|
||||
//device uses only ipCidrRoute and not inetCidrRoute
|
||||
d_echo('IP FORWARD MIB (without inetCidr support)');
|
||||
$ipCidrTable = SnmpQuery::walk('IP-FORWARD-MIB::ipCidrRouteTable')->table(6);
|
||||
echo 'ipCidrRouteTable ';
|
||||
// we need to translate the values to inetCidr structure;
|
||||
//d_echo($ipCidrTable);
|
||||
foreach ($ipCidrTable as $inetCidrRouteDest => $next1) {
|
||||
foreach ($next1 as $ipCidrRouteMask => $next2) {
|
||||
foreach ($next2 as $ipCidrRouteTos => $next3) {
|
||||
foreach ($next3 as $inetCidrRouteNextHop => $entry) {
|
||||
unset($entryClean);
|
||||
$entryClean['inetCidrRouteDestType'] = 'ipv4';
|
||||
$entryClean['inetCidrRouteDest'] = $inetCidrRouteDest;
|
||||
$entryClean['inetCidrRoutePfxLen'] = $inetCidrRoutePfxLen = IPv4::netmask2cidr($entry['IP-FORWARD-MIB::ipCidrRouteMask']); //CONVERT
|
||||
$entryClean['inetCidrRoutePolicy'] = $entry['IP-FORWARD-MIB::ipCidrRouteInfo'];
|
||||
$entryClean['inetCidrRouteNextHopType'] = 'ipv4';
|
||||
$entryClean['inetCidrRouteNextHop'] = $inetCidrRouteNextHop;
|
||||
$entryClean['inetCidrRouteMetric1'] = $entry['IP-FORWARD-MIB::ipCidrRouteMetric1'];
|
||||
$entryClean['inetCidrRouteProto'] = $entry['IP-FORWARD-MIB::ipCidrRouteProto'];
|
||||
$entryClean['inetCidrRouteType'] = $entry['IP-FORWARD-MIB::ipCidrRouteType'];
|
||||
$entryClean['inetCidrRouteIfIndex'] = $entry['IP-FORWARD-MIB::ipCidrRouteIfIndex'];
|
||||
$entryClean['inetCidrRouteNextHopAS'] = $entry['IP-FORWARD-MIB::ipCidrRouteNextHopAS'];
|
||||
$entryClean['context_name'] = '';
|
||||
$entryClean['device_id'] = $device['device_id'];
|
||||
$entryClean['port_id'] = Device::find($device['device_id'])->ports()->where('ifIndex', '=', $entryClean['inetCidrRouteIfIndex'])->first()->port_id;
|
||||
$entryClean['updated_at'] = $update_timestamp;
|
||||
$current = $mixed['']['ipv4'][$inetCidrRouteDest][$inetCidrRoutePfxLen][$entryClean['inetCidrRoutePolicy']]['ipv4'][$inetCidrRouteNextHop] ?? null;
|
||||
if (isset($current) && isset($current['db']) && count($current['db']) > 0 && $delete_row[$current['db']['route_id']] != 1) {
|
||||
//we already have a row in DB
|
||||
$entryClean['route_id'] = $current['db']['route_id'];
|
||||
$update_row[] = $entryClean;
|
||||
} else {
|
||||
$entryClean['created_at'] = ['NOW()'];
|
||||
$create_row[] = $entryClean;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -225,15 +228,17 @@ if (isset($ipForwardNb['0']['ipCidrRouteNumber']) && $ipForwardNb['0']['ipCidrRo
|
||||
$mib = 'MPLS-L3VPN-STD-MIB';
|
||||
$oid = 'mplsL3VpnVrfPerfCurrNumRoutes';
|
||||
$mpls_vpn_route_nb = snmpwalk_group($device, $oid, $mib, 6, []);
|
||||
$mpls_skip = false;
|
||||
|
||||
foreach ($mpls_vpn_route_nb as $vpnId => $route_nb) {
|
||||
if ($route_nb['mplsL3VpnVrfPerfCurrNumRoutes'] > $max_routes) {
|
||||
echo "Skipping all MPLS routes because vpn instance $vpnId has more than $max_routes routes.";
|
||||
$mpls_skip = 1;
|
||||
$mpls_skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($mpls_skip != 1) {
|
||||
if ($mpls_skip == false) {
|
||||
echo 'mplsL3VpnVrfRteTable ';
|
||||
// We can discover the routes;
|
||||
$oid = 'mplsL3VpnVrfRteTable';
|
||||
|
@ -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('/Airflow/', $descr) && $data['coolingUnitStatusAnalogUnits'] == 'CFM' && $value >= 0) {
|
||||
discover_sensor($valid['sensor'], 'airflow', $device, $cur_oid, $cur_oid, 'apc', $descr, $scale, 1, null, null, null, null, $value);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ $divisor = 1000;
|
||||
foreach (array_keys($pre_cache['adva_fsp150']) as $index) {
|
||||
foreach ($sensors_adva as $entry) {
|
||||
$sensor_name = $entry['sensor_name'];
|
||||
if ($pre_cache['adva_fsp150'][$index][$sensor_name]) {
|
||||
if (isset($pre_cache['adva_fsp150'][$index][$sensor_name])) {
|
||||
$oid = $entry['sensor_oid'] . '.' . $index;
|
||||
$descr = $pre_cache['adva_fsp150'][$index]['slotCardUnitName'] . ' [#' . $pre_cache['adva_fsp150'][$index]['slotIndex'] . ']';
|
||||
$current = $pre_cache['adva_fsp150'][$index][$entry['sensor_name']] / $divisor;
|
||||
@ -64,7 +64,7 @@ unset($sensors_adva, $entry);
|
||||
// FSP150 Pro Series SFP Current
|
||||
|
||||
foreach ($pre_cache['adva_fsp150_ports'] as $index => $entry) {
|
||||
if ($entry['cmEthernetNetPortMediaType'] == 'fiber' && $entry['cmEthernetNetPortOperationalState'] == 'normal') {
|
||||
if (isset($entry['cmEthernetNetPortMediaType']) && $entry['cmEthernetNetPortMediaType'] == 'fiber' && $entry['cmEthernetNetPortOperationalState'] == 'normal') {
|
||||
$oid = '.1.3.6.1.4.1.2544.1.12.5.1.5.1.32.' . $index . '.3';
|
||||
$current = $pre_cache['adva_fsp150_perfs'][$index . '.3']['cmEthernetNetPortStatsLBC'];
|
||||
if ($current != 0) {
|
||||
@ -94,7 +94,7 @@ foreach ($pre_cache['adva_fsp150_ports'] as $index => $entry) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($entry['cmEthernetAccPortMediaType'] && $entry['cmEthernetAccPortMediaType'] == 'fiber' && $entry['cmEthernetAccPortOperationalState'] == 'normal') {
|
||||
if (isset($entry['cmEthernetAccPortMediaType']) && $entry['cmEthernetAccPortMediaType'] == 'fiber' && $entry['cmEthernetAccPortOperationalState'] == 'normal') {
|
||||
$oid = '.1.3.6.1.4.1.2544.1.12.5.1.1.1.32.' . $index . '.3';
|
||||
$current = $pre_cache['adva_fsp150_perfs'][$index . '.3']['cmEthernetAccPortStatsLBC'];
|
||||
if ($current != 0) {
|
||||
@ -123,7 +123,7 @@ foreach ($pre_cache['adva_fsp150_ports'] as $index => $entry) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($entry['cmEthernetTrafficPortMediaType'] == 'fiber' && $entry['cmEthernetTrafficPortOperationalState'] == 'normal') {
|
||||
if (isset($entry['cmEthernetTrafficPortMediaType']) && $entry['cmEthernetTrafficPortMediaType'] == 'fiber' && $entry['cmEthernetTrafficPortOperationalState'] == 'normal') {
|
||||
$oid = '.1.3.6.1.4.1.2544.1.12.5.1.21.1.32.' . $index . '.3';
|
||||
$current = $pre_cache['adva_fsp150_perfs'][$index . '.3']['cmEthernetTrafficPortStatsLBC'];
|
||||
if ($current != 0) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
// PDU - Phase
|
||||
$oids = snmp_walk($device, 'rPDUStatusPhaseIndex', '-OsqnU', 'PowerNet-MIB');
|
||||
if ($oids) {
|
||||
if (isset($oids) && $oids) {
|
||||
d_echo($oids . "\n");
|
||||
$oids = trim($oids);
|
||||
if ($oids) {
|
||||
@ -45,7 +45,7 @@ if ($oids) {
|
||||
}
|
||||
unset($oids);
|
||||
$oids = snmp_walk($device, 'rPDULoadStatusPhaseNumber', '-OsqnU', 'PowerNet-MIB');
|
||||
if ($oids) {
|
||||
if (isset($oids) && $oids) {
|
||||
d_echo($oids . "\n");
|
||||
$oids = trim($oids);
|
||||
if ($oids) {
|
||||
@ -97,7 +97,7 @@ if ($bank_count > 0) {
|
||||
$oids = snmp_walk($device, 'rPDULoadStatusBankNumber', '-OsqnU', 'PowerNet-MIB');
|
||||
}
|
||||
// should work with firmware v2 and v3
|
||||
if ($oids) {
|
||||
if (isset($oids) && $oids) {
|
||||
echo 'APC PowerNet-MIB Banks ';
|
||||
d_echo($oids . "\n");
|
||||
$oids = trim($oids);
|
||||
@ -139,7 +139,7 @@ if ($oids) {
|
||||
unset($oids);
|
||||
// Per Outlet Power Bar
|
||||
$oids = snmp_walk($device, '.1.3.6.1.4.1.318.1.1.26.9.4.3.1.1', '-t 30 -OsqnU', 'PowerNet-MIB');
|
||||
if ($oids) {
|
||||
if (isset($oids) && $oids) {
|
||||
echo 'APC PowerNet-MIB Outlets ';
|
||||
d_echo($oids . "\n");
|
||||
$oids = trim($oids);
|
||||
@ -176,7 +176,7 @@ if ($oids) {
|
||||
unset($oids);
|
||||
// ATS
|
||||
$oids = snmp_walk($device, 'atsConfigPhaseTableIndex', '-OsqnU', 'PowerNet-MIB');
|
||||
if ($oids) {
|
||||
if (isset($oids) && $oids) {
|
||||
$type = 'apc';
|
||||
d_echo($oids . "\n");
|
||||
$oids = trim($oids);
|
||||
@ -206,12 +206,12 @@ unset($oids);
|
||||
|
||||
// UPS
|
||||
|
||||
$phasecount = $phasecount = $pre_cache['apcups_phase_count'];
|
||||
$phasecount = $pre_cache['apcups_phase_count'];
|
||||
if ($phasecount > 1) {
|
||||
$oids = snmpwalk_cache_oid($device, 'upsPhaseOutputCurrent', $oids, 'PowerNet-MIB');
|
||||
$oids = snmpwalk_cache_oid($device, 'upsPhaseOutputCurrent', [], 'PowerNet-MIB');
|
||||
$in_oids = snmpwalk_cache_oid($device, 'upsPhaseInputCurrent', $in_oids, 'PowerNet-MIB');
|
||||
} else {
|
||||
$oids = snmpwalk_cache_oid($device, 'upsHighPrecOutputCurrent', $oids, 'PowerNet-MIB');
|
||||
$oids = snmpwalk_cache_oid($device, 'upsHighPrecOutputCurrent', [], 'PowerNet-MIB');
|
||||
}
|
||||
if (isset($in_oids)) {
|
||||
foreach ($in_oids as $index => $data) {
|
||||
|
@ -53,7 +53,7 @@ if (! empty($entity_oids)) {
|
||||
if ($entry['entPhySensorType'] == 'other' && Str::contains($entity_array[$index]['entPhysicalName'], ['Rx Power Sensor', 'Tx Power Sensor'])) {
|
||||
$entitysensor['other'] = 'dbm';
|
||||
}
|
||||
if ($entitysensor[$entry['entPhySensorType']] && is_numeric($entry['entPhySensorValue']) && is_numeric($index)) {
|
||||
if (isset($entitysensor[$entry['entPhySensorType']]) && is_numeric($entry['entPhySensorValue']) && is_numeric($index)) {
|
||||
$entPhysicalIndex = $index;
|
||||
$oid = '.1.3.6.1.2.1.99.1.1.1.4.' . $index;
|
||||
$current = $entry['entPhySensorValue'];
|
||||
@ -144,11 +144,11 @@ if (! empty($entity_oids)) {
|
||||
$valid_sensor = false;
|
||||
}
|
||||
}
|
||||
if ($current == '-127' || ($device['os'] == 'asa' && Str::endsWith($device['hardware'], 'sc'))) {
|
||||
if ($current == '-127' || ($device['os'] == 'asa' && is_string($device['hardware']) && Str::endsWith($device['hardware'], 'sc'))) {
|
||||
$valid_sensor = false;
|
||||
}
|
||||
// Check for valid sensors
|
||||
if ($entry['entPhySensorOperStatus'] === 'unavailable') {
|
||||
if (isset($entry['entPhySensorOperStatus']) && $entry['entPhySensorOperStatus'] === 'unavailable') {
|
||||
$valid_sensor = false;
|
||||
}
|
||||
if ($valid_sensor && dbFetchCell("SELECT COUNT(*) FROM `sensors` WHERE device_id = ? AND `sensor_class` = ? AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ?", [$device['device_id'], $type, $index]) == '0') {
|
||||
|
@ -32,9 +32,10 @@ $virtual_tables = [
|
||||
'ra32-wish-temp' => '/\.1\.3\.6\.1\.4\.1\.20916\.1\.8\.1\.4\.((\d+)\.4\.1\.2\.0)/',
|
||||
];
|
||||
|
||||
$data = snmp_walk($device, '.1.3.6.1.4.1.20916.1', '-OQn');
|
||||
$data = trim(snmp_walk($device, '.1.3.6.1.4.1.20916.1', '-OQn'));
|
||||
foreach (explode(PHP_EOL, $data) as $line) {
|
||||
[$oid, $value] = explode(' = ', $line);
|
||||
[$oid, $value] = explode(' =', $line);
|
||||
$value = trim($value);
|
||||
|
||||
$processed = false;
|
||||
foreach ($virtual_tables as $vt_name => $vt_regex) {
|
||||
|
@ -43,7 +43,7 @@ foreach ($tables as $tablevalue) {
|
||||
$cur_oid = $tablevalue['num_oid'];
|
||||
|
||||
if (is_array($temp)) {
|
||||
if ($temp[0][$tablevalue['state_name']] == 'nonRedundant' || $temp[0]['cswMaxSwitchNum'] == '1') {
|
||||
if (isset($temp[0]) && $temp[0][$tablevalue['state_name']] == 'nonRedundant' || $temp[0]['cswMaxSwitchNum'] == '1') {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -591,8 +591,8 @@ foreach ($ports as $port) {
|
||||
|
||||
// rewrite the ifPhysAddress
|
||||
if (strpos($this_port['ifPhysAddress'] ?? '', ':')) {
|
||||
[$a_a, $a_b, $a_c, $a_d, $a_e, $a_f] = explode(':', $this_port['ifPhysAddress']);
|
||||
$this_port['ifPhysAddress'] = zeropad($a_a) . zeropad($a_b) . zeropad($a_c) . zeropad($a_d) . zeropad($a_e) . zeropad($a_f);
|
||||
$mac_split = explode(':', $this_port['ifPhysAddress']);
|
||||
$this_port['ifPhysAddress'] = zeropad($mac_split[0]) . zeropad($mac_split[1]) . zeropad($mac_split[2]) . zeropad($mac_split[3]) . zeropad($mac_split[4] ?? '') . zeropad($mac_split[5] ?? '');
|
||||
}
|
||||
|
||||
// use HC values if they are available
|
||||
|
@ -3640,11 +3640,6 @@ parameters:
|
||||
count: 2
|
||||
path: LibreNMS/OS/ArrisDsr4410md.php
|
||||
|
||||
-
|
||||
message: "#^Method LibreNMS\\\\OS\\\\ArubaInstant\\:\\:decodeChannel\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
path: LibreNMS/OS/ArubaInstant.php
|
||||
|
||||
-
|
||||
message: "#^Method LibreNMS\\\\OS\\\\ArubaInstant\\:\\:decodeChannel\\(\\) has parameter \\$channel with no type specified\\.$#"
|
||||
count: 1
|
||||
|
Loading…
Reference in New Issue
Block a user