1<?php
2
3if ($device['os'] == 'hirschmann') {
4    ///////////////////////////
5    /// Power Supply Status ///
6    ///////////////////////////
7    $oid = snmpwalk_cache_multi_oid($device, 'hmPSTable', [], 'HMPRIV-MGMT-SNMP-MIB');
8    $cur_oid = '.1.3.6.1.4.1.248.14.1.2.1.3.';
9
10    if (is_array($oid)) {
11        //Create State Index
12        $state_name = 'hmPowerSupplyStatus';
13        $states = [
14            ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'ok'],
15            ['value' => 2, 'generic' => 2, 'graph' => 0, 'descr' => 'failed'],
16            ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'notInstalled'],
17            ['value' => 4, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'],
18        ];
19        create_state_index($state_name, $states);
20
21        foreach ($oid as $index => $entry) {
22            //Discover Sensors
23            discover_sensor($valid['sensor'], 'state', $device, $cur_oid . $index, 'hmPowerSupplyStatus' . $index, $state_name, 'Power Supply ' . $oid[$index]['hmPSID'], 1, 1, null, null, null, null, $oid[$index]['hmPowerSupplyStatus'], 'snmp', 'hmPowerSupplyStatus' . $index);
24
25            //Create Sensor To State Index
26            create_sensor_to_state_index($device, $state_name, 'hmPowerSupplyStatus' . $index);
27        }
28    }
29
30    ////////////////////////////////
31    /// Common LED Status States ///
32    ////////////////////////////////
33    $states = [
34        ['value' => 1, 'generic' => 0, 'graph' => 0, 'descr' => 'off'],
35        ['value' => 2, 'generic' => 0, 'graph' => 0, 'descr' => 'green'],
36        ['value' => 3, 'generic' => 1, 'graph' => 0, 'descr' => 'yellow'],
37        ['value' => 4, 'generic' => 2, 'graph' => 0, 'descr' => 'red'],
38    ];
39
40    ///////////////////////////////
41    /// LED Status Power Supply ///
42    ///////////////////////////////
43    $temp = snmp_get($device, 'hmLEDRSPowerSupply.0', '-Ovqe', 'HMPRIV-MGMT-SNMP-MIB');
44    $cur_oid = '.1.3.6.1.4.1.248.14.1.1.35.1.1.0';
45    $index = '0';
46
47    if (is_numeric($temp)) {
48        //Create State Index
49        $state_name = 'hmLEDRSPowerSupply';
50        create_state_index($state_name, $states);
51
52        $descr = 'LED Status Power Supply';
53        //Discover Sensors
54        discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSPowerSupply.' . $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSPowerSupply.' . $index);
55
56        //Create Sensor To State Index
57        create_sensor_to_state_index($device, $state_name, 'hmLEDRSPowerSupply.' . $index);
58    }
59
60    //////////////////////////
61    /// LED Status Standby ///
62    //////////////////////////
63    $temp = snmp_get($device, 'hmLEDRStandby.0', '-Ovqe', 'HMPRIV-MGMT-SNMP-MIB');
64    $cur_oid = '.1.3.6.1.4.1.248.14.1.1.35.1.2.0';
65    $index = '0';
66
67    if (is_numeric($temp)) {
68        //Create State Index
69        $state_name = 'hmLEDRStandby';
70        create_state_index($state_name, $states);
71
72        $descr = 'LED Status Standby';
73        //Discover Sensors
74        discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRStandby.' . $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRStandby.' . $index);
75
76        //Create Sensor To State Index
77        create_sensor_to_state_index($device, $state_name, 'hmLEDRStandby.' . $index);
78    }
79
80    /////////////////////////////////////
81    /// LED Status Redundancy Manager ///
82    /////////////////////////////////////
83    $temp = snmp_get($device, 'hmLEDRSRedundancyManager.0', '-Ovqe', 'HMPRIV-MGMT-SNMP-MIB');
84    $cur_oid = '.1.3.6.1.4.1.248.14.1.1.35.1.3.0';
85    $index = '0';
86
87    if (is_numeric($temp)) {
88        //Create State Index
89        $state_name = 'hmLEDRSRedundancyManager';
90        create_state_index($state_name, $states);
91
92        $descr = 'LED Status Redundancy Manager';
93        //Discover Sensors
94        discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSRedundancyManager.' . $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSRedundancyManager.' . $index);
95
96        //Create Sensor To State Index
97        create_sensor_to_state_index($device, $state_name, 'hmLEDRSRedundancyManager.' . $index);
98    }
99
100    ////////////////////////
101    /// LED Status Fault ///
102    ////////////////////////
103    $temp = snmp_get($device, 'hmLEDRSFault.0', '-Ovqe', 'HMPRIV-MGMT-SNMP-MIB');
104    $cur_oid = '.1.3.6.1.4.1.248.14.1.1.35.1.4.0';
105    $index = '0';
106
107    if (is_numeric($temp)) {
108        //Create State Index
109        $state_name = 'hmLEDRSFault';
110        create_state_index($state_name, $states);
111
112        $descr = 'LED Status Fault';
113        //Discover Sensors
114        discover_sensor($valid['sensor'], 'state', $device, $cur_oid, 'hmLEDRSFault.' . $index, $state_name, $descr, 1, 1, null, null, null, null, $temp, 'snmp', 'hmLEDRSFault.' . $index);
115
116        //Create Sensor To State Index
117        create_sensor_to_state_index($device, $state_name, 'hmLEDRSFault.' . $index);
118    }
119}
120