Issues (2963)

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

1
<?php
2
3
$divisor = '1';
4
$multiplier = '1';
5
6
// Check PDU2 MIB Inlets
7
$inlet_oids = snmp_walk($device, 'inletLabel', '-Osqn', 'PDU2-MIB');
8
$inlet_oids = trim($inlet_oids);
9
if ($inlet_oids) {
10
    d_echo('PDU2 MIB Inlet');
11
    foreach (explode("\n", $inlet_oids) as $inlet_data) {
12
        $inlet_data = trim($inlet_data);
13
        if ($inlet_data) {
14
            [$inlet_oid,$inlet_descr] = explode(' ', $inlet_data, 2);
15
            $inlet_split_oid = explode('.', $inlet_oid);
16
            $inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)] . '.' . $inlet_split_oid[(count($inlet_split_oid) - 1)];
17
            $inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.5";
18
            $inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.activePower", '-Ovq', 'PDU2-MIB'));
0 ignored issues
show
snmp_get($device, 'inlet...r', '-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

18
            $inlet_divisor = pow(10, /** @scrutinizer ignore-type */ snmp_get($device, "inletSensorDecimalDigits.$inlet_index.activePower", '-Ovq', 'PDU2-MIB'));
Loading history...
19
            $inlet_power = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.activePower", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
20
            if ($inlet_power >= 0) {
21
                discover_sensor($valid['sensor'], 'power', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, $multiplier, null, null, null, null, $inlet_power);
22
            }
23
        }
24
    }
25
}
26
27
// Check PDU MIB Outlets
28
$outlet_oids = snmp_walk($device, 'outletIndex', '-Osqn', 'PDU-MIB');
29
$outlet_oids = trim($outlet_oids);
30
if ($outlet_oids) {
31
    d_echo('PDU MIB Outlet');
32
    foreach (explode("\n", $outlet_oids) as $outlet_data) {
33
        $outlet_data = trim($outlet_data);
34
        if ($outlet_data) {
35
            [$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
36
            $outlet_split_oid = explode('.', $outlet_oid);
37
            $outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
38
            $outletsuffix = "$outlet_index";
39
            $outlet_insert_index = $outlet_index;
40
            $outlet_oid = ".1.3.6.1.4.1.13742.4.1.2.2.1.8.$outletsuffix";
41
            $outlet_descr = snmp_get($device, "outletLabel.$outletsuffix", '-Ovq', 'PDU-MIB');
42
            $outlet_power = (snmp_get($device, "outletApparentPower.$outletsuffix", '-Ovq', 'PDU-MIB'));
43
            if ($outlet_power >= 0) {
44
                discover_sensor($valid['sensor'], 'power', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $divisor, $multiplier, null, null, null, null, $outlet_power);
45
            }
46
        }
47
    }
48
}
49
50
// Check PDU2 MIB Outlets
51
$outlet_oids = snmp_walk($device, 'outletLabel', '-Osqn', 'PDU2-MIB');
52
$outlet_oids = trim($outlet_oids);
53
if ($outlet_oids) {
54
    d_echo('PDU2 MIB Outlet');
55
    foreach (explode("\n", $outlet_oids) as $outlet_data) {
56
        $outlet_data = trim($outlet_data);
57
        if ($outlet_data) {
58
            [$outlet_oid,$outlet_descr] = explode(' ', $outlet_data, 2);
59
            $outlet_split_oid = explode('.', $outlet_oid);
60
            $outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
61
            $outletsuffix = "$outlet_index";
62
            $outlet_insert_index = $outlet_index;
63
            $outlet_oid = ".1.3.6.1.4.1.13742.6.5.4.3.1.4.1.$outletsuffix.5";
64
            $outlet_descr = snmp_get($device, "outletName.1.$outletsuffix", '-Ovq', 'PDU2-MIB');
65
            if (! $outlet_descr) {
66
                $outlet_descr = 'Outlet ' . $outletsuffix;
67
            }
68
            $outlet_divisor = pow(10, snmp_get($device, "outletSensorDecimalDigits.1.$outlet_index.activePower", '-Ovq', 'PDU2-MIB'));
69
            $outlet_power = (snmp_get($device, "measurementsOutletSensorValue.1.$outlet_index.activePower", '-Ovq', 'PDU2-MIB') / $outlet_divisor);
70
            if ($outlet_power >= 0) {
71
                discover_sensor($valid['sensor'], 'power', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $outlet_divisor, $multiplier, null, null, null, null, $outlet_power);
72
            }
73
        }
74
    }
75
}
76