Poller command rewrite (#13414)

* core WIP

* try to finish up

* trim space too
and a couple of cleanups

* update test data

* put escapes back

* another net-snmp difference

* correct copy paste error

* WIP

* Use new code YAY

* a tiny bit more

* Kind of working

* Handle manual modules correctly

* convert core to modern module

* Only save metrics if modules is not overridden

* correct module exists check

* database error handling

* debug handling

* restore bad changes

* Introduce Actions
 RunAlertRulesAction
 UpdateDeviceGroupsAction

* tweaks to output

* Fix some issues in outside code

* Style fixes

* fixes to module status checks

* typehints!

* Use logger only and DI

* OS module not named correctly

* Work on quiet output a bit more

* generically don't change output when disabling debug if the driver is already stack

* Fix missing $device variable for legacy os polling
Fix missing dbFacile functions when no legacy modules polled in RunAlertRulesAction

* restore legacy os module shim

* use the new poller code for tests

* PollingDevice event

* Fix some issues and enable/disable error reporting around legacy modules

* typehints

* fully update baseline

* Use Process for version commands so we don't leak debug output.

* don't detect rrdtool version in ci every time

* style fixes

* Warning fixes

* more fixes

* re-update baseline

* remove diff noise

* fix up alerts
This commit is contained in:
Tony Murray
2021-11-16 16:59:46 -06:00
committed by GitHub
parent c61ccf5c48
commit 1752d1efd4
49 changed files with 1184 additions and 307 deletions

View File

@@ -32,7 +32,13 @@ use Log;
class Debug
{
/**
* @var bool
*/
private static $debug = false;
/**
* @var bool
*/
private static $verbose = false;
/**
@@ -49,20 +55,12 @@ class Debug
restore_error_handler(); // disable Laravel error handler
if (self::$debug) {
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
ini_set('log_errors', '0');
error_reporting(E_ALL & ~E_NOTICE);
self::enableErrorReporting();
self::enableCliDebugOutput();
self::enableQueryDebug();
} else {
ini_set('display_errors', '0');
ini_set('display_startup_errors', '0');
ini_set('log_errors', '1');
error_reporting($silence ? 0 : E_ERROR);
self::disableCliDebugOutput();
self::disableErrorReporting($silence);
self::disableCliDebugOutput($silence);
self::disableQueryDebug();
}
@@ -92,7 +90,7 @@ class Debug
return self::$verbose;
}
public static function disableQueryDebug()
public static function disableQueryDebug(): void
{
$db = Eloquent::DB();
@@ -102,21 +100,21 @@ class Debug
}
}
public static function enableCliDebugOutput()
public static function enableCliDebugOutput(): void
{
if (Laravel::isBooted() && App::runningInConsole()) {
Log::setDefaultDriver('console');
Log::setDefaultDriver('console_debug');
}
}
public static function disableCliDebugOutput()
public static function disableCliDebugOutput(bool $silence): void
{
if (Laravel::isBooted()) {
Log::setDefaultDriver('stack');
if (Laravel::isBooted() && Log::getDefaultDriver() !== 'stack') {
Log::setDefaultDriver(app()->runningInConsole() && ! $silence ? 'console' : 'stack');
}
}
public static function enableQueryDebug()
public static function enableQueryDebug(): void
{
static $sql_debug_enabled;
$db = Eloquent::DB();
@@ -141,4 +139,26 @@ class Debug
$sql_debug_enabled = true;
}
}
/**
* Disable error reporting, do not use with new code
*/
public static function disableErrorReporting(bool $silence = false): void
{
ini_set('display_errors', '0');
ini_set('display_startup_errors', '0');
ini_set('log_errors', '1');
error_reporting($silence ? 0 : E_ERROR);
}
/**
* Enable error reporting. Please call after disabling for legacy code
*/
public static function enableErrorReporting(): void
{
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
ini_set('log_errors', '0');
error_reporting(E_ALL & ~E_NOTICE);
}
}