From 76910e4180c6c28435a018c6783ba67e28c5eaf1 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 5 May 2021 10:27:10 -0500 Subject: [PATCH] Debug and collect-snmp-data.php fixes (#12837) Fix output so it can be captured and typo in collect-snmp-data.php --- LibreNMS/Util/Debug.php | 7 +++++++ LibreNMS/Util/ModuleTestHelper.php | 6 +++--- config/logging.php | 10 ++++++++++ doc/Developing/os/Health-Information.md | 4 ++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/LibreNMS/Util/Debug.php b/LibreNMS/Util/Debug.php index 5623c7fbf8..78e006d053 100644 --- a/LibreNMS/Util/Debug.php +++ b/LibreNMS/Util/Debug.php @@ -35,6 +35,13 @@ class Debug private static $debug = false; private static $verbose = false; + /** + * Enable/disable debug output + * + * @param bool $debug whether to enable or disable debug output + * @param bool $silence Silence error output or output all errors except notices + * @return bool returns $debug + */ public static function set($debug = true, bool $silence = false): bool { self::$debug = (bool) $debug; diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index edceecb35e..e7452af6f4 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -189,13 +189,13 @@ class ModuleTestHelper // Run discovery ob_start(); $save_debug = Debug::isEnabled(); - $save_vedbug = Debug::isEnabled(); + $save_vdebug = Debug::isVerbose(); Debug::set(); - Debug::setVerbose(); + Debug::setVerbose(false); discover_device($device, $this->parseArgs('discovery')); poll_device($device, $this->parseArgs('poller')); Debug::set($save_debug); - Debug::setVerbose($save_vedbug); + Debug::setVerbose($save_vdebug); $collection_output = ob_get_contents(); ob_end_clean(); diff --git a/config/logging.php b/config/logging.php index 0dcc9edada..6682f73c10 100644 --- a/config/logging.php +++ b/config/logging.php @@ -96,6 +96,16 @@ return [ 'level' => 'debug', ], + 'stdout' => [ + 'driver' => 'monolog', + 'handler' => StreamHandler::class, + 'formatter' => \LibreNMS\Util\CliColorFormatter::class, + 'with' => [ + 'stream' => 'php://output', + ], + 'level' => 'debug', + ], + 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), diff --git a/doc/Developing/os/Health-Information.md b/doc/Developing/os/Health-Information.md index df2643f6fe..538fbf9951 100644 --- a/doc/Developing/os/Health-Information.md +++ b/doc/Developing/os/Health-Information.md @@ -85,9 +85,9 @@ For `data:` you have the following options: The only sensor we have defined here is airflow. The available options are as follows: -- `oid` (required): This is the name of the table you want to do the snmp walk on. +- `oid` (required): This is the name of the table you want to snmp walk for data. - `value` (optional): This is the key within the table that contains - the value. If not provided willuse `oid` + the value. If not provided will use `oid` - `num_oid` (required for PullRequests): If not provided, this parameter should be computed automatically by discovery process. This parameter is still required to submit a pull request. This is the numerical OID that contains