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

@@ -1,5 +1,7 @@
<?php
use LibreNMS\Config;
$src = device_by_id_cache($_GET['src']);
// This is my translation of Smokeping's graphing.
@@ -11,7 +13,7 @@ require 'includes/html/graphs/common.inc.php';
require 'includes/html/graphs/device/smokeping_common.inc.php';
$i = 0;
$pings = $config['smokeping']['pings'];
$pings = Config::get('smokeping.pings');
$iter = 0;
$colourset = 'mixed';
@@ -28,7 +30,7 @@ if ($width > '500') {
}
$filename_dir = generate_smokeping_file($device);
if ($src['hostname'] == $config['own_hostname']) {
if ($src['hostname'] == Config::get('own_hostname')) {
$filename = $filename_dir . $device['hostname'].'.rrd';
if (!rrdtool_check_rrd_exists($filename_dir.$device['hostname'].'.rrd')) {
// Try with dots in hostname replaced by underscores
@@ -42,11 +44,11 @@ if ($src['hostname'] == $config['own_hostname']) {
}
}
if (!isset($config['graph_colours'][$colourset][$iter])) {
if (!Config::has("graph_colours.$colourset.$iter")) {
$iter = 0;
}
$colour = $config['graph_colours'][$colourset][$iter];
$colour = Config::get("graph_colours.$colourset.$iter");
$iter++;
$descr = rrdtool_escape($source, $descr_len);

View File

@@ -1,5 +1,7 @@
<?php
use LibreNMS\Config;
$dest = device_by_id_cache($_GET['dest']);
// This is my translation of Smokeping's graphing.
@@ -11,7 +13,7 @@ require 'includes/html/graphs/common.inc.php';
require 'includes/html/graphs/device/smokeping_common.inc.php';
$i = 0;
$pings = $config['smokeping']['pings'];
$pings = Config::get('smokeping.pings');
$iter = 0;
$colourset = 'mixed';
@@ -27,25 +29,26 @@ if ($width > '500') {
$rrd_options .= " COMMENT:'".substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5))." RTT Loss SDev RTT\:SDev \l'";
}
if ($device['hostname'] == $config['own_hostname']) {
$filename = $config['smokeping']['dir'].$dest['hostname'].'.rrd';
if ($device['hostname'] == Config::get('own_hostname')) {
$filename = Config::get('smokeping.dir') . $dest['hostname'] . '.rrd';
if (!rrdtool_check_rrd_exists($filename)) {
// Try with dots in hostname replaced by underscores
$filename = $config['smokeping']['dir'].str_replace('.', '_', $dest['hostname']).'.rrd';
$filename = Config::get('smokeping.dir') . str_replace('.', '_', $dest['hostname']) . '.rrd';
}
} else {
$filename = $config['smokeping']['dir'].$dest['hostname'].'~'.$device['hostname'].'.rrd';
$filename = Config::get('smokeping.dir') . $dest['hostname'] . '~' . $device['hostname'] . '.rrd';
if (!rrdtool_check_rrd_exists($filename)) {
// Try with dots in hostname replaced by underscores
$filename = $config['smokeping']['dir'].str_replace('.', '_', $dest['hostname']).'~'.$device['hostname'].'.rrd';
$filename = Config::get('smokeping.dir') . str_replace('.', '_', $dest['hostname']) . '~' . $device['hostname'] . '.rrd';
}
}
if (!isset($config['graph_colours'][$colourset][$iter])) {
if (!Config::has("graph_colours.$colourset.$iter")) {
$iter = 0;
}
$colour = $config['graph_colours'][$colourset][$iter];
$colour = Config::get("graph_colours.$colourset.$iter");
$iter++;
$descr = rrdtool_escape($source, $descr_len);