mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix various issues with loading os definitions (#11640)
* Ping only device doesn't display if os was set to something, ping os wasn't loaded and we try to get overview graphs from it. * Fix snmp_disable device page load error When other os is set. * Revamp os setting loading the only safe way to access is Config::getOsSetting() * Remove getOsSetting fallback behavior Most instances don't use it and it can have unexpected results Config::getOsSetting('blah', 'group') == 'librenms' * refactor and remove unneeded load_os/loadOs calls now since getOsSetting automatically loads it. * restore unix overview graphs, they are different small cleanups * fix
This commit is contained in:
@@ -170,7 +170,6 @@ class Config
|
||||
|
||||
/**
|
||||
* Get a setting from the $config['os'] array using the os of the given device
|
||||
* If that is not set, fallback to the same global config key
|
||||
*
|
||||
* @param string $os The os name
|
||||
* @param string $key period separated config variable name
|
||||
@@ -180,21 +179,19 @@ class Config
|
||||
public static function getOsSetting($os, $key, $default = null)
|
||||
{
|
||||
if ($os) {
|
||||
\LibreNMS\Util\OS::loadDefinition($os);
|
||||
|
||||
if (isset(self::$config['os'][$os][$key])) {
|
||||
return self::$config['os'][$os][$key];
|
||||
}
|
||||
|
||||
if (!Str::contains($key, '.')) {
|
||||
return self::get($key, $default);
|
||||
}
|
||||
|
||||
$os_key = "os.$os.$key";
|
||||
if (self::has($os_key)) {
|
||||
return self::get($os_key);
|
||||
}
|
||||
}
|
||||
|
||||
return self::get($key, $default);
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +207,7 @@ class Config
|
||||
public static function getCombined($os, $key, $default = array())
|
||||
{
|
||||
if (!self::has($key)) {
|
||||
return self::get("os.$os.$key", $default);
|
||||
return self::getOsSetting($os, $key, $default);
|
||||
}
|
||||
|
||||
if (!isset(self::$config['os'][$os][$key])) {
|
||||
|
Reference in New Issue
Block a user