r3890 renderTrunkPortControls(): fix "clear" button
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
74aee2dc 3$iftable_processors = array();
6be06cbb 4
cbc30061 5$iftable_processors['catalyst-chassis-mgmt'] = array
6be06cbb 6(
cbc30061
DO
7 'pattern' => '@^FastEthernet([[:digit:]])$@',
8 'replacement' => 'fa\\1',
9 'dict_key' => '1-19',
6be06cbb
DO
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
8a4bee49
DO
50$iftable_processors['catalyst-chassis-uplinks-1000SX'] = array
51(
52 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
53 'replacement' => 'gi\\1\\2',
54 'dict_key' => '1-1202', // Gig-SX hardwired
55 'label' => '\\2',
56 'try_next_proc' => FALSE,
57);
58
6be06cbb 59$iftable_processors['catalyst-chassis-any-1000SFP'] = array
74aee2dc 60(
6be06cbb
DO
61 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
62 'replacement' => 'gi\\1\\2',
8536e20a 63 'dict_key' => '4-1077',
6be06cbb 64 'label' => '\\2',
56a797ef
DO
65 'try_next_proc' => FALSE,
66);
67
6be06cbb 68$iftable_processors['catalyst-chassis-any-1000GBIC'] = array
56a797ef 69(
6be06cbb
DO
70 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
71 'replacement' => 'gi\\1\\2',
8536e20a 72 'dict_key' => '3-1078',
6be06cbb 73 'label' => '\\2',
56a797ef
DO
74 'try_next_proc' => FALSE,
75);
76
7e87a291
DO
77$iftable_processors['catalyst-chassis-1-to-2-combo-1000SFP'] = array
78(
79 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(1|2)$@',
80 'replacement' => 'gi\\1\\2',
81 'dict_key' => '4-1077',
82 'label' => '\\2',
83 'try_next_proc' => TRUE,
84);
85
a048e8fc
DO
86$iftable_processors['catalyst-chassis-8-combo-1000SFP'] = array
87(
88 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(8)$@',
89 'replacement' => 'gi\\1\\2',
90 'dict_key' => '4-1077',
91 'label' => '\\2',
92 'try_next_proc' => TRUE,
93);
94
6be06cbb 95$iftable_processors['catalyst-chassis-21-to-24-combo-1000SFP'] = array
56a797ef 96(
6be06cbb
DO
97 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
98 'replacement' => 'gi\\1\\2',
8536e20a 99 'dict_key' => '4-1077',
6be06cbb 100 'label' => '\\2',
56a797ef
DO
101 'try_next_proc' => TRUE,
102);
103
6be06cbb 104$iftable_processors['catalyst-chassis-45-to-48-combo-1000SFP'] = array
56a797ef 105(
6be06cbb
DO
106 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(45|46|47|48)$@',
107 'replacement' => 'gi\\1\\2',
8536e20a 108 'dict_key' => '4-1077',
6be06cbb 109 'label' => '\\2',
56a797ef
DO
110 'try_next_proc' => TRUE,
111);
112
6be06cbb 113$iftable_processors['catalyst-chassis-uplinks-10000X2'] = array
56a797ef 114(
6be06cbb
DO
115 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
116 'replacement' => 'te\\1\\2',
8536e20a 117 'dict_key' => '6-1080',
6be06cbb 118 'label' => '\\2',
56a797ef 119 'try_next_proc' => FALSE,
74aee2dc
DO
120);
121
6be06cbb 122$iftable_processors['catalyst-chassis-25-to-28-1000SFP'] = array
74aee2dc 123(
6be06cbb
DO
124 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(25|26|27|28)$@',
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
6be06cbb 131$iftable_processors['catalyst-chassis-49-to-52-1000SFP'] = array
74aee2dc 132(
6be06cbb
DO
133 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(49|50|51|52)$@',
134 'replacement' => 'gi\\1\\2',
8536e20a 135 'dict_key' => '4-1077',
6be06cbb 136 'label' => '\\2',
56a797ef 137 'try_next_proc' => FALSE,
74aee2dc
DO
138);
139
71d6b313 140$iftable_processors['catalyst-blade-13-to-16-1000SFP'] = array
74aee2dc 141(
6be06cbb
DO
142 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(13|14|15|16)$@',
143 'replacement' => 'gi\\1\\2',
8536e20a 144 'dict_key' => '4-1077',
6be06cbb 145 'label' => '\\2',
56a797ef 146 'try_next_proc' => FALSE,
74aee2dc
DO
147);
148
71d6b313 149$iftable_processors['catalyst-blade-21-to-24-1000SFP'] = array
74aee2dc 150(
6be06cbb
DO
151 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
152 'replacement' => 'gi\\1\\2',
8536e20a 153 'dict_key' => '4-1077',
6be06cbb 154 'label' => '\\2',
56a797ef 155 'try_next_proc' => FALSE,
74aee2dc
DO
156);
157
71d6b313
DO
158$iftable_processors['catalyst-blade-11-to-12-1000T'] = array
159(
160 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(11|12)$@',
161 'replacement' => 'gi\\1\\2',
162 'dict_key' => '1-24',
163 'label' => '\\2',
164 'try_next_proc' => FALSE,
165);
166
167$iftable_processors['catalyst-blade-17-to-20-1000T'] = array
168(
169 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(17|18|19|20)$@',
170 'replacement' => 'gi\\1\\2',
171 'dict_key' => '1-24',
172 'label' => '\\2',
173 'try_next_proc' => FALSE,
174);
175
176$iftable_processors['catalyst-blade-any-bp/1000T'] = array
177(
178 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
179 'replacement' => 'gi\\1\\2',
180 'dict_key' => '1-1087',
181 'label' => '',
182 'try_next_proc' => FALSE,
183);
184
7e87a291
DO
185$iftable_processors['catalyst-1-to-10-1000T'] = array
186(
187 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(1|2|3|4|5|6|7|8|9|10)$@',
188 'replacement' => 'gi\\1\\2',
189 'dict_key' => '1-24',
190 'label' => '\\2',
191 'try_next_proc' => FALSE,
192);
193
194$iftable_processors['catalyst-11-to-12-GBIC'] = array
195(
196 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(11|12)$@',
197 'replacement' => 'gi\\1\\2',
198 'dict_key' => '3-1078',
199 'label' => '\\2',
200 'try_next_proc' => FALSE,
201);
202
74aee2dc
DO
203$iftable_processors['nexus-any-10000SFP+'] = array
204(
56a797ef 205 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
74aee2dc 206 'replacement' => 'e\\1',
8536e20a 207 'dict_key' => '9-1084',
56a797ef
DO
208 'label' => '\\1',
209 'try_next_proc' => FALSE,
74aee2dc
DO
210);
211
e7662d90
DO
212$iftable_processors['nexus-mgmt'] = array
213(
214 'pattern' => '@^(mgmt[[:digit:]]+)$@',
215 'replacement' => '\\1',
216 'dict_key' => '1-24',
217 'label' => '\\1',
218 'try_next_proc' => FALSE,
219);
220
56a797ef 221$iftable_processors['procurve-chassis-100TX'] = array
74aee2dc 222(
56a797ef 223 'pattern' => '@^([[:digit:]]+)$@',
74aee2dc
DO
224 'replacement' => '\\1',
225 'dict_key' => 19,
56a797ef
DO
226 'label' => '\\1',
227 'try_next_proc' => FALSE,
228);
229
230$iftable_processors['procurve-chassis-1000T'] = array
231(
232 'pattern' => '@^([[:digit:]]+)$@',
233 'replacement' => '\\1',
234 'dict_key' => 24,
235 'label' => '\\1',
236 'try_next_proc' => FALSE,
237);
238
4b43f713
DO
239$iftable_processors['procurve-45-to-48-combo-1000SFP'] = array
240(
241 'pattern' => '@^(45|46|47|48)$@',
242 'replacement' => '\\1',
243 'dict_key' => '4-1077',
244 'label' => '\\1',
245 'try_next_proc' => TRUE,
246);
247
56a797ef
DO
248$iftable_processors['procurve-modular-100TX'] = array
249(
250 'pattern' => '@^([A-Z][[:digit:]]+)$@',
251 'replacement' => '\\1',
252 'dict_key' => 19,
253 'label' => '\\1',
254 'try_next_proc' => FALSE,
74aee2dc
DO
255);
256
257$iftable_processors['procurve-25-to-26-1000T'] = array
258(
56a797ef 259 'pattern' => '@^(25|26)$@',
74aee2dc
DO
260 'replacement' => '\\1',
261 'dict_key' => 24,
56a797ef
DO
262 'label' => '\\1',
263 'try_next_proc' => FALSE,
74aee2dc
DO
264);
265
266$iftable_processors['procurve-49-to-50-1000T'] = array
267(
56a797ef 268 'pattern' => '@^(49|50)$@',
74aee2dc
DO
269 'replacement' => '\\1',
270 'dict_key' => 24,
56a797ef
DO
271 'label' => '\\1',
272 'try_next_proc' => FALSE,
74aee2dc
DO
273);
274
6be06cbb 275$iftable_processors['netgear-chassis-any-1000T'] = array
74aee2dc 276(
56a797ef
DO
277 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
278 'replacement' => '\\1',
279 'dict_key' => 24,
280 'label' => '\\1',
281 'try_next_proc' => FALSE,
282);
283
6be06cbb
DO
284$iftable_processors['netgear-chassis-21-to-24-1000Tcombo'] = array
285(
286 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
287 'replacement' => '\\1',
288 'dict_key' => 24,
289 'label' => '\\1T',
290 'try_next_proc' => FALSE,
291);
292
293$iftable_processors['netgear-chassis-21-to-24-1000SFP'] = array
294(
295 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
296 'replacement' => '\\1',
8536e20a 297 'dict_key' => '4-1077',
6be06cbb
DO
298 'label' => '\\1F',
299 'try_next_proc' => TRUE,
300);
301
56a797ef
DO
302$iftable_processors['nortel-any-1000T'] = array
303(
304 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
74aee2dc
DO
305 'replacement' => '\\1',
306 'dict_key' => 24,
56a797ef
DO
307 'label' => '\\1',
308 'try_next_proc' => FALSE,
74aee2dc
DO
309);
310
91389980
DO
311$iftable_processors['juniper-DPCE-R-4XGE-XFP'] = array
312(
7d69a266
DO
313 'pattern' => '@^xe-([[:digit:]]+)/([[:digit:]]+/[[:digit:]]+)$@',
314 'replacement' => '\\0',
91389980 315 'dict_key' => '8-1082', // XFP/empty
7d69a266
DO
316 'label' => 'slot \\1 port \\2',
317 'try_next_proc' => FALSE,
318);
319
320$iftable_processors['quidway-21-to-24-comboT'] = array
321(
322 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)(21|22|23|24)$@',
323 'replacement' => 'gi\\1\\2',
324 'dict_key' => '1-24',
325 'label' => '\\2',
326 'try_next_proc' => TRUE,
327);
328
24c3e444
DO
329$iftable_processors['quidway-21-to-24-comboSFP'] = array
330(
331 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)(21|22|23|24)$@',
332 'replacement' => 'gi\\1\\2',
333 'dict_key' => '4-1077',
334 'label' => '\\2',
335 'try_next_proc' => TRUE,
336);
337
b55f8de3
DO
338$iftable_processors['quidway-slot1-SFP'] = array
339(
340 'pattern' => '@^GigabitEthernet0/1/([[:digit:]]+)$@',
341 'replacement' => 'gi0/1/\\1',
342 'dict_key' => '4-1077',
343 'label' => 'SFP\\1',
344 'try_next_proc' => FALSE,
345);
346
7d69a266
DO
347$iftable_processors['quidway-any-1000SFP'] = array
348(
349 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
350 'replacement' => 'gi\\1\\2',
351 'dict_key' => '4-1077', // empty SFP-1000
352 'label' => '\\2',
353 'try_next_proc' => FALSE,
354);
355
24c3e444
DO
356$iftable_processors['quidway-any-1000T'] = array
357(
358 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
359 'replacement' => 'gi\\1\\2',
360 'dict_key' => '1-24',
361 'label' => '\\2',
362 'try_next_proc' => FALSE,
363);
364
7d69a266
DO
365$iftable_processors['quidway-XFP'] = array
366(
367 'pattern' => '@^XGigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
368 'replacement' => 'xg\\1\\2',
369 'dict_key' => '8-1082',
370 'label' => '\\2',
371 'try_next_proc' => FALSE,
372);
373
374$iftable_processors['quidway-mgmt'] = array
375(
376 'pattern' => '@^MEth([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
377 'replacement' => 'me\\1\\2',
378 'dict_key' => '1-19',
379 'label' => 'eth',
91389980
DO
380 'try_next_proc' => FALSE,
381);
382
661b3fdb
DO
383$iftable_processors['fgs-1-to-4-comboSFP'] = array
384(
385 # only 4 first copper ports of 1st unit of a stack
386 'pattern' => '@^GigabitEthernet1/1/(1|2|3|4)$@',
387 'replacement' => 'e1/1/\\1',
388 'dict_key' => '4-1077',
389 'label' => '\\1F',
390 'try_next_proc' => TRUE,
391);
392
393$iftable_processors['fgs-any-1000T'] = array
394(
395 'pattern' => '@^GigabitEthernet1/1/([[:digit:]]+)$@',
396 'replacement' => 'e1/1/\\1',
397 'dict_key' => '1-24',
398 'label' => '\\1',
399 'try_next_proc' => FALSE,
400);
401
402$iftable_processors['fgs-uplinks'] = array
403(
404 'pattern' => '@^10GigabitEthernet1/2/([[:digit:]]+)$@',
405 'replacement' => 'e1/2/\\1',
406 'dict_key' => '8-1082', // default is XFP, but may be overridden to CX4
407 'label' => 'Slot2 \\1',
408 'try_next_proc' => FALSE,
409);
410
ec523868
DO
411$iftable_processors['fcx-uplinks'] = array
412(
413 'pattern' => '@^10GigabitEthernet1/2/([[:digit:]]+)$@',
414 'replacement' => 'e1/2/\\1',
415 'dict_key' => '9-1084',
416 'label' => 'X\\1',
417 'try_next_proc' => FALSE,
418);
419
420$iftable_processors['fcx-management'] = array
421(
422 'pattern' => '@^Management$@',
423 'replacement' => 'management1',
424 'dict_key' => '1-24',
425 'label' => 'Management',
426 'try_next_proc' => FALSE,
427);
428
4eeadb79
DO
429$iftable_processors['summit-25-to-26-XFP-uplinks'] = array
430(
431 'pattern' => '@^.+ Port (25|26)$@',
432 'replacement' => '\\1',
433 'dict_key' => '8-1082',
434 'label' => '\\1',
435 'try_next_proc' => FALSE,
436);
437
dbcf1931
DO
438$iftable_processors['summit-27-to-30-XFP-uplinks'] = array
439(
440 'pattern' => '@^.+ Port (27|28|29|30)$@',
441 'replacement' => '\\1',
442 'dict_key' => '8-1082',
443 'label' => '\\1',
444 'try_next_proc' => FALSE,
445);
446
4eeadb79
DO
447$iftable_processors['summit-21-to-24-comboSFP'] = array
448(
449 'pattern' => '@^.+ Port (21|22|23|24)$@',
450 'replacement' => '\\1',
451 'dict_key' => '4-1077',
452 'label' => '\\1',
453 'try_next_proc' => TRUE,
454);
455
dbcf1931
DO
456$iftable_processors['summit-13-to-24-comboT'] = array
457(
458 'pattern' => '@^.+ Port (1[3456789]|2[01234])$@',
459 'replacement' => '\\1',
460 'dict_key' => '1-24',
461 'label' => '\\1',
462 'try_next_proc' => TRUE,
463);
464
4eeadb79
DO
465$iftable_processors['summit-any-1000T'] = array
466(
467 'pattern' => '@^.+ Port ([[:digit:]]+)$@',
468 'replacement' => '\\1',
469 'dict_key' => '1-24',
470 'label' => '\\1',
471 'try_next_proc' => FALSE,
472);
473
dbcf1931
DO
474$iftable_processors['summit-any-SFP'] = array
475(
476 'pattern' => '@^.+ Port ([[:digit:]]+)$@',
477 'replacement' => '\\1',
478 'dict_key' => '4-1077',
479 'label' => '\\1',
480 'try_next_proc' => FALSE,
481);
482
4eeadb79
DO
483$iftable_processors['summit-management'] = array
484(
485 'pattern' => '@^Management Port$@',
486 'replacement' => 'mgmt',
487 'dict_key' => '1-19',
21d38e6b 488 'label' => 'management',
4eeadb79
DO
489 'try_next_proc' => FALSE,
490);
491
74aee2dc
DO
492$known_switches = array // key is system OID w/o "enterprises" prefix
493(
d7466acb
DO
494 '9.1.248' => array
495 (
496 'dict_key' => 393,
497 'text' => 'WS-C3524-XL: 24 RJ-45/10-100TX + 2 GBIC/1000',
498 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
499 ),
74aee2dc
DO
500 '9.1.324' => array
501 (
502 'dict_key' => 380,
503 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
6be06cbb 504 'processors' => array ('catalyst-chassis-any-100TX'),
74aee2dc
DO
505 ),
506 '9.1.325' => array
507 (
508 'dict_key' => 382,
509 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
6be06cbb 510 'processors' => array ('catalyst-chassis-25-to-26-100FX/MT-RJ', 'catalyst-chassis-any-100TX'),
74aee2dc 511 ),
7e87a291
DO
512 '9.1.695' => array
513 (
514 'dict_key' => 140,
515 'text' => 'WS-C2960-48TC-L: 48 RJ-45/10-100TX + 2 combo-gig',
516 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
517 ),
a048e8fc
DO
518 '9.1.799' => array
519 (
520 'dict_key' => 168,
521 'text' => 'WS-C2960G-8TC-L: 7 RJ-45/10-100-1000T(X) + 1 combo-gig',
522 'processors' => array ('catalyst-chassis-8-combo-1000SFP', 'catalyst-chassis-any-1000T'),
523 ),
74aee2dc
DO
524 '9.1.696' => array
525 (
526 'dict_key' => 167,
527 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 528 'processors' => array ('catalyst-chassis-21-to-24-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
529 ),
530 '9.1.697' => array
531 (
532 'dict_key' => 166,
533 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 534 'processors' => array ('catalyst-chassis-45-to-48-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
535 ),
536 '9.1.716' => array
537 (
538 'dict_key' => 164,
539 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 540 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
541 ),
542 '9.1.717' => array
543 (
544 'dict_key' => 162,
545 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 546 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc 547 ),
ec523868
DO
548 '9.1.950' => array
549 (
550 'dict_key' => 1347,
551 'text' => 'WS-C2960-24PC: 44 RJ-45/10-100TX + 2 combo-gig',
552 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
553 ),
74aee2dc
DO
554 '9.1.527' => array
555 (
556 'dict_key' => 210,
557 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
6be06cbb 558 'processors' => array ('catalyst-chassis-any-1000T'),
74aee2dc
DO
559 ),
560 '9.1.561' => array
561 (
562 'dict_key' => 115,
563 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 564 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
565 ),
566 '9.1.633' => array
567 (
568 'dict_key' => 169,
569 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 570 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
571 ),
572 '9.1.634' => array
573 (
574 'dict_key' => 170,
575 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 576 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
577 ),
578 '9.1.563' => array
579 (
580 'dict_key' => 171,
581 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 582 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
583 ),
584 '9.1.564' => array
585 (
586 'dict_key' => 172,
587 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 588 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
589 ),
590 '9.1.614' => array
591 (
592 'dict_key' => 175,
593 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 594 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
595 ),
596 '9.1.615' => array
597 (
598 'dict_key' => 173,
599 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 600 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
601 ),
602 '9.1.616' => array
603 (
604 'dict_key' => 176,
605 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 606 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
607 ),
608 '9.1.617' => array
609 (
610 'dict_key' => 174,
611 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 612 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
613 ),
614 '9.1.626' => array
615 (
616 'dict_key' => 147,
56a797ef 617 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
cbc30061 618 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
74aee2dc
DO
619 ),
620 '9.1.659' => array
621 (
622 'dict_key' => 377,
56a797ef 623 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
cbc30061 624 'processors' => array ('catalyst-chassis-uplinks-10000X2', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
74aee2dc
DO
625 ),
626 '9.1.428' => array
627 (
628 'dict_key' => 389,
629 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 630 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
631 ),
632 '9.1.429' => array
633 (
634 'dict_key' => 390,
635 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 636 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
637 ),
638 '9.1.559' => array
639 (
640 'dict_key' => 387,
641 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 642 'processors' => array ('catalyst-chassis-uplinks-1000T', 'catalyst-chassis-any-100TX'),
74aee2dc 643 ),
8a4bee49
DO
644 '9.1.560' => array
645 (
646 'dict_key' => 384,
647 'text' => 'WS-C2950SX-48: 48 RJ-45/10-100TX + 2 1000Base-SX',
648 'processors' => array ('catalyst-chassis-uplinks-1000SX', 'catalyst-chassis-any-100TX'),
649 ),
74aee2dc
DO
650 '9.1.749' => array
651 (
652 'dict_key' => 989,
653 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 654 'processors' => array ('catalyst-blade-11-to-12-1000T', 'catalyst-blade-13-to-16-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc
DO
655 ),
656 '9.1.920' => array
657 (
658 'dict_key' => 795,
659 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 660 'processors' => array ('catalyst-blade-17-to-20-1000T', 'catalyst-blade-21-to-24-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc 661 ),
2217e284
DO
662 '9.1.367' => array
663 (
664 'dict_key' => 404,
665 'text' => 'WS-C3550-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
666 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000GBIC'),
667 ),
7e87a291
DO
668 '9.1.368' => array
669 (
670 'dict_key' => 398,
671 'text' => 'WS-C3550-12T: 10 RJ-45/10-100-1000T(X) + 2 GBIC/1000',
672 'processors' => array ('catalyst-1-to-10-1000T', 'catalyst-11-to-12-GBIC'),
673 ),
a9bd9e98
DO
674 '9.1.282' => array
675 (
676 'dict_key' => 154,
677 'text' => 'WS-C6506: modular device (INCOMPLETE!)',
678 'processors' => array ('catalyst-chassis-any-1000T'),
679 ),
65b4b21a
DO
680 '9.1.1104' => array
681 (
682 'dict_key' => 1348,
683 'text' => 'WS-C2350-48TD: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 w/TwinGig option',
684 'processors' => array
685 (
686 'catalyst-chassis-49-to-52-1000SFP', // TwinGig actually
687 'catalyst-chassis-any-1000T',
688 'catalyst-chassis-uplinks-10000X2',
689 'catalyst-chassis-mgmt',
690 ),
691 ),
74aee2dc
DO
692 '9.12.3.1.3.719' => array
693 (
694 'dict_key' => 960,
695 'text' => 'N5K-C5020: 40 SFP+/10000',
e7662d90 696 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
74aee2dc 697 ),
bc45a3a4
DO
698 '9.12.3.1.3.798' => array
699 (
700 'dict_key' => 959,
701 'text' => 'N5K-C5010: 20 SFP+/10000',
702 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
703 ),
56a797ef
DO
704 '11.2.3.7.11.32' => array
705 (
706 'dict_key' => 871,
707 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
708 'processors' => array ('procurve-chassis-1000T'),
709 ),
74aee2dc
DO
710 '11.2.3.7.11.36' => array
711 (
712 'dict_key' => 865,
713 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 714 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
715 ),
716 '11.2.3.7.11.35' => array
717 (
718 'dict_key' => 867,
719 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
720 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
721 ),
722 '11.2.3.7.11.9' => array
723 (
724 'dict_key' => 1086,
725 'text' => 'J4121A: modular system',
726 'processors' => array ('procurve-modular-100TX'),
74aee2dc 727 ),
4b43f713
DO
728 '11.2.3.7.11.87' => array
729 (
730 'dict_key' => 1349,
731 'text' => 'J9147A: 44 RJ-45/10-100-1000T(X) + 4 combo-gig)',
732 'processors' => array ('procurve-45-to-48-combo-1000SFP', 'procurve-chassis-1000T'),
733 ),
74aee2dc
DO
734 '4526.100.2.2' => array
735 (
736 'dict_key' => 562,
6be06cbb
DO
737 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
738 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
74aee2dc 739 ),
56a797ef
DO
740 '45.3.68.5' => array
741 (
742 'dict_key' => 1085,
743 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
744 'processors' => array ('nortel-any-1000T'),
745 ),
91389980
DO
746 '2636.1.1.1.2.29' => array
747 (
748 'dict_key' => 925,
749 'text' => 'MX240 modular router',
750 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
751 ),
7d69a266
DO
752 '2011.2.23.96' => array
753 (
754 'dict_key' => 1321,
24c3e444 755 'text' => 'S5328C-EI-24S: 20 SFP-1000 + 4 combo-gig + 2 XFP slots',
7d69a266
DO
756 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
757 ),
b55f8de3
DO
758 '2011.2.23.103' => array
759 (
760 'dict_key' => 1341,
761 'text' => 'S5352C-SI: 48 RJ-45/10-100-1000T(X) + optional 2xXFP/4xSFP slots',
762 'processors' => array ('quidway-slot1-SFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
763 ),
24c3e444
DO
764 '2011.2.23.102' => array
765 (
766 'dict_key' => 1339,
767 'text' => 'S5328C-SI: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
768 'processors' => array ('quidway-21-to-24-comboSFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
769 ),
661b3fdb
DO
770 '1991.1.3.45.2.1.1.1' => array
771 (
772 'dict_key' => 127,
773 'text' => 'FGS648P: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
774 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
775 ),
776 '1991.1.3.45.2.2.1.1' => array
777 (
778 'dict_key' => 131,
779 'text' => 'FGS648P-POE: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
780 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
781 ),
ec523868
DO
782 '1991.1.3.54.2.4.1.1' => array
783 (
784 'dict_key' => 1362,
785 'text' => 'FCX 648: 48 RJ-45/10-100-1000T(X) + uplink slot with 4 SFP+',
786 'processors' => array ('fgs-any-1000T', 'fcx-uplinks', 'fcx-management'),
787 ),
4eeadb79
DO
788 '1916.2.71' => array
789 (
790 'dict_key' => 694,
791 'text' => 'X450a-24t: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + XFP uplinks slot',
792 'processors' => array ('summit-25-to-26-XFP-uplinks', 'summit-21-to-24-comboSFP', 'summit-any-1000T', 'summit-management'),
793 ),
dbcf1931
DO
794 '1916.2.139' => array
795 (
796 'dict_key' => 1353,
797 'text' => 'X480-24x: 12 SFP-1000 + 12 combo-gig + 2 XFP + VIM slot',
798 'processors' => array
799 (
800 'summit-27-to-30-XFP-uplinks',
801 'summit-25-to-26-XFP-uplinks',
802 'summit-13-to-24-comboT',
803 'summit-any-SFP',
804 'summit-management'
805 ),
806 ),
74aee2dc
DO
807);
808
74aee2dc
DO
809function updateStickerForCell ($cell, $attr_id, $new_value)
810{
811 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
812 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
813}
814
bdc91a5c
DO
815// Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
816// a record with IIF id = X and OIF id = Y.
817function checkPIC ($port_type_id)
818{
819 $matches = array();
820 switch (1)
821 {
822 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
823 $iif_id = $matches[1];
824 $oif_id = $matches[2];
825 break;
826 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
827 $iif_id = 1;
828 $oif_id = $matches[1];
829 break;
830 default:
831 return;
832 }
833 foreach (getPortInterfaceCompat() as $record)
834 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
835 return;
836 commitSupplementPIC ($iif_id, $oif_id);
837}
838
8536e20a
DO
839$msgcode['doSNMPmining']['ERR1'] = 161;
840$msgcode['doSNMPmining']['ERR2'] = 162;
8536e20a 841$msgcode['doSNMPmining']['OK'] = 81;
56a797ef 842function doSNMPmining ($object_id, $community)
74aee2dc 843{
74aee2dc
DO
844 $objectInfo = spotEntity ('object', $object_id);
845 $objectInfo['attrs'] = getAttrValues ($object_id);
846 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
847 if (count ($endpoints) == 0)
8536e20a 848 return buildRedirectURL (__FUNCTION__, 'ERR1'); // endpoint not found
74aee2dc 849 if (count ($endpoints) > 1)
8536e20a 850 return buildRedirectURL (__FUNCTION__, 'ERR2'); // can't pick an address
4848a7e3
DO
851
852 switch ($objectInfo['objtype_id'])
853 {
24a6e3a2 854 case 7:
4848a7e3
DO
855 case 8:
856 return doSwitchSNMPmining ($objectInfo, $endpoints[0], $community);
857 case 2:
858 return doPDUSNMPmining ($objectInfo, $endpoints[0], $community);
859 }
860}
861
24a6e3a2 862$msgcode['doSwitchSNMPmining']['ERR3'] = 188;
e22f9600 863$msgcode['doSwitchSNMPmining']['ERR4'] = 189;
24a6e3a2 864function doSwitchSNMPmining ($objectInfo, $hostname, $community)
4848a7e3
DO
865{
866 $log = emptyLog();
867 global $known_switches, $iftable_processors;
74aee2dc 868
24a6e3a2 869 if (FALSE === ($sysObjectID = @snmpget ($hostname, $community, 'sysObjectID.0')))
8536e20a 870 return buildRedirectURL (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
84986395 871 $sysObjectID = preg_replace ('/^.*(enterprises\.)([\.[:digit:]]+)$/', '\\2', $sysObjectID);
24a6e3a2
DO
872 $sysName = substr (@snmpget ($hostname, $community, 'sysName.0'), strlen ('STRING: '));
873 $sysDescr = substr (@snmpget ($hostname, $community, 'sysDescr.0'), strlen ('STRING: '));
74aee2dc
DO
874 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
875 if (!isset ($known_switches[$sysObjectID]))
8536e20a 876 return buildRedirectURL (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
5e193b67
DO
877 foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
878 if (!array_key_exists ($known_switches[$sysObjectID]['processors'][$pkey], $iftable_processors))
879 {
880 $log = mergeLogs ($log, oneLiner (200, array ('processor "' . $known_switches[$sysObjectID]['processors'][$pkey] . '" not found')));
881 unset ($known_switches[$sysObjectID]['processors'][$pkey]);
882 }
56a797ef 883 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 884 updateStickerForCell ($objectInfo, 3, $sysName);
56a797ef 885 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
74aee2dc
DO
886 switch (1)
887 {
56a797ef 888 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
84986395
DO
889 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
890 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
891 $ios_codes = array
892 (
893 '12.0' => 244,
894 '12.1' => 251,
895 '12.2' => 252,
896 );
897 updateStickerForCell ($objectInfo, 5, $exact_release);
6be06cbb
DO
898 if (array_key_exists ($major_line, $ios_codes))
899 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
24a6e3a2 900 $sysChassi = @snmpget ($hostname, $community, '1.3.6.1.4.1.9.3.6.3.0');
74aee2dc
DO
901 if ($sysChassi !== FALSE or $sysChassi !== NULL)
902 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
bdc91a5c
DO
903 checkPIC ('1-29');
904 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
facd0235
DO
905 // blade devices are powered through internal circuitry of chassis
906 if ($sysObjectID != '9.1.749' and $sysObjectID != '9.1.920')
907 {
908 checkPIC ('1-16'); // AC input
909 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
910 }
56a797ef 911 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
74aee2dc 912 break;
56a797ef 913 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
84986395
DO
914 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
915 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
916 $nxos_codes = array
917 (
918 '4.0' => 963,
919 '4.1' => 964,
920 );
6be06cbb
DO
921 if (array_key_exists ($major_line, $nxos_codes))
922 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
74aee2dc 923 updateStickerForCell ($objectInfo, 5, $exact_release);
bdc91a5c 924 checkPIC ('1-29');
24a6e3a2 925 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
dcfa87d7
DO
926 checkPIC ('1-16'); // AC input
927 commitAddPort ($objectInfo['id'], 'AC-in-1', '1-16', 'AC1', '');
928 commitAddPort ($objectInfo['id'], 'AC-in-2', '1-16', 'AC2', '');
56a797ef 929 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
74aee2dc 930 break;
56a797ef 931 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
84986395 932 $exact_release = preg_replace ('/^.* revision ([^ ]+), .*$/', '\\1', $sysDescr);
74aee2dc 933 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 934 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
74aee2dc 935 break;
6be06cbb 936 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
bdc91a5c
DO
937 checkPIC ('1-681');
938 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
6be06cbb
DO
939 $log = mergeLogs ($log, oneLiner (81, array ('netgear-generic')));
940 break;
7d69a266 941 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
ec523868
DO
942 $swtype_pcre = array
943 (
944 '/Huawei Versatile Routing Platform Software.+VRP.+Software, Version 5.30 /s' => 1360,
945 '/Huawei Versatile Routing Platform Software.+VRP.+Software, Version 5.50 /s' => 1361,
946 );
947 foreach ($swtype_pcre as $pattern => $dict_key)
948 if (preg_match ($pattern, $sysDescr))
949 {
950 updateStickerForCell ($objectInfo, 4, $dict_key);
951 break;
952 }
bdc91a5c 953 checkPIC ('1-681');
b55f8de3 954 commitAddPort ($objectInfo['id'], 'con0', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
955 $log = mergeLogs ($log, oneLiner (81, array ('huawei-generic')));
956 break;
957 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
bdc91a5c
DO
958 checkPIC ('1-681');
959 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266 960 $log = mergeLogs ($log, oneLiner (81, array ('juniper-generic')));
661b3fdb
DO
961 break;
962 case preg_match ('/^1991\.1\.3\.45\./', $sysObjectID): // snFGSFamily
ec523868 963 case preg_match ('/^1991\.1\.3\.54\.2\.4\.1\.1$/', $sysObjectID): // FCX 648
84986395 964 $exact_release = preg_replace ('/^.*, IronWare Version ([^ ]+) .*$/', '\\1', $sysDescr);
661b3fdb
DO
965 updateStickerForCell ($objectInfo, 5, $exact_release);
966 # FOUNDRY-SN-AGENT-MIB::snChasSerNum.0
967 $sysChassi = @snmpget ($hostname, $community, 'enterprises.1991.1.1.1.1.2.0');
968 if ($sysChassi !== FALSE or $sysChassi !== NULL)
969 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
970
971 # Type of uplink module installed.
972 # table: FOUNDRY-SN-AGENT-MIB::snAgentBrdMainBrdDescription
973 # Possible part numbers are:
974 # FGS-1XG1XGC (one fixed CX4 port)
975 # FGS-2XGC (two fixed CX4 ports)
976 # FGS-2XG (two XFP slots)
977 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.2.2.1.1.2') as $module_raw)
978 if (preg_match ('/^STRING: "(FGS-1XG1XGC|FGS-2XGC) /i', $module_raw))
979 {
980 $iftable_processors['fgs-uplinks']['dict_key'] = '1-40'; // CX4
981 break;
982 }
983
984 # AC inputs
985 # table: FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
986 # "Power supply 1 "
987 # "Power supply 2 "
988 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.1.2.1.1.2') as $PSU_raw)
989 {
990 $count = 0;
991 $PSU_cooked = trim (preg_replace ('/^string: "(.+)"$/i', '\\1', $PSU_raw, 1, $count));
992 if ($count)
993 {
994 checkPIC ('1-16');
995 commitAddPort ($objectInfo['id'], $PSU_cooked, '1-16', '', '');
996 }
997 }
998 # fixed console port
999 checkPIC ('1-681');
1000 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
1001 $log = mergeLogs ($log, oneLiner (81, array ('brocade-generic')));
1002 break;
4eeadb79
DO
1003 case preg_match ('/^1916\.2\./', $sysObjectID): // Extreme Networks Summit
1004 $xos_release = preg_replace ('/^ExtremeXOS version ([[:digit:]]+)\..*$/', '\\1', $sysDescr);
1005 $xos_codes = array
1006 (
1007 '10' => 1350,
1008 '11' => 1351,
1009 '12' => 1352,
1010 );
1011 if (array_key_exists ($xos_release, $xos_codes))
1012 updateStickerForCell ($objectInfo, 4, $xos_codes[$xos_release]);
1013 checkPIC ('1-681');
1014 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232
1015 checkPIC ('1-16');
1016 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
1017 $log = mergeLogs ($log, oneLiner (81, array ('summit-generic')));
1018 break;
7d69a266 1019 default: // Nortel...
74aee2dc
DO
1020 break;
1021 }
56a797ef
DO
1022 $ifInfo = array();
1023 $tablename = 'ifDescr';
24a6e3a2 1024 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef 1025 {
84986395
DO
1026 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
1027 $value = trim (preg_replace ('/^.+: (.+)$/', '\\1', $value), '"');
56a797ef
DO
1028 $ifInfo[$randomindex][$tablename] = $value;
1029 }
1030 $tablename = 'ifPhysAddress';
24a6e3a2 1031 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef 1032 {
84986395 1033 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
56a797ef
DO
1034 $value = trim ($value);
1035 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
1036 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
1037 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
6a845dce 1038 if (preg_match ('/^string: [0-9a-f]{1,2}(:[0-9a-f]{1,2}){5}/i', $value)) // STRING: x:yy:z:xx:y:zz
56a797ef
DO
1039 {
1040 list ($dummy, $value) = explode (' ', $value);
1041 $addrbytes = explode (':', $value);
1042 foreach ($addrbytes as $bidx => $bytestr)
1043 if (strlen ($bytestr) == 1)
1044 $addrbytes[$bidx] = '0' . $bytestr;
1045 }
6a845dce 1046 elseif (preg_match ('/^hex-string:( [0-9a-f]{2}){6}/i', $value)) // Hex-STRING: xx yy zz xx yy zz
56a797ef 1047 $addrbytes = explode (' ', substr ($value, -17));
6a845dce
DO
1048 elseif (preg_match ('/22[0-9a-f]{12}22$/', bin2hex ($value))) // STRING: "??????"
1049 $addrbytes = array (substr (bin2hex ($value), -14, 12));
56a797ef
DO
1050 else
1051 continue; // martian format
1052 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
1053 }
1054 // process each interface only once regardless of how many processors we have to run
1055 foreach ($ifInfo as $iface)
1056 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
1057 {
56a797ef
DO
1058 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
1059 if (!$count)
1060 continue; // try next processor on current port
1061 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
bdc91a5c 1062 checkPIC ($iftable_processors[$processor_name]['dict_key']);
24a6e3a2 1063 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
56a797ef
DO
1064 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
1065 continue 2;
1066 }
1067 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
1068 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
8536e20a
DO
1069 // No failure up to this point, thus leave current tab for the "Ports" one.
1070 return buildWideRedirectURL ($log, NULL, 'ports');
74aee2dc
DO
1071}
1072
4848a7e3
DO
1073$msgcode['doPDUSNMPmining']['OK'] = 0;
1074function doPDUSNMPmining ($objectInfo, $hostname, $community)
38e05b77 1075{
29de85b6
DO
1076 $log = emptyLog();
1077 global $known_APC_SKUs;
4848a7e3 1078 $switch = new APCPowerSwitch ($hostname, $community);
29de85b6
DO
1079 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
1080 updateStickerForCell ($objectInfo, 2, $dict_key);
1081 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
4848a7e3 1082 updateStickerForCell ($objectInfo, 3, $switch->getName());
29de85b6 1083 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
bdc91a5c 1084 checkPIC ('1-16');
29de85b6 1085 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
4848a7e3
DO
1086 $portno = 1;
1087 foreach ($switch->getPorts() as $name => $port)
29de85b6
DO
1088 {
1089 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
bdc91a5c 1090 checkPIC ('1-1322');
29de85b6
DO
1091 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
1092 $portno++;
1093 }
912d98f8 1094 $log = mergeLogs ($log, oneLiner (0, array ("Added ${portno} port(s)")));
29de85b6 1095 return buildWideRedirectURL ($log, NULL, 'ports');
38e05b77
DO
1096}
1097
4848a7e3 1098// APC SNMP code by Russ Garrett
38e05b77
DO
1099define('APC_STATUS_ON', 1);
1100define('APC_STATUS_OFF', 2);
1101define('APC_STATUS_REBOOT', 3);
1102
1103class SNMPDevice {
1104 protected $hostname;
1105 protected $community;
1106
1107 function __construct($hostname, $community) {
1108 $this->hostname = $hostname;
1109 $this->community = $community;
1110 }
1111
1112 function getName() {
1113 return $this->getString('sysName.0');
1114 }
1115
1116 function getDescription() {
1117 return $this->getString('sysDescr.0');
1118 }
1119
1120 protected function snmpSet($oid, $type, $value) {
1121 return snmpset($this->hostname, $this->community, $oid, $type, $value);
1122 }
1123
1124 protected function getString($oid) {
1125 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, $oid)), '"');
1126 }
1127}
1128
1129class APCPowerSwitch extends SNMPDevice {
1130 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
1131
1132 function getPorts() {
1133 $data = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2");
1134 $status = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4");
1135 $out = array();
1136 foreach ($data as $id => $d) {
1137 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
1138 }
1139 return $out;
1140 }
1141
1142 function getPortStatus($id) {
1143 return trim(snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
1144 }
1145
1146 function getPortName($id) {
1147 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
1148 }
1149
1150 function setPortName($id, $name) {
1151 return snmpset($this->hostname, $this->community, "{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
1152 }
1153
1154 function portOff($id) {
1155 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
1156 }
1157
1158 function portOn($id) {
1159 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
1160 }
1161
1162 function portReboot($id) {
1163 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
1164 }
30ad8bc4
DO
1165 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
1166 function getFWRev()
1167 {
1168 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.3.0"));
1169 }
1170 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
1171 function getHWSerial()
1172 {
1173 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.6.0"));
1174 }
1175 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
1176 function getHWModel()
1177 {
1178 return preg_replace ('/^STRING: "(.*)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.5.0"));
1179 }
38e05b77
DO
1180}
1181
2d511052
DO
1182// Take address in the form XX:XX:XX:XX:XX:XX and return the next
1183// address in the same form.
1184function nextMACAddress ($addr)
1185{
cc000fab
DO
1186 if ($addr == '')
1187 return '';
2d511052
DO
1188 $bytes = array();
1189 foreach (explode (':', $addr) as $hex)
1190 $bytes[] = hexdec ($hex);
1191 for ($i = 5; $i >= 0; $i--)
1192 {
1193 $bytes[$i] += 1;
1194 if ($bytes[$i] <= 255) // FF
1195 break; // no roll over
1196 $bytes[$i] = 0;
1197 }
1198 foreach (array_keys ($bytes) as $key)
1199 $bytes[$key] = sprintf ('%02X', $bytes[$key]);
1200 return implode (':', $bytes);
1201}
1202
1203function generatePortsForCatModule ($object_id, $slotno = 1, $mtype = 'X6748', $mac_address = '')
1204{
1205 global $dbxlink;
1206 $mac_address = l2addressFromDatabase (l2addressForDatabase ($mac_address));
1207 switch ($mtype)
1208 {
cc000fab 1209 case 'WS-X6748-GE-TX':
2d511052
DO
1210 $dbxlink->beginTransaction();
1211 for ($i = 1; $i <= 48; $i++)
1212 {
1213 if ('' != commitAddPort ($object_id, "gi${slotno}/${i}", '1-24', "slot ${slotno} port ${i}", $mac_address))
1214 {
1215 $dbxlink->rollBack();
1216 break 2;
1217 }
cc000fab 1218 $mac_address = nextMACAddress ($mac_address);
2d511052
DO
1219 }
1220 $dbxlink->commit();
1221 break;
cc000fab
DO
1222 case 'WS-X6708-10GE':
1223 for ($i = 1; $i <= 8; $i++)
1224 {
1225 commitAddPort ($object_id, "te${slotno}/${i}", '6-1080', "slot ${slotno} port ${i}", $mac_address);
1226 $mac_address = nextMACAddress ($mac_address);
1227 }
1228 break;
8fe2d6f0
DO
1229 case 'WS-X6704-10GE':
1230 for ($i = 1; $i <= 4; $i++)
1231 {
1232 commitAddPort ($object_id, "te${slotno}/${i}", '5-1079', "slot ${slotno} port ${i}", $mac_address);
1233 $mac_address = nextMACAddress ($mac_address);
1234 }
1235 break;
cc000fab
DO
1236 case 'VS-S720-10G':
1237 commitAddPort ($object_id, "gi${slotno}/1", '4-1077', "slot ${slotno} port 1", $mac_address);
1238 $mac_address = nextMACAddress ($mac_address);
1239 commitAddPort ($object_id, "gi${slotno}/2", '4-1077', "slot ${slotno} port 2", $mac_address);
1240 $mac_address = nextMACAddress ($mac_address);
1241 commitAddPort ($object_id, "gi${slotno}/3", '1-24', "slot ${slotno} port 3", $mac_address);
1242 $mac_address = nextMACAddress ($mac_address);
1243 commitAddPort ($object_id, "te${slotno}/4", '6-1080', "slot ${slotno} port 4", $mac_address);
1244 $mac_address = nextMACAddress ($mac_address);
1245 commitAddPort ($object_id, "te${slotno}/5", '6-1080', "slot ${slotno} port 5", $mac_address);
1246 break;
3e34adae
DO
1247 case '3750G-24TS':
1248 // MAC address of 1st port is the next one after switch's address
cc000fab 1249 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1250 for ($i = 1; $i <= 24; $i++)
1251 {
1252 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
cc000fab 1253 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1254 }
1255 for ($i = 25; $i <= 28; $i++)
1256 {
1257 commitAddPort ($object_id, "gi${slotno}/0/${i}", '4-1077', "unit ${slotno} port ${i}", $mac_address);
cc000fab 1258 $mac_address = nextMACAddress ($mac_address);
3e34adae
DO
1259 }
1260 break;
d423bb7d
DO
1261 case '3750G-16TD':
1262 $mac_address = nextMACAddress ($mac_address);
1263 for ($i = 1; $i <= 16; $i++)
1264 {
1265 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
1266 $mac_address = nextMACAddress ($mac_address);
1267 }
1268 commitAddPort ($object_id, "te${slotno}/0/1", '5-1079', "unit ${slotno} port ${i}", $mac_address);
1269 break;
c5553818
DO
1270 case 'LE02G48TA':
1271 for ($i = 0; $i <= 47; $i++)
1272 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "slot ${slotno} port ${i}", $mac_address);
1273 break;
1274 case 'LE02X12SA':
1275 for ($i = 0; $i <= 11; $i++)
1276 commitAddPort ($object_id, "gi${slotno}/0/${i}", '9-1084', "slot ${slotno} port ${i}", $mac_address);
1277 break;
2d511052
DO
1278 }
1279}
1280
2ffd5a2a 1281?>