diff --git a/LibreNMS/OS.php b/LibreNMS/OS.php index 08487a72b885..cc2f34d60223 100644 --- a/LibreNMS/OS.php +++ b/LibreNMS/OS.php @@ -318,13 +318,15 @@ protected function pollWirelessChannelAsFrequency($sensors, $callback = null) $data = []; foreach ($oids as $id => $oid) { - if (isset($callback)) { - $channel = call_user_func($callback, $snmp_data[$oid]); - } else { - $channel = $snmp_data[$oid]; - } + if (isset($snmp_data[$oid])) { + if (isset($callback)) { + $channel = call_user_func($callback, $snmp_data[$oid]); + } else { + $channel = $snmp_data[$oid]; + } - $data[$id] = WirelessSensor::channelToFrequency($channel); + $data[$id] = WirelessSensor::channelToFrequency($channel); + } } return $data; diff --git a/includes/dbFacile.php b/includes/dbFacile.php index 6ad9d4146385..04df31f8c8ef 100644 --- a/includes/dbFacile.php +++ b/includes/dbFacile.php @@ -60,21 +60,25 @@ function dbQuery($sql, $parameters = []) * @deprecated Please use Eloquent instead; https://laravel.com/docs/eloquent#inserting-and-updating-models * @see https://laravel.com/docs/eloquent#inserting-and-updating-models */ -function dbInsert($data, $table) +function dbInsert($data, $table): ?int { $sql = 'INSERT IGNORE INTO `' . $table . '` (`' . implode('`,`', array_keys($data)) . '`) VALUES (' . implode(',', dbPlaceHolders($data)) . ')'; try { $result = Eloquent::DB()->insert($sql, (array) $data); + + if ($result) { + $lastInsertId = Eloquent::DB()->getPdo()->lastInsertId(); + + if ($lastInsertId) { + return (int) $lastInsertId; + } + } } catch (PDOException $pdoe) { dbHandleException(new QueryException('dbFacile', $sql, $data, $pdoe)); } - if ($result) { - return Eloquent::DB()->getPdo()->lastInsertId(); - } else { - return null; - } + return null; }//end dbInsert() /** diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index e88ec2567451..23ed6f44115a 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -381,6 +381,7 @@ 'rlPethPsePortOutputPower', ]; + $port_stats_temp = []; foreach ($linksys_poe_oids as $oid) { $port_stats_temp = snmpwalk_cache_oid($device, $oid, $port_stats_temp, 'LINKSYS-POE-MIB:POWER-ETHERNET-MIB'); } diff --git a/tests/data/timos_ixr-s.json b/tests/data/timos_ixr-s.json index 943f060a51c0..625cde2c75d7 100644 --- a/tests/data/timos_ixr-s.json +++ b/tests/data/timos_ixr-s.json @@ -13828,8 +13828,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.1", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.1", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.1", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.1", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 1", "group": "Fan State", @@ -13853,8 +13853,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.2", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.2", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.2", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.2", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 2", "group": "Fan State", @@ -13878,8 +13878,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.3", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.3", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.3", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.3", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 3", "group": "Fan State", @@ -13903,8 +13903,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.4", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.4", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.4", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.4", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 4", "group": "Fan State", @@ -13928,8 +13928,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.5", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.5", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.5", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.5", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 5", "group": "Fan State", @@ -13953,8 +13953,8 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.6", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.6", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.6", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.6", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 6", "group": "Fan State", @@ -15635,7 +15635,7 @@ "group": null, "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 1, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -15644,7 +15644,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 1, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxChassisOverTempState" @@ -15835,7 +15835,7 @@ "group": null, "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 2, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -15844,7 +15844,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 2, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxHwAlarmState" @@ -15860,7 +15860,7 @@ "group": null, "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 2, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -15869,7 +15869,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 2, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxHwAlarmState" @@ -16003,14 +16003,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.1", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.1", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.1", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.1", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 1", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16019,7 +16019,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus" @@ -16028,14 +16028,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.2", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.2", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.2", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.2", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 2", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16044,7 +16044,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus" @@ -16053,14 +16053,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.3", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.3", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.3", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.3", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 3", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16069,7 +16069,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus" @@ -16078,14 +16078,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.4", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.4", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.4", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.4", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 4", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16094,7 +16094,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus" @@ -16103,14 +16103,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.5", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.5", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.5", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.5", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 5", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16119,7 +16119,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus" @@ -16128,14 +16128,14 @@ "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", - "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.routerChassis.1.6", - "sensor_index": "tmnxPhysChassisFanOperStatus.routerChassis.1.6", + "sensor_oid": ".1.3.6.1.4.1.6527.3.1.2.2.1.24.1.1.2.3.1.6", + "sensor_index": "tmnxPhysChassisFanOperStatus.3.1.6", "sensor_type": "tmnxPhysChassisFanOperStatus", "sensor_descr": "Fan 6", "group": "Fan State", "sensor_divisor": 1, "sensor_multiplier": 1, - "sensor_current": 0, + "sensor_current": 3, "sensor_limit": null, "sensor_limit_warn": null, "sensor_limit_low": null, @@ -16144,7 +16144,7 @@ "sensor_custom": "No", "entPhysicalIndex": null, "entPhysicalIndex_measured": null, - "sensor_prev": 3, + "sensor_prev": null, "user_func": null, "rrd_type": "GAUGE", "state_name": "tmnxPhysChassisFanOperStatus"