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