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