Revert "Poller command rewrite (#13414)" (#13524)

This reverts commit 1752d1efd4.
This commit is contained in:
Tony Murray
2021-11-16 21:40:29 -06:00
committed by GitHub
parent 1752d1efd4
commit f8764ddcb5
49 changed files with 304 additions and 1181 deletions
+8 -12
View File
@@ -33,7 +33,6 @@ use LibreNMS\Config;
use LibreNMS\Data\Source\SnmpResponse;
use LibreNMS\Exceptions\FileNotFoundException;
use LibreNMS\Exceptions\InvalidModuleException;
use LibreNMS\Poller;
use Symfony\Component\Yaml\Yaml;
class ModuleTestHelper
@@ -80,6 +79,8 @@ class ModuleTestHelper
*/
public function __construct($modules, $os, $variant = '')
{
global $influxdb;
$this->modules = self::resolveModuleDependencies((array) $modules);
$this->os = strtolower($os);
$this->variant = strtolower($variant);
@@ -195,10 +196,8 @@ class ModuleTestHelper
$save_vdebug = Debug::isVerbose();
Debug::set();
Debug::setVerbose(false);
\Log::setDefaultDriver('console');
discover_device($device, $this->parseArgs('discovery'));
$poller = app(Poller::class, ['device_spec' => $device_id, 'module_override' => $this->modules]);
$poller->poll();
poll_device($device, $this->parseArgs('poller'));
Debug::set($save_debug);
Debug::setVerbose($save_vdebug);
$collection_output = ob_get_contents();
@@ -534,7 +533,6 @@ class ModuleTestHelper
{
global $device;
Config::set('rrd.enable', false); // disable rrd
Config::set('rrdtool_version', '1.7.2'); // don't detect rrdtool version, rrdtool is not install on ci
if (! is_file($this->snmprec_file)) {
throw new FileNotFoundException("$this->snmprec_file does not exist!");
@@ -594,7 +592,7 @@ class ModuleTestHelper
// Dump the discovered data
$data = array_merge_recursive($data, $this->dumpDb($device['device_id'], $discovered_modules, 'discovery'));
DeviceCache::get($device_id)->refresh(); // refresh the device
$device = device_by_id_cache($device_id, true); // refresh the device array
// Run the poller
if ($this->quiet) {
@@ -603,9 +601,7 @@ class ModuleTestHelper
}
ob_start();
\Log::setDefaultDriver('console');
$poller = app(Poller::class, ['device_spec' => $device_id, 'module_override' => $this->modules]);
$poller->poll();
poll_device($device, $this->parseArgs('poller'));
$this->poller_output = ob_get_contents();
if ($this->quiet) {
@@ -621,12 +617,12 @@ class ModuleTestHelper
$polled_modules = array_keys($this->poller_module_output);
// Dump polled data
$data = array_merge_recursive($data, $this->dumpDb($device_id, $polled_modules, 'poller'));
$data = array_merge_recursive($data, $this->dumpDb($device['device_id'], $polled_modules, 'poller'));
// Remove the test device, we don't need the debug from this
if ($device['hostname'] == $snmpsim->getIp()) {
Debug::set(false);
delete_device($device_id);
delete_device($device['device_id']);
}
if (! $no_save) {
@@ -725,7 +721,7 @@ class ModuleTestHelper
// build joins
$join = '';
$select = ["`$table`.*"];
foreach ($info['joins'] ?? [] as $join_info) {
foreach ($info['joins'] ?: [] as $join_info) {
if (isset($join_info['custom'])) {
$join .= ' ' . $join_info['custom'];