Error reporting (#14190)

* Error reporting

* Move code to ErrorReportingProvider
Enable reporting of error (and warning) messages.
report module exceptions

* Restore flare key
Not needed to set late anymore.  We set up filtering before it is initialized.

* Remove unnecessary and maybe double Flare report

* lint

* Cannot use typed properties yet, use phpdoc

* fix handleError return type

* Filter both exceptions and reports (so we don't miss any)
Consolidate the check if reporting should be enabled

* Cache reportingEnabled check for the runtime

* Split out middleware to improve readability
Logging of why reporting is disabled
Fix reportingEnabled cache

* Style

* Return some user data

* Change to class based middleware, it looks nicer

* Fix error page error id report, add url.

* also rewrite intended url

* remove link

* Move ignition to production and update flare-client

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Jellyfrog 2022-08-24 00:33:28 +02:00 committed by GitHub
parent 9ce05d7628
commit 1dbab5ac7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 760 additions and 205 deletions

View File

@ -47,7 +47,7 @@ class Config
public static function load()
{
// don't reload the config if it is already loaded, reload() should be used for that
if (! is_null(self::$config)) {
if (self::isLoaded()) {
return self::$config;
}
@ -566,4 +566,14 @@ class Config
self::set('db_port', config("database.connections.$db.port", 3306));
self::set('db_socket', config("database.connections.$db.unix_socket"));
}
/**
* Check if the config has been loaded yet
*
* @return bool
*/
public static function isLoaded(): bool
{
return ! is_null(self::$config);
}
}

View File

@ -190,6 +190,7 @@ class Poller
// isolate module exceptions so they don't disrupt the polling process
$this->logger->error("%rError polling $module module for {$this->device->hostname}.%n $e", ['color' => true]);
\Log::event("Error polling $module module. Check log file for more details.", $this->device, 'poller', Alert::ERROR);
report($e);
}
app(MeasurementManager::class)->printChangedStats();

View File

@ -27,6 +27,7 @@ namespace LibreNMS\Util;
use Carbon\Carbon;
use LibreNMS\Config;
use Symfony\Component\Process\Process;
class Git
{
@ -53,4 +54,45 @@ class Git
{
return \Date::createFromTimestamp(exec("git show --pretty='%ct' -s HEAD"));
}
public static function unchanged(): bool
{
$process = new Process(['git', 'diff-index', '--quiet', 'HEAD']);
$process->disableOutput();
$process->run();
return $process->getExitCode() === 0;
}
/**
* Note: It assumes origin/master points to github.com/librenms/librenms for this to work.
*/
public static function officalCommit(?string $hash = null, string $remote = 'origin/master'): bool
{
if ($hash === null) {
$process = new Process(['git', 'rev-parse', 'HEAD']);
$process->run();
$hash = trim($process->getOutput());
}
$process = new Process(['git', 'branch', '--remotes', '--contains', $hash, $remote]);
$process->run();
if ($process->isSuccessful()) {
if (trim($process->getOutput()) == $remote) {
return true;
}
}
return false;
}
public static function remoteUrl(string $remote = 'origin'): string
{
$process = new Process(['git', 'ls-remote', '--get-url', $remote]);
$process->run();
return trim($process->getOutput());
}
}

View File

@ -0,0 +1,66 @@
<?php
/**
* CleanContext.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2022 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Logging\Reporting\Middleware;
use Facade\FlareClient\Report;
class CleanContext
{
/**
* Middleware to remove sensitive data from the context.
*
* @param \Facade\FlareClient\Report $report
* @param callable $next
* @return mixed
*/
public function handle(Report $report, $next)
{
try {
$report->setApplicationPath('');
$context = $report->allContext();
if (isset($context['request']['url'])) {
$context['request']['url'] = str_replace($context['headers']['host'] ?? '', 'librenms', $context['request']['url']);
}
if (isset($context['session']['url']['intended'])) {
$context['session']['url']['intended'] = str_replace($context['headers']['host'] ?? '', 'librenms', $context['session']['url']['intended']);
}
if (isset($context['session']['_previous']['url'])) {
$context['session']['_previous']['url'] = str_replace($context['headers']['host'] ?? '', 'librenms', $context['session']['_previous']['url']);
}
$context['headers']['host'] = null;
$context['headers']['referer'] = null;
$report->userProvidedContext($context);
} catch (\Exception $e) {
}
return $next($report);
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* SetGroups.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2022 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Logging\Reporting\Middleware;
use Facade\FlareClient\Report;
use LibreNMS\Util\Version;
class SetGroups
{
/**
* Middleware to set LibreNMS and Tools grouping data
*
* @param \Facade\FlareClient\Report $report
* @param callable $next
* @return mixed
*/
public function handle(Report $report, $next)
{
try {
$version = Version::get();
$report->group('LibreNMS', [
'Git version' => $version->local(),
'App version' => Version::VERSION,
]);
$report->group('Tools', [
'Database' => $version->databaseServer(),
'Net-SNMP' => $version->netSnmp(),
'Python' => $version->python(),
'RRDtool' => $version->rrdtool(),
]);
} catch (\Exception $e) {
}
return $next($report);
}
}

View File

@ -40,6 +40,11 @@ class User extends Authenticatable
'can_modify_passwd' => 'integer',
];
public function toFlare(): array
{
return $this->only(['level', 'auth_type', 'enabled']);
}
// ---- Helper Functions ----
/**

View File

@ -90,7 +90,7 @@ class AppServiceProvider extends ServiceProvider
private function registerFacades()
{
// replace log manager so we can add the event function
$this->app->bind('log', function ($app) {
$this->app->singleton('log', function ($app) {
return new \App\Facades\LogManager($app);
});
}

View File

@ -0,0 +1,156 @@
<?php
/**
* ErrorReportingProvider.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @link https://www.librenms.org
*
* @copyright 2022 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/
namespace App\Providers;
use App\Logging\Reporting\Middleware\CleanContext;
use App\Logging\Reporting\Middleware\SetGroups;
use ErrorException;
use Facade\FlareClient\Report;
use Facade\Ignition\Facades\Flare;
use Illuminate\Support\Str;
use LibreNMS\Config;
use LibreNMS\Util\Git;
class ErrorReportingProvider extends \Facade\Ignition\IgnitionServiceProvider
{
/** @var int */
protected $errorReportingLevel = E_ALL & ~E_NOTICE;
/** @var callable */
private $laravelErrorHandler;
/** @var bool */
private $reportingEnabled;
public function boot(): void
{
Flare::filterExceptionsUsing(function (\Exception $e) {
return $this->isReportingEnabled();
});
Flare::filterReportsUsing(function (Report $report) {
return $this->isReportingEnabled();
});
Flare::determineVersionUsing(function () {
return \LibreNMS\Util\Version::VERSION;
});
// Filter some extra fields for privacy
// Move to header middleware when switching to spatie/laravel-ignition
Flare::registerMiddleware(CleanContext::class);
// Add more LibreNMS related info
Flare::registerMiddleware(SetGroups::class);
// Override the Laravel error handler but save it to call when in modern code
$this->laravelErrorHandler = set_error_handler([$this, 'handleError']);
parent::boot();
}
/**
* Checks the state of the config and current install to determine if reporting should be enabled
* The primary factor is the setting reporting.error
*/
public function isReportingEnabled(): bool
{
if ($this->reportingEnabled !== null) {
return $this->reportingEnabled;
}
// safety check so we don't leak early reports (but reporting should not be loaded before the config is)
if (! Config::isLoaded()) {
return false;
}
$this->reportingEnabled = false; // don't cache before config is loaded
// check the user setting
if (! Config::get('reporting.error')) {
\Log::debug('Reporting disabled by user setting');
return false;
}
// Only run in production
if (! $this->app->isProduction()) {
\Log::debug('Reporting disabled because app is not in production');
return false;
}
// Check git
if (Git::repoPresent()) {
if (! Str::contains(Git::remoteUrl(), ['git@github.com:librenms/librenms.git', 'https://github.com/librenms/librenms.git'])) {
\Log::debug('Reporting disabled because LibreNMS is not from the official repository');
return false;
}
if (! Git::unchanged()) {
\Log::debug('Reporting disabled because LibreNMS is not from the official repository');
return false;
}
if (! Git::officalCommit()) {
\Log::debug('Reporting disabled due to local modifications');
return false;
}
}
$this->reportingEnabled = true;
return true;
}
/**
* Report PHP deprecations, or convert PHP errors to ErrorException instances.
*
* @param int $level
* @param string $message
* @param string $file
* @param int $line
* @param array $context
* @return bool
*
* @throws \ErrorException
*/
public function handleError($level, $message, $file = '', $line = 0, $context = []): bool
{
// report errors if they are allowed
if ($this->errorReportingLevel & $level) {
Flare::report(new ErrorException($message, 0, $level, $file, $line));
}
// call the laravel error handler, unless using a legacy entry point (init.php)
if (! defined('IGNORE_ERRORS')) {
call_user_func($this->laravelErrorHandler, $level, $message, $file, $line);
}
return true;
}
}

View File

@ -29,6 +29,7 @@
"doctrine/dbal": "^2.11",
"easybook/geshi": "^1.0.8",
"ezyang/htmlpurifier": "^4.8",
"facade/ignition": "^2.17.6",
"fico7489/laravel-pivot": "^3.0",
"fruitcake/laravel-cors": "^2.0",
"genealabs/laravel-caffeine": "^8.0",
@ -57,7 +58,6 @@
"require-dev": {
"barryvdh/laravel-debugbar": "^3.5",
"barryvdh/laravel-ide-helper": "^2.8",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"friendsofphp/php-cs-fixer": "^v3.4",
"laravel/dusk": "^6.15",
@ -87,7 +87,8 @@
"extra": {
"laravel": {
"dont-discover": [
"nunomaduro/laravel-console-summary"
"nunomaduro/laravel-console-summary",
"facade/ignition"
]
}
},

394
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ab30c6215e7fdbe2c7b485ae9f4c1317",
"content-hash": "eca53b0989abe1607b3f5ce9fd711db0",
"packages": [
{
"name": "amenadiel/jpgraph",
@ -1070,6 +1070,202 @@
},
"time": "2020-06-29T00:56:53+00:00"
},
{
"name": "facade/flare-client-php",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/facade/flare-client-php.git",
"reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/flare-client-php/zipball/213fa2c69e120bca4c51ba3e82ed1834ef3f41b8",
"reference": "213fa2c69e120bca4c51ba3e82ed1834ef3f41b8",
"shasum": ""
},
"require": {
"facade/ignition-contracts": "~1.0",
"illuminate/pipeline": "^5.5|^6.0|^7.0|^8.0",
"php": "^7.1|^8.0",
"symfony/http-foundation": "^3.3|^4.1|^5.0",
"symfony/mime": "^3.4|^4.0|^5.1",
"symfony/var-dumper": "^3.4|^4.0|^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"phpunit/phpunit": "^7.5",
"spatie/phpunit-snapshot-assertions": "^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Facade\\FlareClient\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Send PHP errors to Flare",
"homepage": "https://github.com/facade/flare-client-php",
"keywords": [
"exception",
"facade",
"flare",
"reporting"
],
"support": {
"issues": "https://github.com/facade/flare-client-php/issues",
"source": "https://github.com/facade/flare-client-php/tree/1.10.0"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2022-08-09T11:23:57+00:00"
},
{
"name": "facade/ignition",
"version": "2.17.6",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "6acd82e986a2ecee89e2e68adfc30a1936d1ab7c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/6acd82e986a2ecee89e2e68adfc30a1936d1ab7c",
"reference": "6acd82e986a2ecee89e2e68adfc30a1936d1ab7c",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"facade/flare-client-php": "^1.9.1",
"facade/ignition-contracts": "^1.0.2",
"illuminate/support": "^7.0|^8.0",
"monolog/monolog": "^2.0",
"php": "^7.2.5|^8.0",
"symfony/console": "^5.0",
"symfony/var-dumper": "^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"livewire/livewire": "^2.4",
"mockery/mockery": "^1.3",
"orchestra/testbench": "^5.0|^6.0",
"psalm/plugin-laravel": "^1.2"
},
"suggest": {
"laravel/telescope": "^3.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"laravel": {
"providers": [
"Facade\\Ignition\\IgnitionServiceProvider"
],
"aliases": {
"Flare": "Facade\\Ignition\\Facades\\Flare"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Facade\\Ignition\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A beautiful error page for Laravel applications.",
"homepage": "https://github.com/facade/ignition",
"keywords": [
"error",
"flare",
"laravel",
"page"
],
"support": {
"docs": "https://flareapp.io/docs/ignition-for-laravel/introduction",
"forum": "https://twitter.com/flareappio",
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2022-06-30T18:26:59+00:00"
},
{
"name": "facade/ignition-contracts",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition-contracts.git",
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
"shasum": ""
},
"require": {
"php": "^7.3|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v2.15.8",
"phpunit/phpunit": "^9.3.11",
"vimeo/psalm": "^3.17.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Facade\\IgnitionContracts\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://flareapp.io",
"role": "Developer"
}
],
"description": "Solution contracts for Ignition",
"homepage": "https://github.com/facade/ignition-contracts",
"keywords": [
"contracts",
"flare",
"ignition"
],
"support": {
"issues": "https://github.com/facade/ignition-contracts/issues",
"source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
},
"time": "2020-10-16T08:27:54+00:00"
},
{
"name": "fgrosse/phpasn1",
"version": "v2.4.0",
@ -9002,202 +9198,6 @@
],
"time": "2022-03-03T08:28:38+00:00"
},
{
"name": "facade/flare-client-php",
"version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/facade/flare-client-php.git",
"reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/flare-client-php/zipball/b2adf1512755637d0cef4f7d1b54301325ac78ed",
"reference": "b2adf1512755637d0cef4f7d1b54301325ac78ed",
"shasum": ""
},
"require": {
"facade/ignition-contracts": "~1.0",
"illuminate/pipeline": "^5.5|^6.0|^7.0|^8.0",
"php": "^7.1|^8.0",
"symfony/http-foundation": "^3.3|^4.1|^5.0",
"symfony/mime": "^3.4|^4.0|^5.1",
"symfony/var-dumper": "^3.4|^4.0|^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"phpunit/phpunit": "^7.5.16",
"spatie/phpunit-snapshot-assertions": "^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Facade\\FlareClient\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Send PHP errors to Flare",
"homepage": "https://github.com/facade/flare-client-php",
"keywords": [
"exception",
"facade",
"flare",
"reporting"
],
"support": {
"issues": "https://github.com/facade/flare-client-php/issues",
"source": "https://github.com/facade/flare-client-php/tree/1.9.1"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2021-09-13T12:16:46+00:00"
},
{
"name": "facade/ignition",
"version": "2.17.5",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "1d71996f83c9a5a7807331b8986ac890352b7a0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/1d71996f83c9a5a7807331b8986ac890352b7a0c",
"reference": "1d71996f83c9a5a7807331b8986ac890352b7a0c",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"facade/flare-client-php": "^1.9.1",
"facade/ignition-contracts": "^1.0.2",
"illuminate/support": "^7.0|^8.0",
"monolog/monolog": "^2.0",
"php": "^7.2.5|^8.0",
"symfony/console": "^5.0",
"symfony/var-dumper": "^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14",
"livewire/livewire": "^2.4",
"mockery/mockery": "^1.3",
"orchestra/testbench": "^5.0|^6.0",
"psalm/plugin-laravel": "^1.2"
},
"suggest": {
"laravel/telescope": "^3.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"laravel": {
"providers": [
"Facade\\Ignition\\IgnitionServiceProvider"
],
"aliases": {
"Flare": "Facade\\Ignition\\Facades\\Flare"
}
}
},
"autoload": {
"files": [
"src/helpers.php"
],
"psr-4": {
"Facade\\Ignition\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A beautiful error page for Laravel applications.",
"homepage": "https://github.com/facade/ignition",
"keywords": [
"error",
"flare",
"laravel",
"page"
],
"support": {
"docs": "https://flareapp.io/docs/ignition-for-laravel/introduction",
"forum": "https://twitter.com/flareappio",
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2022-02-23T18:31:24+00:00"
},
{
"name": "facade/ignition-contracts",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition-contracts.git",
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
"reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267",
"shasum": ""
},
"require": {
"php": "^7.3|^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v2.15.8",
"phpunit/phpunit": "^9.3.11",
"vimeo/psalm": "^3.17.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Facade\\IgnitionContracts\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://flareapp.io",
"role": "Developer"
}
],
"description": "Solution contracts for Ignition",
"homepage": "https://github.com/facade/ignition-contracts",
"keywords": [
"contracts",
"flare",
"ignition"
],
"support": {
"issues": "https://github.com/facade/ignition-contracts/issues",
"source": "https://github.com/facade/ignition-contracts/tree/1.0.2"
},
"time": "2020-10-16T08:27:54+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.19.0",

View File

@ -178,6 +178,8 @@ return [
/*
* LibreNMS Service Providers...
*/
App\Providers\ConfigServiceProvider::class,
App\Providers\ErrorReportingProvider::class, // This should always be after the config is loaded
App\Providers\AppServiceProvider::class,
App\Providers\CliServiceProvider::class,
App\Providers\AuthServiceProvider::class,
@ -185,7 +187,6 @@ return [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\ConfigServiceProvider::class,
App\Providers\SocialiteListenersServiceProvider::class,
App\Providers\ComposerServiceProvider::class,
@ -246,6 +247,7 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,
'Flare' => Facade\Ignition\Facades\Flare::class,
// LibreNMS
'Permissions' => \App\Facades\Permissions::class,

70
config/flare.php Normal file
View File

@ -0,0 +1,70 @@
<?php
/*
| !!!! DO NOT EDIT THIS FILE !!!!
|
| You can change settings by setting them in the environment or .env
| If there is something you need to change, but is not available as an environment setting,
| request an environment variable to be created upstream or send a pull request.
*/
return [
/*
|
|--------------------------------------------------------------------------
| Flare API key
|--------------------------------------------------------------------------
|
| Specify Flare's API key below to enable error reporting to the service.
|
| More info: https://flareapp.io/docs/general/projects
|
*/
'key' => env('FLARE_KEY', 'quYFBTFNKHLBqFCoeo5yDVOQNbs6muV1'),
/*
|--------------------------------------------------------------------------
| Reporting Options
|--------------------------------------------------------------------------
|
| These options determine which information will be transmitted to Flare.
|
*/
'reporting' => [
'anonymize_ips' => true,
'collect_git_information' => true,
'report_queries' => true,
'maximum_number_of_collected_queries' => 200,
'report_query_bindings' => true,
'report_view_data' => true,
'grouping_type' => null,
'report_logs' => false,
'maximum_number_of_collected_logs' => 200,
'censor_request_body_fields' => ['username', 'password', 'sysContact', 'community', 'authname', 'authpass', 'cryptopass'],
],
/*
|--------------------------------------------------------------------------
| Reporting Log statements
|--------------------------------------------------------------------------
|
| If this setting is `false` log statements won't be sent as events to Flare,
| no matter which error level you specified in the Flare log channel.
|
*/
'send_logs_as_events' => false,
/*
|--------------------------------------------------------------------------
| Censor request body fields
|--------------------------------------------------------------------------
|
| These fields will be censored from your request when sent to Flare.
|
*/
'censor_request_body_fields' => ['username', 'password', 'sysContact', 'community', 'authname', 'authpass', 'cryptopass'],
];

126
config/ignition.php Normal file
View File

@ -0,0 +1,126 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Editor
|--------------------------------------------------------------------------
|
| Choose your preferred editor to use when clicking any edit button.
|
| Supported: "phpstorm", "vscode", "vscode-insiders", "vscodium", "textmate", "emacs",
| "sublime", "atom", "nova", "macvim", "idea", "netbeans",
| "xdebug"
|
*/
'editor' => env('IGNITION_EDITOR', 'phpstorm'),
/*
|--------------------------------------------------------------------------
| Theme
|--------------------------------------------------------------------------
|
| Here you may specify which theme Ignition should use.
|
| Supported: "light", "dark", "auto"
|
*/
'theme' => env('IGNITION_THEME', 'auto'),
/*
|--------------------------------------------------------------------------
| Sharing
|--------------------------------------------------------------------------
|
| You can share local errors with colleagues or others around the world.
| Sharing is completely free and doesn't require an account on Flare.
|
| If necessary, you can completely disable sharing below.
|
*/
'enable_share_button' => env('IGNITION_SHARING_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Register Ignition commands
|--------------------------------------------------------------------------
|
| Ignition comes with an additional make command that lets you create
| new solution classes more easily. To keep your default Laravel
| installation clean, this command is not registered by default.
|
| You can enable the command registration below.
|
*/
'register_commands' => env('REGISTER_IGNITION_COMMANDS', false),
/*
|--------------------------------------------------------------------------
| Ignored Solution Providers
|--------------------------------------------------------------------------
|
| You may specify a list of solution providers (as fully qualified class
| names) that shouldn't be loaded. Ignition will ignore these classes
| and possible solutions provided by them will never be displayed.
|
*/
'ignored_solution_providers' => [
\Facade\Ignition\SolutionProviders\MissingPackageSolutionProvider::class,
],
/*
|--------------------------------------------------------------------------
| Runnable Solutions
|--------------------------------------------------------------------------
|
| Some solutions that Ignition displays are runnable and can perform
| various tasks. Runnable solutions are enabled when your app has
| debug mode enabled. You may also fully disable this feature.
|
*/
'enable_runnable_solutions' => env('IGNITION_ENABLE_RUNNABLE_SOLUTIONS', false),
/*
|--------------------------------------------------------------------------
| Remote Path Mapping
|--------------------------------------------------------------------------
|
| If you are using a remote dev server, like Laravel Homestead, Docker, or
| even a remote VPS, it will be necessary to specify your path mapping.
|
| Leaving one, or both of these, empty or null will not trigger the remote
| URL changes and Ignition will treat your editor links as local files.
|
| "remote_sites_path" is an absolute base path for your sites or projects
| in Homestead, Vagrant, Docker, or another remote development server.
|
| Example value: "/home/vagrant/Code"
|
| "local_sites_path" is an absolute base path for your sites or projects
| on your local computer where your IDE or code editor is running on.
|
| Example values: "/Users/<name>/Code", "C:\Users\<name>\Documents\Code"
|
*/
'remote_sites_path' => env('IGNITION_REMOTE_SITES_PATH', ''),
'local_sites_path' => env('IGNITION_LOCAL_SITES_PATH', ''),
/*
|--------------------------------------------------------------------------
| Housekeeping Endpoint Prefix
|--------------------------------------------------------------------------
|
| Ignition registers a couple of routes when it is enabled. Below you may
| specify a route prefix that will be used to host all internal links.
|
*/
'housekeeping_endpoint_prefix' => '_ignition',
];

View File

@ -45,13 +45,13 @@ return [
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'channels' => ['single', 'flare'],
'ignore_exceptions' => false,
],
'console' => [
'driver' => 'stack',
'channels' => ['single', 'stdout'],
'channels' => ['single', 'stdout', 'flare'],
'ignore_exceptions' => false,
],
@ -142,6 +142,10 @@ return [
'emergency' => [
'path' => storage_path('logs/laravel.log'),
],
'flare' => [
'driver' => 'flare',
],
],
];

View File

@ -155,6 +155,7 @@ function discover_device(&$device, $force_module = false)
// isolate module exceptions so they don't disrupt the polling process
Log::error("%rError discovering $module module for {$device['hostname']}.%n $e", ['color' => true]);
Log::event("Error discovering $module module. Check log file for more details.", $device['device_id'], 'discovery', Alert::ERROR);
report($e);
}
$module_time = microtime(true) - $module_start;

View File

@ -37,6 +37,7 @@ global $vars, $console_color;
error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
const IGNORE_ERRORS = true;
$install_dir = realpath(__DIR__ . '/..');
chdir($install_dir);
@ -87,7 +88,6 @@ if (module_selected('web', $init_modules)) {
Laravel::bootCli();
}
Debug::set($debug ?? false); // override laravel configured settings (hides legacy errors too)
restore_error_handler(); // disable Laravel error handler
if (! module_selected('nodb', $init_modules)) {
if (! \LibreNMS\DB\Eloquent::isConnected()) {

View File

@ -333,6 +333,7 @@ function poll_device($device, $force_module = false)
// isolate module exceptions so they don't disrupt the polling process
Log::error("%rError polling $module module for {$device['hostname']}.%n $e", ['color' => true]);
Log::event("Error polling $module module. Check log file for more details.", $device['device_id'], 'poller', Alert::ERROR);
report($e);
}
$module_time = microtime(true) - $module_start;

View File

@ -5611,6 +5611,10 @@
"section": "smokeping",
"order": 3,
"type": "text"
},
"reporting.error": {
"default": false,
"type": "boolean"
}
}
}

View File

@ -75,6 +75,10 @@
<p>{{ __("Check your log for more details.") }} ({{ isset($log_file) ? $log_file : 'librenms.log' }})</p>
<p>{{ __("If you need additional help, you can find how to get help at") }} <a target="_blank" href="https://docs.librenms.org/Support">https://docs.librenms.org/Support</a>.</p>
@if(! empty(Flare::sentReports()->all()))
<p>{{ __("Please include this Error-ID when reporting problems:") }} <b>{{ Flare::sentReports()->latestUuid() }}</b></p>
@endif
</div>
</body>
</html>