1 | <?php |
||
2 | /** |
||
3 | * ict-pdu.inc.php |
||
4 | * |
||
5 | * LibreNMS status 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 | $oids = snmpwalk_cache_oid($device, 'outputEntry', [], 'ICT-DISTRIBUTION-PANEL-MIB'); |
||
26 | |||
27 | if (is_array($oids)) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
28 | $state_name = 'outputFuseStatus'; |
||
29 | $states = [ |
||
30 | ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'OK'], |
||
31 | ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'OPEN'], |
||
32 | ]; |
||
33 | create_state_index($state_name, $states); |
||
34 | |||
35 | foreach ($oids as $index => $entry) { |
||
36 | $fuse_state_oid = '.1.3.6.1.4.1.39145.10.8.1.4.' . $index; |
||
37 | $fuse_number = (int) $index + 1; |
||
38 | $descr = 'Fuse #' . $fuse_number; |
||
39 | |||
40 | $current_value_string = $entry[$state_name]; |
||
41 | if ($current_value_string == 'OK') { |
||
42 | $current_value = 1; |
||
43 | } elseif ($current_value_string == 'OPEN') { |
||
44 | $current_value = 2; |
||
45 | } |
||
46 | |||
47 | discover_sensor($valid['sensor'], 'state', $device, $fuse_state_oid, $index, $state_name, $descr, 1, 1, null, null, null, null, $current_value, 'snmp', $index); |
||
48 | |||
49 | create_sensor_to_state_index($device, $state_name, $index); |
||
50 | } |
||
51 | } |
||
52 |