Issues (2963)

discovery/sensors/voltage/raritan-pdu.inc.php (1 issue)

1
<?php
2
/**
3
 * raritan-pdu.inc.php
4
 *
5
 * LibreNMS voltage sensor discovery module for Raritan
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
 *
22
 * @copyright  2017 Neil Lathwood
23
 * @author     Neil Lathwood <[email protected]>
24
 */
25
foreach ($pre_cache['raritan_inletTable'] as $index => $raritan_data) {
26
    for ($x = 1; $x <= $raritan_data['inletPoleCount']; $x++) {
27
        $tmp_index = "$index.$x";
28
        $new_index = "inletPoleVoltage.$tmp_index";
29
        $oid = '.1.3.6.1.4.1.13742.4.1.21.2.1.4.' . $tmp_index;
30
        $descr = 'Inlet ' . $pre_cache['raritan_inletPoleTable'][$index][$x]['inletPoleLabel'];
31
        $divisor = 1000;
32
        $low_limit = $raritan_data['inletVoltageUpperCritical'] / $divisor;
33
        $low_warn_limit = $raritan_data['inletVoltageUpperWarning'] / $divisor;
34
        $warn_limit = $raritan_data['inletVoltageLowerWarning'] / $divisor;
35
        $high_limit = $raritan_data['inletVoltageLowerCritical'] / $divisor;
36
        $current = $pre_cache['raritan_inletPoleTable'][$index][$x]['inletPoleVoltage'] / $divisor;
37
        discover_sensor($valid['sensor'], 'voltage', $device, $oid, $tmp_index, 'raritan', $descr, $divisor, 1, $low_limit, $low_limit, $warn_limit, $high_limit, $current);
38
    }
39
}
40
41
foreach ($pre_cache['raritan_inletLabel'] as $index => $inlet_data) {
42
    $inlet_descr = $inlet_data['inletLabel'];
43
    $inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$index.4";
44
    $inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$index.rmsVoltage", '-Ovq', 'PDU2-MIB'));
0 ignored issues
show
snmp_get($device, 'inlet...e', '-Ovq', 'PDU2-MIB') of type false|string is incompatible with the type double|integer expected by parameter $exp of pow(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

44
    $inlet_divisor = pow(10, /** @scrutinizer ignore-type */ snmp_get($device, "inletSensorDecimalDigits.$index.rmsVoltage", '-Ovq', 'PDU2-MIB'));
Loading history...
45
    $inlet_power = (snmp_get($device, "measurementsInletSensorValue.$index.rmsVoltage", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
46
47
    if ($inlet_power >= 0) {
48
        discover_sensor($valid['sensor'], 'voltage', $device, $inlet_oid, $index . '.rmsVoltage', 'raritan', $inlet_descr, $inlet_divisor, 1, null, null, null, null, $inlet_power);
49
    }
50
}
51