Issues (2963)

includes/discovery/sensors/charge/apc.inc.php (1 issue)

1
<?php
2
3
$oids = snmp_get($device, '.1.3.6.1.4.1.318.1.1.1.2.3.1.0', '-OsqnU');
4
d_echo($oids . "\n");
0 ignored issues
show
Are you sure $oids of type false|string can be used in concatenation? ( Ignorable by Annotation )

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

4
d_echo(/** @scrutinizer ignore-type */ $oids . "\n");
Loading history...
5
6
// Try High-Precision First
7
if (! empty($oids)) {
8
    echo 'APC UPS Battery Charge High Precision';
9
    $type = 'apc';
10
    [$oid,$current] = explode(' ', $oids);
11
12
    $precision = 10;
13
    $sensorType = 'apc';
14
    $current_oid = '.1.3.6.1.4.1.318.1.1.1.2.3.1.0';
15
    $index = 0;
16
    $current_val = ($current / $precision);
17
    $limit = 100;
18
    $lowlimit = 0;
19
    $warnlimit = 10;
20
    $descr = 'Battery Charge';
21
22
    discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, 1, $lowlimit, $warnlimit, null, $limit, $current_val);
23
} else {
24
    // Try to just get capacity
25
    $oids = snmp_get($device, '.1.3.6.1.4.1.318.1.1.1.2.2.1.0', '-OsqnU');
26
    d_echo($oids . "\n");
27
28
    if (! empty($oids)) {
29
        echo 'APC UPS Battery Charge';
30
        $type = 'apc';
31
        [$oid,$current] = explode(' ', $oids);
32
33
        $precision = 1;
34
        $sensorType = 'apc';
35
        $current_oid = '.1.3.6.1.4.1.318.1.1.1.2.2.1.0';
36
        $index = 0;
37
        $current_val = $current;
38
        $limit = 100;
39
        $lowlimit = 0;
40
        $warnlimit = 10;
41
        $descr = 'Battery Charge';
42
43
        discover_sensor($valid['sensor'], 'charge', $device, $current_oid, $index, $sensorType, $descr, $precision, 1, $lowlimit, $warnlimit, null, $limit, $current_val);
44
    }
45
}//end if
46