mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: OS Discovery cleanup (Part 1) (#4335)
* refactor: OS Discovery cleanup (Part 1) Convert linux.inc.php to use new string functions Create OS discovery tests Use glob instead of readdir in os discovery (could change discovery order) Stop discovering once $os is set * Remove duplicate file header.
This commit is contained in:
committed by
Neil Lathwood
parent
f42406e2b0
commit
f6134f429c
@@ -106,20 +106,15 @@ function getHostOS($device)
|
||||
|
||||
d_echo("| $sysDescr | $sysObjectId | ");
|
||||
|
||||
$path = $config['install_dir'] . "/includes/discovery/os";
|
||||
$dir_handle = @opendir($path) or die("Unable to open $path");
|
||||
while ($file = readdir($dir_handle)) {
|
||||
if (preg_match("/.php$/", $file)) {
|
||||
include($config['install_dir'] . "/includes/discovery/os/" . $file);
|
||||
$pattern = $config['install_dir'] . '/includes/discovery/os/*.inc.php';
|
||||
foreach (glob($pattern) as $file) {
|
||||
include $file;
|
||||
if (isset($os)) {
|
||||
return $os;
|
||||
}
|
||||
}
|
||||
closedir($dir_handle);
|
||||
|
||||
if ($os) {
|
||||
return $os;
|
||||
} else {
|
||||
return "generic";
|
||||
}
|
||||
return "generic";
|
||||
}
|
||||
|
||||
function percent_colour($perc)
|
||||
|
Reference in New Issue
Block a user