Issues (2963)

includes/discovery/storage/vrp.inc.php (2 issues)

1
<?php
2
/**
3
 * oceanstor.inc.php
4
 *
5
 * LibreNMS storage discovery module for Huawei OceanStor
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  2017 Neil Lathwood
22
 * @copyright  2020 PipoCanaja
23
 * @author     Neil Lathwood <[email protected]>
24
 */
25
26
if ($device['os'] === 'vrp') {
27
    $vrp_tmp = snmpwalk_cache_oid($device, 'hwStorageEntry', null, 'HUAWEI-FLASH-MAN-MIB');
0 ignored issues
show
Are you sure the assignment to $vrp_tmp is correct as snmpwalk_cache_oid($devi...'HUAWEI-FLASH-MAN-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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
/*
29
 * array (
30
 *   1 =>
31
 *   array (
32
 *     'hwStorageType' => 'flash',
33
 *     'hwStorageSpace' => '206324',
34
 *     'hwStorageSpaceFree' => '59084',
35
 *     'hwStorageName' => 'flash:',
36
 *     'hwStorageDescr' => 'System Flash',
37
 *   ),
38
 * )
39
 */
40
    if (is_array($vrp_tmp)) {
0 ignored issues
show
The condition is_array($vrp_tmp) is always false.
Loading history...
41
        echo 'storageEntry ';
42
        foreach ($vrp_tmp as $index => $storage) {
43
            $fstype = 'dsk';
44
            $descr = $storage['hwStorageDescr'];
45
            if (empty($descr)) {
46
                $descr = $storage['hwStorageName'];
47
            }
48
            $units = 1024;
49
            if (is_numeric($storage['hwStorageSpace']) && is_numeric($storage['hwStorageSpaceFree'])) {
50
                $total = $storage['hwStorageSpace'] * $units;
51
                $used = $total - $storage['hwStorageSpaceFree'] * $units;
52
                discover_storage($valid_storage, $device, $index, $fstype, 'vrp', $descr, $total, $units, $used);
53
            }
54
        }
55
    }
56
    unset($vrp_tmp);
57
}
58