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
+4 -6
View File
@@ -1,5 +1,6 @@
<?php
use LibreNMS\Config;
use LibreNMS\RRD\RrdDefinition;
function get_service_status($device = null)
@@ -115,21 +116,19 @@ function discover_service($device, $service)
function poll_service($service)
{
global $config;
$update = array();
$old_status = $service['service_status'];
$check_cmd = "";
// if we have a script for this check, use it.
$check_script = $config['install_dir'].'/includes/services/check_'.strtolower($service['service_type']).'.inc.php';
$check_script = Config::get('install_dir') . '/includes/services/check_' . strtolower($service['service_type']) . '.inc.php';
if (is_file($check_script)) {
include $check_script;
}
// If we do not have a cmd from the check script, build one.
if ($check_cmd == "") {
$check_cmd = $config['nagios_plugins'] . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
$check_cmd = Config::get('nagios_plugins') . "/check_" . $service['service_type'] . " -H " . ($service['service_ip'] ? $service['service_ip'] : $service['hostname']);
$check_cmd .= " " . $service['service_param'];
}
@@ -325,9 +324,8 @@ function check_service($command)
*/
function list_available_services()
{
global $config;
$services = array();
foreach (scandir($config['nagios_plugins']) as $file) {
foreach (scandir(Config::get('nagios_plugins')) as $file) {
if (substr($file, 0, 6) === 'check_') {
$services[] = substr($file, 6);
}