Issues (2963)

discovery/sensors/temperature/linux.inc.php (1 issue)

1
<?php
2
/*
3
 * cpu temp for raspberry pi
4
 * requires snmp extend agent script from librenms-agent
5
 */
6
7
use Illuminate\Support\Str;
8
use LibreNMS\Config;
9
10
$sensor_oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.9.114.97.115.112.98.101.114.114.121.1';
11
$value = snmp_get($device, $sensor_oid, '-Oqve');
12
$value = trim($value, '"');
0 ignored issues
show
It seems like $value can also be of type false; however, parameter $string of trim() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

12
$value = trim(/** @scrutinizer ignore-type */ $value, '"');
Loading history...
13
if (is_numeric($value)) {
14
    $sensor_type = 'raspberry_temp';
15
    $descr = 'CPU Temp';
16
    discover_sensor($valid['sensor'], 'temperature', $device, $sensor_oid, 1, $sensor_type, $descr, 1, 1, null, null, null, null, $value);
17
}
18
19
if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.232.')) {
20
    echo 'HP_ILO ';
21
    $oids = snmp_walk($device, '.1.3.6.1.4.1.232.6.2.6.8.1.2.1', '-Osqn', '');
22
    $oids = trim($oids);
23
    foreach (explode("\n", $oids) as $data) {
24
        $data = trim($data);
25
        if ($data != '') {
26
            [$oid] = explode(' ', $data);
27
            $split_oid = explode('.', $oid);
28
            $temperature_id = $split_oid[(count($split_oid) - 2)] . '.' . $split_oid[(count($split_oid) - 1)];
29
30
            $descr_oid = ".1.3.6.1.4.1.232.6.2.6.8.1.3.$temperature_id";
31
            $descr = snmp_get($device, $descr_oid, '-Oqnv', 'CPQHLTH-MIB', 'hp');
32
33
            $temperature_oid = ".1.3.6.1.4.1.232.6.2.6.8.1.4.$temperature_id";
34
            $temperature = snmp_get($device, $temperature_oid, '-Oqv', '');
35
36
            $threshold_oid = ".1.3.6.1.4.1.232.6.2.6.8.1.5.$temperature_id";
37
            $threshold = snmp_get($device, $threshold_oid, '-Oqv', '');
38
39
            if (! empty($temperature)) {
40
                discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, $oid, 'hpilo', $descr, '1', '1', null, null, null, $threshold, $temperature);
41
            }
42
        }
43
    }
44
}
45
46
if (preg_match('/(Linux).+(ntc)/', $device['sysDescr'])) {
47
    $sensor_type = 'chip_axp209_temperature';
48
    $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.112.111.119.101.114.45.115.116.97.';
49
    $lowlimit = -40;
50
    $lowwarnlimit = -35;
51
    $warnlimit = 120;
52
    $limit = 130;
53
    $descr = 'AXP209 Temperature';
54
    $index = '116.1';
55
    $value = snmp_get($device, $oid . $index, '-Oqv');
56
    if (is_numeric($value)) {
57
        discover_sensor($valid['sensor'], 'temperature', $device, $oid . $index, $index, $sensor_type, $descr, '1', '1', $lowlimit, $lowwarnlimit, $warnlimit, $limit, $value);
58
    }
59
}
60
61
include_once Config::get('install_dir') . '/includes/discovery/sensors/temperature/supermicro.inc.php';
62