Isolate poller and discovery modules (#9074)

An exception in one module should not interrupt the process for other modules.

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:
Tony Murray
2018-08-25 15:00:03 -05:00
committed by Neil Lathwood
parent 0a34a37d9e
commit c0b667ebc0
2 changed files with 20 additions and 2 deletions

View File

@@ -173,7 +173,16 @@ function discover_device(&$device, $force_module = false)
$module_start = microtime(true);
$start_memory = memory_get_usage();
echo "\n#### Load disco module $module ####\n";
include "includes/discovery/$module.inc.php";
try {
include "includes/discovery/$module.inc.php";
} catch (Exception $e) {
// isolate module exceptions so they don't disrupt the polling process
echo $e->getTraceAsString() .PHP_EOL;
c_echo("%rError in $module module.%n " . $e->getMessage() . PHP_EOL);
logfile("Error in $module module. " . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL);
}
$module_time = microtime(true) - $module_start;
$module_time = substr($module_time, 0, 5);
$module_mem = (memory_get_usage() - $start_memory);

View File

@@ -297,7 +297,16 @@ function poll_device($device, $force_module = false)
$start_memory = memory_get_usage();
$module_start = microtime(true);
echo "\n#### Load poller module $module ####\n";
include "includes/polling/$module.inc.php";
try {
include "includes/polling/$module.inc.php";
} catch (Exception $e) {
// isolate module exceptions so they don't disrupt the polling process
echo $e->getTraceAsString() .PHP_EOL;
c_echo("%rError in $module module.%n " . $e->getMessage() . PHP_EOL);
logfile("Error in $module module. " . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL);
}
$module_time = microtime(true) - $module_start;
$module_mem = (memory_get_usage() - $start_memory);
printf("\n>> Runtime for poller module '%s': %.4f seconds with %s bytes\n", $module, $module_time, $module_mem);