Issues (2963)

includes/html/graphs/device/poller_perf.inc.php (1 issue)

1
<?php
2
3
/*
4
 * LibreNMS
5
 *
6
 * Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
7
 *
8
 * This program is free software: you can redistribute it and/or modify it
9
 * under the terms of the GNU General Public License as published by the
10
 * Free Software Foundation, either version 3 of the License, or (at your
11
 * option) any later version.  Please see LICENSE.txt at the top level of
12
 * the source code distribution for details.
13
 */
14
use LibreNMS\Config;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Config. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
15
16
$scale_min = '0';
17
18
require 'includes/html/graphs/common.inc.php';
19
20
$rrd_filename = Rrd::name($device['hostname'], 'poller-perf');
21
22
$rrd_options .= ' DEF:poller=' . $rrd_filename . ':poller:AVERAGE';
23
$rrd_options .= " 'COMMENT:Seconds      Cur     Min     Max     Avg\\n'";
24
if (Config::get('applied_site_style') == 'dark') {
25
    $rrd_options .= ' LINE1.25:poller#63636d:Poller';
26
} else {
27
    $rrd_options .= ' LINE1.25:poller#36393d:Poller';
28
}
29
$rrd_options .= ' GPRINT:poller:LAST:%6.2lf  GPRINT:poller:MIN:%6.2lf';
30
$rrd_options .= " GPRINT:poller:MAX:%6.2lf  'GPRINT:poller:AVERAGE:%6.2lf\\n'";
31
32
if ($_GET['previous'] == 'yes') {
33
    $rrd_options .= " COMMENT:' \\n'";
34
    $rrd_options .= " DEF:pollerX=$rrd_filename:poller:AVERAGE:start=$prev_from:end=$from";
35
    $rrd_options .= " SHIFT:pollerX:$period";
36
    $rrd_options .= " LINE1.25:pollerX#CCCCCC:'Prev Poller'\t";
37
    $rrd_options .= ' GPRINT:pollerX:MIN:%6.2lf';
38
    $rrd_options .= " GPRINT:pollerX:MAX:%6.2lf  'GPRINT:pollerX:AVERAGE:%6.2lf\\n'";
39
}
40