r3245 push fix for ticket:307 into trunk
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
74aee2dc 3$iftable_processors = array();
6be06cbb
DO
4
5$iftable_processors['catalyst-4948-mgmt'] = array
6(
7 'pattern' => '@^FastEthernet1$@',
8 'replacement' => 'fa1',
9 'dict_key' => 19,
10 'label' => 'mgmt',
11 'try_next_proc' => FALSE,
12);
13
14$iftable_processors['catalyst-chassis-any-100TX'] = array
74aee2dc 15(
6be06cbb
DO
16 'pattern' => '@^FastEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
17 'replacement' => 'fa\\1\\2',
74aee2dc 18 'dict_key' => 19,
6be06cbb 19 'label' => '\\2X',
56a797ef
DO
20 'try_next_proc' => FALSE,
21);
22
6be06cbb 23$iftable_processors['catalyst-chassis-25-to-26-100FX/MT-RJ'] = array
56a797ef 24(
6be06cbb
DO
25 'pattern' => '@^FastEthernet([[:digit:]]+/)?(25|26)$@',
26 'replacement' => 'fa\\1\\2',
56a797ef 27 'dict_key' => 1083,
6be06cbb
DO
28 'label' => '\\2',
29 'try_next_proc' => FALSE,
30);
31
32$iftable_processors['catalyst-chassis-any-1000T'] = array
33(
34 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
35 'replacement' => 'gi\\1\\2',
36 'dict_key' => 24,
37 'label' => '\\2X',
56a797ef 38 'try_next_proc' => FALSE,
74aee2dc
DO
39);
40
6be06cbb 41$iftable_processors['catalyst-chassis-uplinks-1000T'] = array
74aee2dc 42(
6be06cbb
DO
43 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
44 'replacement' => 'gi\\1\\2',
74aee2dc 45 'dict_key' => 24,
6be06cbb 46 'label' => '\\2',
56a797ef
DO
47 'try_next_proc' => FALSE,
48);
49
6be06cbb 50$iftable_processors['catalyst-chassis-any-1000SFP'] = array
74aee2dc 51(
6be06cbb
DO
52 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
53 'replacement' => 'gi\\1\\2',
8536e20a 54 'dict_key' => '4-1077',
6be06cbb 55 'label' => '\\2',
56a797ef
DO
56 'try_next_proc' => FALSE,
57);
58
6be06cbb 59$iftable_processors['catalyst-chassis-any-1000GBIC'] = array
56a797ef 60(
6be06cbb
DO
61 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
62 'replacement' => 'gi\\1\\2',
8536e20a 63 'dict_key' => '3-1078',
6be06cbb 64 'label' => '\\2',
56a797ef
DO
65 'try_next_proc' => FALSE,
66);
67
6be06cbb 68$iftable_processors['catalyst-chassis-21-to-24-combo-1000SFP'] = array
56a797ef 69(
6be06cbb
DO
70 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
71 'replacement' => 'gi\\1\\2',
8536e20a 72 'dict_key' => '4-1077',
6be06cbb 73 'label' => '\\2',
56a797ef
DO
74 'try_next_proc' => TRUE,
75);
76
6be06cbb 77$iftable_processors['catalyst-chassis-45-to-48-combo-1000SFP'] = array
56a797ef 78(
6be06cbb
DO
79 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(45|46|47|48)$@',
80 'replacement' => 'gi\\1\\2',
8536e20a 81 'dict_key' => '4-1077',
6be06cbb 82 'label' => '\\2',
56a797ef
DO
83 'try_next_proc' => TRUE,
84);
85
6be06cbb 86$iftable_processors['catalyst-chassis-uplinks-10000X2'] = array
56a797ef 87(
6be06cbb
DO
88 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
89 'replacement' => 'te\\1\\2',
8536e20a 90 'dict_key' => '6-1080',
6be06cbb 91 'label' => '\\2',
56a797ef 92 'try_next_proc' => FALSE,
74aee2dc
DO
93);
94
6be06cbb 95$iftable_processors['catalyst-chassis-25-to-28-1000SFP'] = array
74aee2dc 96(
6be06cbb
DO
97 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(25|26|27|28)$@',
98 'replacement' => 'gi\\1\\2',
8536e20a 99 'dict_key' => '4-1077',
6be06cbb 100 'label' => '\\2',
56a797ef 101 'try_next_proc' => FALSE,
74aee2dc
DO
102);
103
6be06cbb 104$iftable_processors['catalyst-chassis-49-to-52-1000SFP'] = array
74aee2dc 105(
6be06cbb
DO
106 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(49|50|51|52)$@',
107 'replacement' => 'gi\\1\\2',
8536e20a 108 'dict_key' => '4-1077',
6be06cbb 109 'label' => '\\2',
56a797ef 110 'try_next_proc' => FALSE,
74aee2dc
DO
111);
112
71d6b313 113$iftable_processors['catalyst-blade-13-to-16-1000SFP'] = array
74aee2dc 114(
6be06cbb
DO
115 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(13|14|15|16)$@',
116 'replacement' => 'gi\\1\\2',
8536e20a 117 'dict_key' => '4-1077',
6be06cbb 118 'label' => '\\2',
56a797ef 119 'try_next_proc' => FALSE,
74aee2dc
DO
120);
121
71d6b313 122$iftable_processors['catalyst-blade-21-to-24-1000SFP'] = array
74aee2dc 123(
6be06cbb
DO
124 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
125 'replacement' => 'gi\\1\\2',
8536e20a 126 'dict_key' => '4-1077',
6be06cbb 127 'label' => '\\2',
56a797ef 128 'try_next_proc' => FALSE,
74aee2dc
DO
129);
130
71d6b313
DO
131$iftable_processors['catalyst-blade-11-to-12-1000T'] = array
132(
133 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(11|12)$@',
134 'replacement' => 'gi\\1\\2',
135 'dict_key' => '1-24',
136 'label' => '\\2',
137 'try_next_proc' => FALSE,
138);
139
140$iftable_processors['catalyst-blade-17-to-20-1000T'] = array
141(
142 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(17|18|19|20)$@',
143 'replacement' => 'gi\\1\\2',
144 'dict_key' => '1-24',
145 'label' => '\\2',
146 'try_next_proc' => FALSE,
147);
148
149$iftable_processors['catalyst-blade-any-bp/1000T'] = array
150(
151 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
152 'replacement' => 'gi\\1\\2',
153 'dict_key' => '1-1087',
154 'label' => '',
155 'try_next_proc' => FALSE,
156);
157
74aee2dc
DO
158$iftable_processors['nexus-any-10000SFP+'] = array
159(
56a797ef 160 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
74aee2dc 161 'replacement' => 'e\\1',
8536e20a 162 'dict_key' => '9-1084',
56a797ef
DO
163 'label' => '\\1',
164 'try_next_proc' => FALSE,
74aee2dc
DO
165);
166
e7662d90
DO
167$iftable_processors['nexus-mgmt'] = array
168(
169 'pattern' => '@^(mgmt[[:digit:]]+)$@',
170 'replacement' => '\\1',
171 'dict_key' => '1-24',
172 'label' => '\\1',
173 'try_next_proc' => FALSE,
174);
175
56a797ef 176$iftable_processors['procurve-chassis-100TX'] = array
74aee2dc 177(
56a797ef 178 'pattern' => '@^([[:digit:]]+)$@',
74aee2dc
DO
179 'replacement' => '\\1',
180 'dict_key' => 19,
56a797ef
DO
181 'label' => '\\1',
182 'try_next_proc' => FALSE,
183);
184
185$iftable_processors['procurve-chassis-1000T'] = array
186(
187 'pattern' => '@^([[:digit:]]+)$@',
188 'replacement' => '\\1',
189 'dict_key' => 24,
190 'label' => '\\1',
191 'try_next_proc' => FALSE,
192);
193
194$iftable_processors['procurve-modular-100TX'] = array
195(
196 'pattern' => '@^([A-Z][[:digit:]]+)$@',
197 'replacement' => '\\1',
198 'dict_key' => 19,
199 'label' => '\\1',
200 'try_next_proc' => FALSE,
74aee2dc
DO
201);
202
203$iftable_processors['procurve-25-to-26-1000T'] = array
204(
56a797ef 205 'pattern' => '@^(25|26)$@',
74aee2dc
DO
206 'replacement' => '\\1',
207 'dict_key' => 24,
56a797ef
DO
208 'label' => '\\1',
209 'try_next_proc' => FALSE,
74aee2dc
DO
210);
211
212$iftable_processors['procurve-49-to-50-1000T'] = array
213(
56a797ef 214 'pattern' => '@^(49|50)$@',
74aee2dc
DO
215 'replacement' => '\\1',
216 'dict_key' => 24,
56a797ef
DO
217 'label' => '\\1',
218 'try_next_proc' => FALSE,
74aee2dc
DO
219);
220
6be06cbb 221$iftable_processors['netgear-chassis-any-1000T'] = array
74aee2dc 222(
56a797ef
DO
223 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
224 'replacement' => '\\1',
225 'dict_key' => 24,
226 'label' => '\\1',
227 'try_next_proc' => FALSE,
228);
229
6be06cbb
DO
230$iftable_processors['netgear-chassis-21-to-24-1000Tcombo'] = array
231(
232 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
233 'replacement' => '\\1',
234 'dict_key' => 24,
235 'label' => '\\1T',
236 'try_next_proc' => FALSE,
237);
238
239$iftable_processors['netgear-chassis-21-to-24-1000SFP'] = array
240(
241 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
242 'replacement' => '\\1',
8536e20a 243 'dict_key' => '4-1077',
6be06cbb
DO
244 'label' => '\\1F',
245 'try_next_proc' => TRUE,
246);
247
56a797ef
DO
248$iftable_processors['nortel-any-1000T'] = array
249(
250 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
74aee2dc
DO
251 'replacement' => '\\1',
252 'dict_key' => 24,
56a797ef
DO
253 'label' => '\\1',
254 'try_next_proc' => FALSE,
74aee2dc
DO
255);
256
91389980
DO
257$iftable_processors['juniper-DPCE-R-4XGE-XFP'] = array
258(
7d69a266
DO
259 'pattern' => '@^xe-([[:digit:]]+)/([[:digit:]]+/[[:digit:]]+)$@',
260 'replacement' => '\\0',
91389980 261 'dict_key' => '8-1082', // XFP/empty
7d69a266
DO
262 'label' => 'slot \\1 port \\2',
263 'try_next_proc' => FALSE,
264);
265
266$iftable_processors['quidway-21-to-24-comboT'] = array
267(
268 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)(21|22|23|24)$@',
269 'replacement' => 'gi\\1\\2',
270 'dict_key' => '1-24',
271 'label' => '\\2',
272 'try_next_proc' => TRUE,
273);
274
275$iftable_processors['quidway-any-1000SFP'] = array
276(
277 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
278 'replacement' => 'gi\\1\\2',
279 'dict_key' => '4-1077', // empty SFP-1000
280 'label' => '\\2',
281 'try_next_proc' => FALSE,
282);
283
284$iftable_processors['quidway-XFP'] = array
285(
286 'pattern' => '@^XGigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
287 'replacement' => 'xg\\1\\2',
288 'dict_key' => '8-1082',
289 'label' => '\\2',
290 'try_next_proc' => FALSE,
291);
292
293$iftable_processors['quidway-mgmt'] = array
294(
295 'pattern' => '@^MEth([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
296 'replacement' => 'me\\1\\2',
297 'dict_key' => '1-19',
298 'label' => 'eth',
91389980
DO
299 'try_next_proc' => FALSE,
300);
301
74aee2dc
DO
302$known_switches = array // key is system OID w/o "enterprises" prefix
303(
304 '9.1.324' => array
305 (
306 'dict_key' => 380,
307 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
6be06cbb 308 'processors' => array ('catalyst-chassis-any-100TX'),
74aee2dc
DO
309 ),
310 '9.1.325' => array
311 (
312 'dict_key' => 382,
313 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
6be06cbb 314 'processors' => array ('catalyst-chassis-25-to-26-100FX/MT-RJ', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
315 ),
316 '9.1.696' => array
317 (
318 'dict_key' => 167,
319 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 320 'processors' => array ('catalyst-chassis-21-to-24-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
321 ),
322 '9.1.697' => array
323 (
324 'dict_key' => 166,
325 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 326 'processors' => array ('catalyst-chassis-45-to-48-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
327 ),
328 '9.1.716' => array
329 (
330 'dict_key' => 164,
331 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 332 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
333 ),
334 '9.1.717' => array
335 (
336 'dict_key' => 162,
337 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 338 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
339 ),
340 '9.1.527' => array
341 (
342 'dict_key' => 210,
343 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
6be06cbb 344 'processors' => array ('catalyst-chassis-any-1000T'),
74aee2dc
DO
345 ),
346 '9.1.561' => array
347 (
348 'dict_key' => 115,
349 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 350 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
351 ),
352 '9.1.633' => array
353 (
354 'dict_key' => 169,
355 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 356 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
357 ),
358 '9.1.634' => array
359 (
360 'dict_key' => 170,
361 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 362 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
363 ),
364 '9.1.563' => array
365 (
366 'dict_key' => 171,
367 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 368 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
369 ),
370 '9.1.564' => array
371 (
372 'dict_key' => 172,
373 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 374 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
375 ),
376 '9.1.614' => array
377 (
378 'dict_key' => 175,
379 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 380 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
381 ),
382 '9.1.615' => array
383 (
384 'dict_key' => 173,
385 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 386 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
387 ),
388 '9.1.616' => array
389 (
390 'dict_key' => 176,
391 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 392 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
393 ),
394 '9.1.617' => array
395 (
396 'dict_key' => 174,
397 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 398 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
399 ),
400 '9.1.626' => array
401 (
402 'dict_key' => 147,
56a797ef 403 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
6be06cbb 404 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-uplinks-1000T', 'catalyst-4948-mgmt'),
74aee2dc
DO
405 ),
406 '9.1.659' => array
407 (
408 'dict_key' => 377,
56a797ef 409 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
6be06cbb 410 'processors' => array ('catalyst-chassis-uplinks-10000X2', 'catalyst-chassis-uplinks-1000T', 'catalyst-4948-mgmt'),
74aee2dc
DO
411 ),
412 '9.1.428' => array
413 (
414 'dict_key' => 389,
415 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 416 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
417 ),
418 '9.1.429' => array
419 (
420 'dict_key' => 390,
421 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 422 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
423 ),
424 '9.1.559' => array
425 (
426 'dict_key' => 387,
427 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 428 'processors' => array ('catalyst-chassis-uplinks-1000T', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
429 ),
430 '9.1.749' => array
431 (
432 'dict_key' => 989,
433 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 434 'processors' => array ('catalyst-blade-11-to-12-1000T', 'catalyst-blade-13-to-16-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc
DO
435 ),
436 '9.1.920' => array
437 (
438 'dict_key' => 795,
439 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 440 'processors' => array ('catalyst-blade-17-to-20-1000T', 'catalyst-blade-21-to-24-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc
DO
441 ),
442 '9.12.3.1.3.719' => array
443 (
444 'dict_key' => 960,
445 'text' => 'N5K-C5020: 40 SFP+/10000',
e7662d90 446 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
74aee2dc 447 ),
56a797ef
DO
448 '11.2.3.7.11.32' => array
449 (
450 'dict_key' => 871,
451 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
452 'processors' => array ('procurve-chassis-1000T'),
453 ),
74aee2dc
DO
454 '11.2.3.7.11.36' => array
455 (
456 'dict_key' => 865,
457 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 458 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
459 ),
460 '11.2.3.7.11.35' => array
461 (
462 'dict_key' => 867,
463 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
464 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
465 ),
466 '11.2.3.7.11.9' => array
467 (
468 'dict_key' => 1086,
469 'text' => 'J4121A: modular system',
470 'processors' => array ('procurve-modular-100TX'),
74aee2dc
DO
471 ),
472 '4526.100.2.2' => array
473 (
474 'dict_key' => 562,
6be06cbb
DO
475 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
476 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
74aee2dc 477 ),
56a797ef
DO
478 '45.3.68.5' => array
479 (
480 'dict_key' => 1085,
481 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
482 'processors' => array ('nortel-any-1000T'),
483 ),
91389980
DO
484 '2636.1.1.1.2.29' => array
485 (
486 'dict_key' => 925,
487 'text' => 'MX240 modular router',
488 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
489 ),
7d69a266
DO
490 '2011.2.23.96' => array
491 (
492 'dict_key' => 1321,
493 'text' => 'S5328C-EI-24S: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
494 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
495 ),
74aee2dc
DO
496);
497
74aee2dc
DO
498function updateStickerForCell ($cell, $attr_id, $new_value)
499{
500 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
501 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
502}
503
bdc91a5c
DO
504// Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
505// a record with IIF id = X and OIF id = Y.
506function checkPIC ($port_type_id)
507{
508 $matches = array();
509 switch (1)
510 {
511 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
512 $iif_id = $matches[1];
513 $oif_id = $matches[2];
514 break;
515 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
516 $iif_id = 1;
517 $oif_id = $matches[1];
518 break;
519 default:
520 return;
521 }
522 foreach (getPortInterfaceCompat() as $record)
523 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
524 return;
525 commitSupplementPIC ($iif_id, $oif_id);
526}
527
8536e20a
DO
528$msgcode['doSNMPmining']['ERR1'] = 161;
529$msgcode['doSNMPmining']['ERR2'] = 162;
8536e20a 530$msgcode['doSNMPmining']['OK'] = 81;
56a797ef 531function doSNMPmining ($object_id, $community)
74aee2dc 532{
74aee2dc
DO
533 $objectInfo = spotEntity ('object', $object_id);
534 $objectInfo['attrs'] = getAttrValues ($object_id);
535 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
536 if (count ($endpoints) == 0)
8536e20a 537 return buildRedirectURL (__FUNCTION__, 'ERR1'); // endpoint not found
74aee2dc 538 if (count ($endpoints) > 1)
8536e20a 539 return buildRedirectURL (__FUNCTION__, 'ERR2'); // can't pick an address
4848a7e3
DO
540
541 switch ($objectInfo['objtype_id'])
542 {
24a6e3a2 543 case 7:
4848a7e3
DO
544 case 8:
545 return doSwitchSNMPmining ($objectInfo, $endpoints[0], $community);
546 case 2:
547 return doPDUSNMPmining ($objectInfo, $endpoints[0], $community);
548 }
549}
550
24a6e3a2 551$msgcode['doSwitchSNMPmining']['ERR3'] = 188;
e22f9600 552$msgcode['doSwitchSNMPmining']['ERR4'] = 189;
24a6e3a2 553function doSwitchSNMPmining ($objectInfo, $hostname, $community)
4848a7e3
DO
554{
555 $log = emptyLog();
556 global $known_switches, $iftable_processors;
74aee2dc 557
24a6e3a2 558 if (FALSE === ($sysObjectID = @snmpget ($hostname, $community, 'sysObjectID.0')))
8536e20a 559 return buildRedirectURL (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
74aee2dc 560 $sysObjectID = ereg_replace ('^.*(enterprises\.)([\.[:digit:]]+)$', '\\2', $sysObjectID);
24a6e3a2
DO
561 $sysName = substr (@snmpget ($hostname, $community, 'sysName.0'), strlen ('STRING: '));
562 $sysDescr = substr (@snmpget ($hostname, $community, 'sysDescr.0'), strlen ('STRING: '));
74aee2dc
DO
563 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
564 if (!isset ($known_switches[$sysObjectID]))
8536e20a 565 return buildRedirectURL (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
56a797ef 566 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 567 updateStickerForCell ($objectInfo, 3, $sysName);
56a797ef 568 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
74aee2dc
DO
569 switch (1)
570 {
56a797ef 571 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
74aee2dc
DO
572 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
573 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
574 $ios_codes = array
575 (
576 '12.0' => 244,
577 '12.1' => 251,
578 '12.2' => 252,
579 );
580 updateStickerForCell ($objectInfo, 5, $exact_release);
6be06cbb
DO
581 if (array_key_exists ($major_line, $ios_codes))
582 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
24a6e3a2 583 $sysChassi = @snmpget ($hostname, $community, '1.3.6.1.4.1.9.3.6.3.0');
74aee2dc
DO
584 if ($sysChassi !== FALSE or $sysChassi !== NULL)
585 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
bdc91a5c
DO
586 checkPIC ('1-29');
587 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
588 checkPIC ('1-16');
24a6e3a2 589 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', ''); // AC input
56a797ef 590 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
74aee2dc 591 break;
56a797ef 592 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
74aee2dc
DO
593 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
594 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
595 $nxos_codes = array
596 (
597 '4.0' => 963,
598 '4.1' => 964,
599 );
6be06cbb
DO
600 if (array_key_exists ($major_line, $nxos_codes))
601 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
74aee2dc 602 updateStickerForCell ($objectInfo, 5, $exact_release);
bdc91a5c 603 checkPIC ('1-29');
24a6e3a2 604 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
56a797ef 605 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
74aee2dc 606 break;
56a797ef 607 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
74aee2dc
DO
608 $exact_release = ereg_replace ('^.* revision ([^ ]+), .*$', '\\1', $sysDescr);
609 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 610 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
74aee2dc 611 break;
6be06cbb 612 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
bdc91a5c
DO
613 checkPIC ('1-681');
614 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
6be06cbb
DO
615 $log = mergeLogs ($log, oneLiner (81, array ('netgear-generic')));
616 break;
7d69a266 617 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
bdc91a5c
DO
618 checkPIC ('1-681');
619 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
620 $log = mergeLogs ($log, oneLiner (81, array ('huawei-generic')));
621 break;
622 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
bdc91a5c
DO
623 checkPIC ('1-681');
624 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
625 $log = mergeLogs ($log, oneLiner (81, array ('juniper-generic')));
626 default: // Nortel...
74aee2dc
DO
627 break;
628 }
56a797ef
DO
629 $ifInfo = array();
630 $tablename = 'ifDescr';
24a6e3a2 631 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef
DO
632 {
633 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
634 $value = trim (ereg_replace ('^.+: (.+)$', '\\1', $value), '"');
635 $ifInfo[$randomindex][$tablename] = $value;
636 }
637 $tablename = 'ifPhysAddress';
24a6e3a2 638 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef
DO
639 {
640 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
641 $value = trim ($value);
642 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
643 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
644 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
645 if (preg_match ('/^string: /i', $value)) // STRING: x:yy:z:xx:y:zz
646 {
647 list ($dummy, $value) = explode (' ', $value);
648 $addrbytes = explode (':', $value);
649 foreach ($addrbytes as $bidx => $bytestr)
650 if (strlen ($bytestr) == 1)
651 $addrbytes[$bidx] = '0' . $bytestr;
652 }
653 elseif (preg_match ('/^hex-string: /i', $value)) // Hex-STRING: xx yy zz xx yy zz
654 $addrbytes = explode (' ', substr ($value, -17));
655 else
656 continue; // martian format
657 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
658 }
659 // process each interface only once regardless of how many processors we have to run
660 foreach ($ifInfo as $iface)
661 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
662 {
56a797ef
DO
663 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
664 if (!$count)
665 continue; // try next processor on current port
666 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
bdc91a5c 667 checkPIC ($iftable_processors[$processor_name]['dict_key']);
24a6e3a2 668 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
56a797ef
DO
669 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
670 continue 2;
671 }
672 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
673 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
8536e20a
DO
674 // No failure up to this point, thus leave current tab for the "Ports" one.
675 return buildWideRedirectURL ($log, NULL, 'ports');
74aee2dc
DO
676}
677
4848a7e3
DO
678$msgcode['doPDUSNMPmining']['OK'] = 0;
679function doPDUSNMPmining ($objectInfo, $hostname, $community)
38e05b77 680{
29de85b6
DO
681 $log = emptyLog();
682 global $known_APC_SKUs;
4848a7e3 683 $switch = new APCPowerSwitch ($hostname, $community);
29de85b6
DO
684 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
685 updateStickerForCell ($objectInfo, 2, $dict_key);
686 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
4848a7e3 687 updateStickerForCell ($objectInfo, 3, $switch->getName());
29de85b6 688 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
bdc91a5c 689 checkPIC ('1-16');
29de85b6 690 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
4848a7e3
DO
691 $portno = 1;
692 foreach ($switch->getPorts() as $name => $port)
29de85b6
DO
693 {
694 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
bdc91a5c 695 checkPIC ('1-1322');
29de85b6
DO
696 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
697 $portno++;
698 }
912d98f8 699 $log = mergeLogs ($log, oneLiner (0, array ("Added ${portno} port(s)")));
29de85b6 700 return buildWideRedirectURL ($log, NULL, 'ports');
38e05b77
DO
701}
702
4848a7e3 703// APC SNMP code by Russ Garrett
38e05b77
DO
704define('APC_STATUS_ON', 1);
705define('APC_STATUS_OFF', 2);
706define('APC_STATUS_REBOOT', 3);
707
708class SNMPDevice {
709 protected $hostname;
710 protected $community;
711
712 function __construct($hostname, $community) {
713 $this->hostname = $hostname;
714 $this->community = $community;
715 }
716
717 function getName() {
718 return $this->getString('sysName.0');
719 }
720
721 function getDescription() {
722 return $this->getString('sysDescr.0');
723 }
724
725 protected function snmpSet($oid, $type, $value) {
726 return snmpset($this->hostname, $this->community, $oid, $type, $value);
727 }
728
729 protected function getString($oid) {
730 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, $oid)), '"');
731 }
732}
733
734class APCPowerSwitch extends SNMPDevice {
735 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
736
737 function getPorts() {
738 $data = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2");
739 $status = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4");
740 $out = array();
741 foreach ($data as $id => $d) {
742 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
743 }
744 return $out;
745 }
746
747 function getPortStatus($id) {
748 return trim(snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
749 }
750
751 function getPortName($id) {
752 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
753 }
754
755 function setPortName($id, $name) {
756 return snmpset($this->hostname, $this->community, "{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
757 }
758
759 function portOff($id) {
760 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
761 }
762
763 function portOn($id) {
764 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
765 }
766
767 function portReboot($id) {
768 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
769 }
30ad8bc4
DO
770 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
771 function getFWRev()
772 {
773 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.3.0"));
774 }
775 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
776 function getHWSerial()
777 {
778 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.6.0"));
779 }
780 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
781 function getHWModel()
782 {
783 return preg_replace ('/^STRING: "(.*)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.5.0"));
784 }
38e05b77
DO
785}
786
2ffd5a2a 787?>