1 | <?php |
||
2 | /* |
||
3 | * LibreNMS module to capture NTP statistics |
||
4 | * |
||
5 | * Copyright (c) 2016 Aaron Daniels <[email protected]> |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify it |
||
8 | * under the terms of the GNU General Public License as published by the |
||
9 | * Free Software Foundation, either version 3 of the License, or (at your |
||
10 | * option) any later version. Please see LICENSE.txt at the top level of |
||
11 | * the source code distribution for details. |
||
12 | * |
||
13 | * This module will display NTP details from various device types. |
||
14 | * To display, modules must create rrd's named: ntp-%PEER%.rrd with the following DS': |
||
15 | * DS:stratum:GAUGE:'.\LibreNMS\Config::get('rrd.heartbeat').':0:U |
||
16 | * DS:offset:GAUGE:'.\LibreNMS\Config::get('rrd.heartbeat').':0:U |
||
17 | * DS:delay:GAUGE:'.\LibreNMS\Config::get('rrd.heartbeat').':0:U |
||
18 | * DS:dispersion:GAUGE:'.\LibreNMS\Config::get('rrd.heartbeat').':0:U |
||
19 | */ |
||
20 | |||
21 | use LibreNMS\Config; |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | if (file_exists(Config::get('install_dir') . "/includes/polling/ntp/{$device['os_group']}.inc.php")) { |
||
24 | include Config::get('install_dir') . "/includes/polling/ntp/{$device['os_group']}.inc.php"; |
||
25 | } |
||
26 | |||
27 | if ($device['os'] == 'awplus') { |
||
28 | include 'includes/polling/ntp/awplus.inc.php'; |
||
29 | } |
||
30 | |||
31 | unset( |
||
32 | $cntpPeersVarEntry, |
||
33 | $atNtpAssociationEntry |
||
34 | ); |
||
35 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/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 beforeOtherDir/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: