1 | <?php |
||||
2 | |||||
3 | // Supermicro sensors |
||||
4 | $oids = snmp_walk($device, '.1.3.6.1.4.1.10876.2.1.1.1.1.3', '-Osqn', 'SUPERMICRO-HEALTH-MIB', 'supermicro'); |
||||
5 | $oids = trim($oids); |
||||
6 | if ($oids) { |
||||
7 | echo 'Supermicro '; |
||||
8 | foreach (explode("\n", $oids) as $data) { |
||||
9 | $data = trim($data); |
||||
10 | if ($data) { |
||||
11 | [$oid, $type] = explode(' ', $data); |
||||
12 | $oid_ex = explode('.', $oid); |
||||
13 | $index = $oid_ex[(count($oid_ex) - 1)]; |
||||
14 | if ($type == 2) { |
||||
15 | $temperature_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.4.$index"; |
||||
16 | $descr_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.2.$index"; |
||||
17 | $limit_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.5.$index"; |
||||
18 | $divisor_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.9.$index"; |
||||
19 | $monitor_oid = ".1.3.6.1.4.1.10876.2.1.1.1.1.10.$index"; |
||||
20 | $descr = snmp_get($device, $descr_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB', 'supermicro'); |
||||
21 | $temperature = snmp_get($device, $temperature_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB', 'supermicro'); |
||||
22 | $limit = snmp_get($device, $limit_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB', 'supermicro'); |
||||
23 | $divisor = snmp_get($device, $divisor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB', 'supermicro') || 1; |
||||
24 | $monitor = snmp_get($device, $monitor_oid, '-Oqv', 'SUPERMICRO-HEALTH-MIB', 'supermicro'); |
||||
25 | if ($monitor == 'true') { |
||||
26 | $descr = trim(str_ireplace('temperature', '', $descr)); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
It seems like
$descr can also be of type false ; however, parameter $subject of str_ireplace() does only seem to accept array|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
Loading history...
|
|||||
27 | discover_sensor($valid['sensor'], 'temperature', $device, $temperature_oid, trim($index, '.'), 'supermicro', $descr, (int) $divisor, '1', null, null, null, $limit, $temperature); |
||||
28 | } |
||||
29 | } |
||||
30 | } |
||||
31 | } |
||||
32 | } |
||||
33 |