1 | <?php |
||||
2 | /** |
||||
3 | * microsemipdsine.inc.php |
||||
4 | * |
||||
5 | * LibreNMS temperature sensor discovery module for Microsemi PoE Switches |
||||
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 Lorenzo Zafra |
||||
23 | * @author Lorenzo Zafra<[email protected]> |
||||
24 | */ |
||||
25 | |||||
26 | // temperature |
||||
27 | |||||
28 | $temperature_unit = trim(snmp_get($device, '.1.3.6.1.4.1.7428.1.2.2.1.1.12.1', '-Oqv'), '" '); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
29 | $temperature = trim(snmp_get($device, '.1.3.6.1.4.1.7428.1.2.2.1.1.11.1', '-Oqv'), '" '); |
||||
30 | |||||
31 | if (! empty($temperature_unit) && ! empty($temperature)) { |
||||
32 | // If fahrenheit convert to celsius |
||||
33 | $function = null; |
||||
34 | if ($temperature_unit == '2') { |
||||
35 | $function = 'fahrenheit_to_celsius'; |
||||
36 | $temperature = fahrenheit_to_celsius($temperature); |
||||
0 ignored issues
–
show
$temperature of type string is incompatible with the type double expected by parameter $value of fahrenheit_to_celsius() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
37 | } |
||||
38 | |||||
39 | $divisor = 1; |
||||
40 | $index = '11.1'; |
||||
41 | $descr = 'Unit Temperature'; |
||||
42 | $type = 'microsemipdsine'; |
||||
43 | $oid = '.1.3.6.1.4.1.7428.1.2.2.1.1.11.1'; |
||||
44 | $current_value = $temperature / $divisor; |
||||
45 | |||||
46 | discover_sensor($valid['sensor'], 'temperature', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current_value, 'snmp', null, null, $function); |
||||
47 | } |
||||
48 |