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

View File

@@ -21,7 +21,7 @@ $sqlparams = array();
$options = getopt('h:m:i:n:d::v::a::q', array('os:','type:'));
if (!isset($options['q'])) {
echo $config['project_name_version']." Discovery\n";
echo \LibreNMS\Config::get('project_name_version') . " Discovery\n";
}
if (isset($options['h'])) {
@@ -111,8 +111,8 @@ $module_override = parse_modules('discovery', $options);
$discovered_devices = 0;
if (!empty($config['distributed_poller_group'])) {
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
if (!empty(\LibreNMS\Config::get('distributed_poller_group'))) {
$where .= ' AND poller_group IN(' . \LibreNMS\Config::get('distributed_poller_group') . ')';
}
global $device;
@@ -125,7 +125,14 @@ $run = ($end - $start);
$proctime = substr($run, 0, 5);
if ($discovered_devices) {
dbInsert(array('type' => 'discover', 'doing' => $doing, 'start' => $start, 'duration' => $proctime, 'devices' => $discovered_devices, 'poller' => $config['distributed_poller_name']), 'perf_times');
dbInsert([
'type' => 'discover',
'doing' => $doing,
'start' => $start,
'duration' => $proctime,
'devices' => $discovered_devices,
'poller' => \LibreNMS\Config::get('distributed_poller_name')
], 'perf_times');
if ($doing === 'new') {
// We have added a new device by this point so we might want to do some other work
oxidized_reload_nodes();
@@ -136,7 +143,7 @@ if ($doing === 'new') {
$new_discovery_lock->release();
}
$string = $argv[0]." $doing ".date($config['dateformat']['compact'])." - $discovered_devices devices discovered in $proctime secs";
$string = $argv[0] . " $doing " . date(\LibreNMS\Config::get('dateformat.compact')) . " - $discovered_devices devices discovered in $proctime secs";
d_echo("$string\n");
if (!isset($options['q'])) {