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

@@ -3,65 +3,59 @@
* Configuration file for Collectd graph browser
*/
if (isset($config['rrdgraph_def_text'])) {
$config['rrdgraph_def_text'] = str_replace(' ', ' ', $config['rrdgraph_def_text']);
$config['rrd_opts_array'] = explode(' ', trim($config['rrdgraph_def_text']));
use LibreNMS\Config;
if (Config::has('rrdgraph_def_text')) {
Config::set('rrdgraph_def_text', str_replace(' ', ' ', Config::get('rrdgraph_def_text')));
Config::set('rrd_opts_array', explode(' ', trim(Config::get('rrdgraph_def_text'))));
}
// Array of paths when collectd's rrdtool plugin writes RRDs
$config['datadirs'] = array($config['collectd_dir']);
Config::set('datadirs', [Config::get('collectd_dir')]);
// Width of graph to be generated by rrdgraph
if (isset($_GET['width'])) {
$config['rrd_width'] = $_GET['width'];
} else {
$config['rrd_width'] = 270;
}
Config::set('rrd_width', $_GET['width'] ?? 270);
// Height of graph to be generated by rrdgraph
if (isset($_GET['height'])) {
$config['rrd_height'] = $_GET['height'];
} else {
$config['rrd_height'] = 120;
}
Config::set('rrd_height', $_GET['height'] ?? 120);
// List of supported timespans (used for period drop-down list)
$config['timespan'] = array(
array(
'name' => 'hour',
'label' => 'past hour',
Config::set('timespan', [
[
'name' => 'hour',
'label' => 'past hour',
'seconds' => 3600,
),
array(
'name' => 'day',
'label' => 'past day',
],
[
'name' => 'day',
'label' => 'past day',
'seconds' => 86400,
),
array(
'name' => 'week',
'label' => 'past week',
],
[
'name' => 'week',
'label' => 'past week',
'seconds' => 604800,
),
array(
'name' => 'month',
'label' => 'past month',
],
[
'name' => 'month',
'label' => 'past month',
'seconds' => 2678400,
),
array(
'name' => 'year',
'label' => 'past year',
],
[
'name' => 'year',
'label' => 'past year',
'seconds' => 31622400,
),
);
],
]);
// Interval at which values are collectd (currently ignored)
$config['rrd_interval'] = 10;
Config::set('rrd_interval', 10);
// Average rows/rra (currently ignored)
$config['rrd_rows'] = 2400;
Config::set('rrd_rows', 2400);
// Additional options to pass to rrdgraph
// $config['rrd_opts'] = (isset($config['rrdgraph_defaults']) ? $config['rrdgraph_defaults'] : '');
// $config['rrd_opts'] = array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
// Config::set('rrd_opts', (Config::get('rrdgraph_defaults', ''));
// Config::set('rrd_opts', array('-E', "-c", "SHADEA#a5a5a5", "-c", "SHADEB#a5a5a5", "-c", "FONT#000000", "-c", "CANVAS#FFFFFF", "-c", "GRID#aaaaaa",
// "-c", "MGRID#FFAAAA", "-c", "FRAME#3e3e3e", "-c", "ARROW#5e5e5e", "-R", "normal");
// Predefined set of colors for use by collectd_draw_rrd()
$config['rrd_colors'] = array(
Config::set('rrd_colors', [
'h_1' => 'F7B7B7',
'f_1' => 'FF0000', // Red
'h_2' => 'B7EFB7',
@@ -88,14 +82,14 @@ $config['rrd_colors'] = array(
'f_12' => 'FF0051',
'h_13' => 'BBBBBB',
'f_13' => '555555',
);
]);
/*
* Path to TTF font file to use in error images
* (fallback when file does not exist is GD fixed font)
*/
$config['error_font'] = '/usr/share/fonts/corefonts/arial.ttf';
Config::set('error_font', '/usr/share/fonts/corefonts/arial.ttf');
/*
* Constant defining full path to rrdtool
*/
define('RRDTOOL', $config['rrdtool']);
define('RRDTOOL', Config::get('rrdtool'));