1 | <?php |
||
2 | /* |
||
3 | * LibreNMS NX-OS Fan state |
||
4 | * |
||
5 | * Copyright (c) 2016 Dave Bell <[email protected]> |
||
6 | * This program is free software: you can redistribute it and/or modify it |
||
7 | * under the terms of the GNU General Public License as published by the |
||
8 | * Free Software Foundation, either version 3 of the License, or (at your |
||
9 | * option) any later version. Please see LICENSE.txt at the top level of |
||
10 | * the source code distribution for details. |
||
11 | */ |
||
12 | |||
13 | $fan_tray_oid = '.1.3.6.1.4.1.9.9.117.1.4.1.1.1'; |
||
14 | $fan_trays = snmpwalk_cache_oid($device, $fan_tray_oid, []); |
||
15 | |||
16 | /* CISCO-ENTITY-FRU-CONTROL-MIB cefcFanTrayOperStatus |
||
17 | * unknown(1), |
||
18 | * up(2), |
||
19 | * down(3), |
||
20 | * warning(4) |
||
21 | */ |
||
22 | |||
23 | if (is_array($fan_trays)) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
24 | foreach ($fan_trays as $oid => $array) { |
||
25 | $state = current($array); |
||
26 | $split_oid = explode('.', $oid); |
||
27 | $index = $split_oid[(count($split_oid) - 1)]; |
||
28 | $current_oid = "$fan_tray_oid.$index"; |
||
29 | |||
30 | $entity_oid = '.1.3.6.1.2.1.47.1.1.1.1.7'; |
||
31 | $descr = trim(snmp_get($device, "$entity_oid.$index", '-Ovq'), '"'); |
||
32 | |||
33 | $state_name = 'cefcFanTrayOperStatus'; |
||
34 | $states = [ |
||
35 | ['value' => 1, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], |
||
36 | ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'up'], |
||
37 | ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'down'], |
||
38 | ['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], |
||
39 | ]; |
||
40 | create_state_index($state_name, $states); |
||
41 | |||
42 | discover_sensor($valid['sensor'], 'state', $device, $current_oid, $index, $state_name, $descr, 1, 1); |
||
43 | create_sensor_to_state_index($device, $state_name, $index); |
||
44 | } |
||
45 | } |
||
46 |