Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions LibreNMS/OS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions includes/dbFacile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()

/**
Expand Down
1 change: 1 addition & 0 deletions includes/polling/ports.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
84 changes: 42 additions & 42 deletions tests/data/timos_ixr-s.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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,
Expand All @@ -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"
Expand Down