1 | <?php |
||
2 | /** |
||
3 | * tegile.inc.php |
||
4 | * |
||
5 | * LibreNMS storage discovery module for Tegile 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 <http://www.storage snmpgnu.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'] == 'intelliflash') { |
||
27 | $tegile_storage = snmpwalk_cache_oid($device, 'poolEntry', null, 'TEGILE-MIB'); |
||
0 ignored issues
–
show
Are you sure the assignment to
$tegile_storage is correct as snmpwalk_cache_oid($devi...y', null, 'TEGILE-MIB') seems to always return null .
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
28 | if (is_array($tegile_storage)) { |
||
0 ignored issues
–
show
|
|||
29 | echo 'poolEntry '; |
||
30 | foreach ($tegile_storage as $index => $storage) { |
||
31 | $units = 1; |
||
32 | $fstype = $storage['poolState']; |
||
33 | $descr = $storage['poolName']; |
||
34 | //Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes. |
||
35 | $size = (($storage['poolSizeHigh'] << 32) + $storage['poolSizeLow']) * $units; |
||
36 | $used = (($storage['poolUsedSizeHigh'] << 32) + $storage['poolUsedSizeLow']) * $units; |
||
37 | if (is_numeric($index)) { |
||
38 | discover_storage($valid_storage, $device, $index, $fstype, 'intelliflash-pl', $descr, $size, $units, $used); |
||
39 | } |
||
40 | unset($deny, $fstype, $descr, $size, $used, $units, $storage_rrd, $old_storage_rrd, $hrstorage_array); |
||
41 | } |
||
42 | } |
||
43 | $tegile_storage2 = snmpwalk_cache_oid($device, 'projectEntry', null, 'TEGILE-MIB'); |
||
0 ignored issues
–
show
Are you sure the assignment to
$tegile_storage2 is correct as snmpwalk_cache_oid($devi...y', null, 'TEGILE-MIB') seems to always return null .
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
Loading history...
|
|||
44 | if (is_array($tegile_storage2)) { |
||
0 ignored issues
–
show
|
|||
45 | echo 'projectEntry '; |
||
46 | foreach ($tegile_storage2 as $index => $storage) { |
||
47 | $units = 1; |
||
48 | $descr = $storage['projectName']; |
||
49 | $fstype = 1; |
||
50 | $pdsh = ($storage['projectDataSizeHigh'] << 32); |
||
51 | $pdsl = ($storage['projectDataSizeLow']); |
||
52 | $pdst = (($pdsh + $pdsl) * $units); |
||
53 | $pfsh = ($storae['projectFreeSizeHigh'] << 32); |
||
54 | $pfsl = ($storage['projectFreeSizeLow']); |
||
55 | $pfst = (($pfsh + $pfsl) * $units); |
||
56 | //Tegile uses a high 32bit counter and a low 32bit counter to make a 64bit counter. Storage units are in bytes. |
||
57 | $size = ($pdst + $pfst); |
||
58 | $used = ($pdst); |
||
59 | $free = ($pfst); |
||
60 | if (is_numeric($index)) { |
||
61 | discover_storage($valid_storage, $device, $index, $fstype, 'intelliflash-pr', $descr, $size, $units, $used); |
||
62 | } |
||
63 | unset($deny, $fstype, $descr, $size, $used2, $units, $storage_rrd, $old_storage_rrd, $hrstorage_array); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 |
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: