mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Support specifying submodules in poller and discovery for debug (#8896)
Mostly useful for debugging DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
committed by
Neil Lathwood
parent
33887417ee
commit
846cf11331
@@ -25,6 +25,7 @@
|
||||
|
||||
namespace LibreNMS\Device;
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Interfaces\Discovery\DiscoveryModule;
|
||||
use LibreNMS\Interfaces\Polling\PollerModule;
|
||||
use LibreNMS\OS;
|
||||
@@ -268,9 +269,18 @@ class Sensor implements DiscoveryModule, PollerModule
|
||||
{
|
||||
$table = static::$table;
|
||||
|
||||
$query = "SELECT * FROM `$table` WHERE `device_id` = ?";
|
||||
$params = [$os->getDeviceId()];
|
||||
|
||||
$submodules = Config::get('poller_submodules.wireless', []);
|
||||
if (!empty($submodules)) {
|
||||
$query .= " AND `sensor_class` IN " . dbGenPlaceholders(count($submodules));
|
||||
$params = array_merge($params, $submodules);
|
||||
}
|
||||
|
||||
// fetch and group sensors, decode oids
|
||||
$sensors = array_reduce(
|
||||
dbFetchRows("SELECT * FROM `$table` WHERE `device_id` = ?", array($os->getDeviceId())),
|
||||
dbFetchRows($query, $params),
|
||||
function ($carry, $sensor) {
|
||||
$sensor['sensor_oids'] = json_decode($sensor['sensor_oids']);
|
||||
$carry[$sensor['sensor_class']][] = $sensor;
|
||||
|
Reference in New Issue
Block a user