1 | <?php |
||
2 | /** |
||
3 | * ict-pdu.inc.php |
||
4 | * |
||
5 | * LibreNMS current sensor discovery module for ICT DC Distribution Panel |
||
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 | // Output Current |
||
27 | $oids = snmpwalk_cache_oid($device, 'outputEntry', [], 'ICT-DISTRIBUTION-PANEL-MIB'); |
||
28 | |||
29 | foreach ($oids as $index => $entry) { |
||
30 | $output_number = (int) $entry['outputNumber'] + 1; |
||
31 | |||
32 | $descr = 'Output Current #' . $output_number; |
||
33 | if ($entry['outputName'] && $entry['outputName'] != '00') { |
||
34 | $descr .= ' ' . $entry['outputName']; |
||
35 | } |
||
36 | |||
37 | $divisor = 1; |
||
38 | $oid = '.1.3.6.1.4.1.39145.10.8.1.3.' . $index; |
||
39 | $type = 'ict-pdu'; |
||
40 | $current = (float) $entry['outputCurrent'] / $divisor; |
||
41 | |||
42 | discover_sensor($valid['sensor'], 'current', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); |
||
43 | } |
||
44 | |||
45 | // System Current |
||
46 | $systemCurrent = trim(snmp_get($device, 'systemCurrent.0', '-Oqv', 'ICT-DISTRIBUTION-PANEL-MIB'), '" '); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
47 | if (! empty($systemCurrent)) { |
||
48 | $divisor = 1; |
||
49 | $index = '7.0'; |
||
50 | $descr = 'System Current'; |
||
51 | $type = 'ict-pdu'; |
||
52 | $oid = '.1.3.6.1.4.1.39145.10.7.0'; |
||
53 | $current = $systemCurrent / $divisor; |
||
54 | |||
55 | discover_sensor($valid['sensor'], 'current', $device, $oid, $index, $type, $descr, $divisor, '1', null, null, null, null, $current); |
||
56 | } |
||
57 |