1 | <?php |
||
2 | /* |
||
3 | * LibreNMS |
||
4 | * |
||
5 | * Copyright (c) 2016 Peter TKATCHENKO https://github.com/Peter2121/ |
||
6 | * |
||
7 | * This program is free software: you can redistribute it and/or modify it |
||
8 | * under the terms of the GNU General Public License as published by the |
||
9 | * Free Software Foundation, either version 3 of the License, or (at your |
||
10 | * option) any later version. Please see LICENSE.txt at the top level of |
||
11 | * the source code distribution for details. |
||
12 | */ |
||
13 | |||
14 | $oids = snmp_walk($device, 'eqlMemberHealthStatus', '-OQne', 'EQLMEMBER-MIB', 'equallogic'); |
||
15 | |||
16 | d_echo('Health oids:'); |
||
17 | d_echo($oids . "\n"); |
||
18 | |||
19 | /* |
||
20 | eqlMemberHealthStatus |
||
21 | INTEGER { |
||
22 | unknown (0), |
||
23 | normal (1), |
||
24 | warning (2), |
||
25 | critical (3) |
||
26 | } |
||
27 | DESCRIPTION The value of this object is determinted by the severity of the |
||
28 | health condition state variables. The most severe state will |
||
29 | be reflected. |
||
30 | |||
31 | The LibreNMS generic states is derived from Nagios: |
||
32 | 0 = OK |
||
33 | 1 = Warning |
||
34 | 2 = Critical |
||
35 | 3 = Unknown |
||
36 | |||
37 | */ |
||
38 | |||
39 | if (! empty($oids)) { |
||
40 | $descr = 'Health'; |
||
41 | |||
42 | $state_name = 'eqlMemberHealthStatus'; |
||
43 | $states = [ |
||
44 | ['value' => 0, 'generic' => 3, 'graph' => 0, 'descr' => 'unknown'], |
||
45 | ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'normal'], |
||
46 | ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'warning'], |
||
47 | ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'critical'], |
||
48 | ]; |
||
49 | create_state_index($state_name, $states); |
||
50 | |||
51 | foreach (explode("\n", $oids) as $data) { |
||
52 | $data = trim($data); |
||
53 | if (! empty($data)) { |
||
54 | [$oid,$current] = explode(' = ', $data, 2); |
||
55 | $split_oid = explode('.', $oid); |
||
56 | $num_index = $split_oid[(count($split_oid) - 1)]; |
||
57 | $index = (int) cast_number($num_index); |
||
58 | $low_limit = 0.5; |
||
59 | $high_limit = 2.5; |
||
60 | discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $current, 'snmp', $index); |
||
61 | create_sensor_to_state_index($device, $state_name, $index); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 | |||
66 | $oids1 = snmp_walk($device, 'eqlMemberHealthDetailsPowerSupplyName', '-OQn', 'EQLMEMBER-MIB', 'equallogic'); |
||
67 | |||
68 | d_echo('PowerSupplyName oids:'); |
||
69 | d_echo($oids1 . "\n"); |
||
70 | |||
71 | /* |
||
72 | .1.3.6.1.4.1.12740.2.1.8.1.2.1.329840783.1 = Power Cooling Module 0 |
||
73 | .1.3.6.1.4.1.12740.2.1.8.1.2.1.329840783.2 = Power Cooling Module 1 |
||
74 | **/ |
||
75 | |||
76 | $base_oid = '.1.3.6.1.4.1.12740.2.1.8.1.3.1.'; // eqlMemberHealthDetailsPowerSupplyCurrentState |
||
77 | |||
78 | if (! empty($oids1)) { |
||
79 | /* |
||
80 | eqlMemberHealthDetailsPowerSupplyCurrentState |
||
81 | INTEGER { |
||
82 | on-and-operating (1), |
||
83 | no-ac-power (2), |
||
84 | failed-or-no-data (3) -- has ac but no dc out or we have no data |
||
85 | } |
||
86 | */ |
||
87 | $state_name = 'eqlMemberPowerSupplyCurrentState'; |
||
88 | $states = [ |
||
89 | ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'on-and-operating'], |
||
90 | ['value' => 2, 'generic' => 1, 'graph' => 1, 'descr' => 'no-ac-power'], |
||
91 | ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'failed-or-no-data'], |
||
92 | ]; |
||
93 | create_state_index($state_name, $states); |
||
94 | |||
95 | foreach (explode("\n", $oids1) as $data) { |
||
96 | $data = trim($data); |
||
97 | if (! empty($data)) { |
||
98 | [$oid,$descr] = explode(' = ', $data, 2); |
||
99 | $split_oid = explode('.', $oid); |
||
100 | $num_index = $split_oid[(count($split_oid) - 1)]; |
||
101 | $index = (int) cast_number($num_index); |
||
102 | $member_id = $split_oid[(count($split_oid) - 2)]; |
||
103 | $num_index = $member_id . '.' . $num_index; |
||
104 | $oid = $base_oid . $num_index; |
||
105 | $extra = snmp_get_multi($device, $oid, '-OQne', 'EQLMEMBER-MIB', 'equallogic'); |
||
106 | d_echo($extra); |
||
107 | if (! empty($extra)) { |
||
108 | [$foid,$pstatus] = explode(' = ', $extra, 2); |
||
109 | $index = (100 + $index); |
||
110 | $low_limit = 0.5; |
||
111 | $high_limit = 1.5; |
||
112 | discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, $descr, 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); |
||
113 | create_sensor_to_state_index($device, $state_name, $index); |
||
114 | } |
||
115 | }//end if |
||
116 | }//end foreach |
||
117 | }//end if empty oids |
||
118 | |||
119 | $oids_disks = snmp_walk($device, 'eqlDiskSerialNumber', '-OQn', 'EQLDISK-MIB', 'equallogic'); |
||
120 | |||
121 | d_echo('Disk Serials oids:' . PHP_EOL); |
||
122 | d_echo($oids_disks . "\n"); |
||
123 | |||
124 | $disks_base_oid = '.1.3.6.1.4.1.12740.3.1.1.1.8.1.'; // eqlDiskStatus |
||
125 | |||
126 | if (! empty($oids_disks)) { |
||
127 | $state_name = 'eqlDiskStatus'; |
||
128 | $states = [ |
||
129 | ['value' => 1, 'generic' => 0, 'graph' => 1, 'descr' => 'on-line'], |
||
130 | ['value' => 2, 'generic' => 0, 'graph' => 1, 'descr' => 'spare'], |
||
131 | ['value' => 3, 'generic' => 2, 'graph' => 1, 'descr' => 'failed'], |
||
132 | ['value' => 4, 'generic' => 1, 'graph' => 1, 'descr' => 'off-line'], |
||
133 | ['value' => 5, 'generic' => 1, 'graph' => 1, 'descr' => 'alt-sig'], |
||
134 | ['value' => 6, 'generic' => 2, 'graph' => 1, 'descr' => 'too-small'], |
||
135 | ['value' => 7, 'generic' => 0, 'graph' => 1, 'descr' => 'history-of-failures'], |
||
136 | ['value' => 8, 'generic' => 1, 'graph' => 1, 'descr' => 'unsupported-version'], |
||
137 | ]; |
||
138 | create_state_index($state_name, $states); |
||
139 | |||
140 | foreach (explode("\n", $oids_disks) as $data) { |
||
141 | $data = trim($data); |
||
142 | if (! empty($data)) { |
||
143 | [$oid,$descr] = explode(' = ', $data, 2); |
||
144 | $split_oid = explode('.', $oid); |
||
145 | $disk_index = $split_oid[(count($split_oid) - 1)]; |
||
146 | $member_id = $split_oid[(count($split_oid) - 2)]; |
||
147 | $num_index = $member_id . '.' . $disk_index; |
||
148 | $oid = $disks_base_oid . $num_index; |
||
149 | $extra = snmp_get($device, $oid, '-OQne', 'EQLDISK-MIB', 'equallogic'); |
||
150 | d_echo($extra); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
151 | if (! empty($extra)) { |
||
152 | [$foid,$pstatus] = explode(' = ', $extra, 2); |
||
153 | $index = 'eqlDiskStatus.' . $disk_index; |
||
154 | $low_limit = 0.5; |
||
155 | $high_limit = 1.5; |
||
156 | discover_sensor($valid['sensor'], 'state', $device, $oid, $index, $state_name, "Disk $disk_index - $descr", 1, 1, $low_limit, $low_limit, $high_limit, $high_limit, $pstatus, 'snmp', $index); |
||
157 | create_sensor_to_state_index($device, $state_name, $index); |
||
158 | unset( |
||
159 | $index, |
||
160 | $low_limit, |
||
161 | $high_limit |
||
162 | ); |
||
163 | } |
||
164 | unset( |
||
165 | $split_oid, |
||
166 | $disk_index, |
||
167 | $index, |
||
168 | $member_id, |
||
169 | $num_index, |
||
170 | $oid, |
||
171 | $extra |
||
172 | ); |
||
173 | }//end if |
||
174 | unset( |
||
175 | $data |
||
176 | ); |
||
177 | }//end foreach |
||
178 | }//end if empty oids |
||
179 | |||
180 | unset( |
||
181 | $oid_disks, |
||
182 | $disks_base_oid, |
||
183 | $disks_state_name, |
||
184 | $disks_state_index_id, |
||
185 | $disk_states, |
||
186 | $insert |
||
187 | ); |
||
188 |