1 | <?php |
||
2 | /** |
||
3 | * nimbleos.inc.php |
||
4 | * |
||
5 | * LibreNMS storage discovery module for Nimble Storage |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify |
||
8 | * it under the terms of the GNU General Public License as published by |
||
9 | * the Free Software Foundation, either version 3 of the License, or |
||
10 | * (at your option) any later version. |
||
11 | * |
||
12 | * This program is distributed in the hope that it will be useful, |
||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
||
15 | * GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License |
||
18 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
||
19 | * |
||
20 | * @link https://www.librenms.org |
||
21 | * @copyright 2018 Ryan Finney |
||
22 | * @author https://github.com/theherodied/ |
||
23 | */ |
||
24 | use LibreNMS\Config; |
||
0 ignored issues
–
show
|
|||
25 | |||
26 | if ($device['os'] == 'nimbleos') { |
||
27 | $nimble_storage = snmpwalk_cache_oid($device, 'volEntry', null, 'NIMBLE-MIB'); |
||
28 | if (is_array($nimble_storage)) { |
||
29 | echo 'volEntry '; |
||
30 | foreach ($nimble_storage as $index => $storage) { |
||
31 | $units = 1024 * 1024; |
||
32 | $fstype = $storage['volOnline']; |
||
33 | $descr = $storage['volName']; |
||
34 | //nimble uses a high 32bit counter and a low 32bit counter to make a 64bit counter |
||
35 | $size = (($storage['volSizeHigh'] << 32) + $storage['volSizeLow']) * $units; |
||
36 | $used = (($storage['volUsageHigh'] << 32) + $storage['volUsageLow']) * $units; |
||
37 | if (is_numeric($index)) { |
||
38 | discover_storage($valid_storage, $device, $index, $fstype, 'nimbleos', $descr, $size, $units, $used); |
||
39 | } |
||
40 | unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $hrstorage_array); |
||
41 | } |
||
42 | } |
||
43 | } |
||
44 |
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: