mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix: Discovery validation with ping-only devices (#7665)
* fix: validation check cli php extensions Fix fatal errors when mysql is not loaded / can't connect * fix: discovery validation incorrectly detects on ping only devices.
This commit is contained in:
committed by
Neil Lathwood
parent
52784ed189
commit
cbe6cb532d
@@ -61,6 +61,8 @@ class Php implements ValidationGroup
|
||||
foreach ($required_modules as $extension) {
|
||||
if (!extension_loaded($extension)) {
|
||||
$validator->fail("Missing PHP extension: $extension", "Please install $extension");
|
||||
} elseif (shell_exec("php -r \"var_export(extension_loaded('$extension'));\"") == 'false') {
|
||||
$validator->fail("Missing CLI PHP extension: $extension", "Please install $extension");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,11 @@ class Poller implements ValidationGroup
|
||||
*/
|
||||
public function validate(Validator $validator)
|
||||
{
|
||||
if (!dbIsConnected()) {
|
||||
$validator->warn("Could not check poller/discovery, db is not connected.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `devices`') == 0) {
|
||||
$result = ValidationResult::warn("You have not added any devices yet.");
|
||||
|
||||
@@ -128,9 +133,12 @@ class Poller implements ValidationGroup
|
||||
|
||||
private function checkLastDiscovered(Validator $validator)
|
||||
{
|
||||
if (dbFetchCell('SELECT COUNT(*) FROM `devices` WHERE `last_discovered` IS NOT NULL') == 0) {
|
||||
$incomplete_sql = "SELECT 1 FROM `devices` WHERE `last_discovered` <= DATE_ADD(NOW(), INTERVAL - 24 HOUR)
|
||||
AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1 AND `snmp_disable` = 0";
|
||||
|
||||
if (!dbFetchCell('SELECT 1 FROM `devices` WHERE `last_discovered` IS NOT NULL')) {
|
||||
$validator->fail('Discovery has never run. Check the cron job');
|
||||
} elseif (dbFetchCell("SELECT COUNT(*) FROM `devices` WHERE `last_discovered` <= DATE_ADD(NOW(), INTERVAL - 24 HOUR) AND `ignore` = 0 AND `disabled` = 0 AND `status` = 1") > 0) {
|
||||
} elseif (dbFetchCell($incomplete_sql)) {
|
||||
$validator->fail(
|
||||
"Discovery has not completed in the last 24 hours.",
|
||||
"Check the cron job to make sure it is running and using discovery-wrapper.py"
|
||||
|
||||
@@ -1131,7 +1131,7 @@ function version_info($remote = false)
|
||||
$output['local_date'] = $local_date;
|
||||
$output['local_branch'] = rtrim(`git rev-parse --abbrev-ref HEAD`);
|
||||
}
|
||||
$output['db_schema'] = get_db_schema() ?: '?';
|
||||
$output['db_schema'] = dbIsConnected() ? get_db_schema() : '?';
|
||||
$output['php_ver'] = phpversion();
|
||||
$output['mysql_ver'] = dbIsConnected() ? dbFetchCell('SELECT version()') : '?';
|
||||
$output['rrdtool_ver'] = str_replace('1.7.01.7.0', '1.7.0', implode(' ', array_slice(explode(' ', shell_exec(
|
||||
|
||||
@@ -50,6 +50,10 @@ function dbConnect($host = null, $user = '', $password = '', $database = '', $po
|
||||
return $database_link;
|
||||
}
|
||||
|
||||
if (!function_exists('mysqli_connect')) {
|
||||
throw new DatabaseConnectException("mysqli extension not loaded!");
|
||||
}
|
||||
|
||||
$host = empty($host) ? $config['db_host'] : $host;
|
||||
$user = empty($user) ? $config['db_user'] : $user;
|
||||
$password = empty($password) ? $config['db_pass'] : $password;
|
||||
|
||||
Reference in New Issue
Block a user