Use Config helper (#10339)

remove usage of global variable
This commit is contained in:
Tony Murray
2019-06-23 00:29:12 -05:00
committed by GitHub
parent 342acf50f1
commit f3ba8947f7
367 changed files with 1589 additions and 1857 deletions
+5 -5
View File
@@ -48,16 +48,16 @@ function get_cache($host, $value)
function process_syslog($entry, $update)
{
global $config, $dev_cache;
global $dev_cache;
foreach ($config['syslog_filter'] as $bi) {
foreach (Config::get('syslog_filter') as $bi) {
if (strpos($entry['msg'], $bi) !== false) {
return $entry;
}
}
$entry['host'] = preg_replace("/^::ffff:/", "", $entry['host']);
if ($new_host = Config::get("syslog_xlate")[$entry['host']]) {
if ($new_host = Config::get("syslog_xlate.{$entry['host']}")) {
$entry['host'] = $new_host;
}
$entry['device_id'] = get_cache($entry['host'], 'device_id');
@@ -65,8 +65,8 @@ function process_syslog($entry, $update)
$os = get_cache($entry['host'], 'os');
$hostname = get_cache($entry['host'], 'hostname');
if ((isset($config['enable_syslog_hooks'])) && ($config['enable_syslog_hooks']) && (isset($config['os'][$os]['syslog_hook'])) && (is_array($config['os'][$os]['syslog_hook']))) {
foreach ($config['os'][$os]['syslog_hook'] as $k => $v) {
if (Config::get('enable_syslog_hooks') && is_array(Config::getOsSetting($os, 'syslog_hook'))) {
foreach (Config::getOsSetting($os, 'syslog_hook') as $k => $v) {
$syslogprogmsg = $entry['program'].": ".$entry['msg'];
if ((isset($v['script'])) && (isset($v['regex'])) && ((preg_match($v['regex'], $syslogprogmsg)))) {
shell_exec(escapeshellcmd($v['script']).' '.escapeshellarg($hostname).' '.escapeshellarg($os).' '.escapeshellarg($syslogprogmsg).' >/dev/null 2>&1 &');