r3737 fixed Summit's management port label
[racktables] / inc / snmp.php
1 <?php
2
3 $iftable_processors = array();
4
5 $iftable_processors['catalyst-chassis-mgmt'] = array
6 (
7 'pattern' => '@^FastEthernet([[:digit:]])$@',
8 'replacement' => 'fa\\1',
9 'dict_key' => '1-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-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
59 $iftable_processors['catalyst-chassis-any-1000SFP'] = array
60 (
61 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
62 'replacement' => 'gi\\1\\2',
63 'dict_key' => '4-1077',
64 'label' => '\\2',
65 'try_next_proc' => FALSE,
66 );
67
68 $iftable_processors['catalyst-chassis-any-1000GBIC'] = array
69 (
70 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
71 'replacement' => 'gi\\1\\2',
72 'dict_key' => '3-1078',
73 'label' => '\\2',
74 'try_next_proc' => FALSE,
75 );
76
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
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
95 $iftable_processors['catalyst-chassis-21-to-24-combo-1000SFP'] = array
96 (
97 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
98 'replacement' => 'gi\\1\\2',
99 'dict_key' => '4-1077',
100 'label' => '\\2',
101 'try_next_proc' => TRUE,
102 );
103
104 $iftable_processors['catalyst-chassis-45-to-48-combo-1000SFP'] = array
105 (
106 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(45|46|47|48)$@',
107 'replacement' => 'gi\\1\\2',
108 'dict_key' => '4-1077',
109 'label' => '\\2',
110 'try_next_proc' => TRUE,
111 );
112
113 $iftable_processors['catalyst-chassis-uplinks-10000X2'] = array
114 (
115 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
116 'replacement' => 'te\\1\\2',
117 'dict_key' => '6-1080',
118 'label' => '\\2',
119 'try_next_proc' => FALSE,
120 );
121
122 $iftable_processors['catalyst-chassis-25-to-28-1000SFP'] = array
123 (
124 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(25|26|27|28)$@',
125 'replacement' => 'gi\\1\\2',
126 'dict_key' => '4-1077',
127 'label' => '\\2',
128 'try_next_proc' => FALSE,
129 );
130
131 $iftable_processors['catalyst-chassis-49-to-52-1000SFP'] = array
132 (
133 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(49|50|51|52)$@',
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-13-to-16-1000SFP'] = array
141 (
142 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(13|14|15|16)$@',
143 'replacement' => 'gi\\1\\2',
144 'dict_key' => '4-1077',
145 'label' => '\\2',
146 'try_next_proc' => FALSE,
147 );
148
149 $iftable_processors['catalyst-blade-21-to-24-1000SFP'] = array
150 (
151 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
152 'replacement' => 'gi\\1\\2',
153 'dict_key' => '4-1077',
154 'label' => '\\2',
155 'try_next_proc' => FALSE,
156 );
157
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
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
203 $iftable_processors['nexus-any-10000SFP+'] = array
204 (
205 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
206 'replacement' => 'e\\1',
207 'dict_key' => '9-1084',
208 'label' => '\\1',
209 'try_next_proc' => FALSE,
210 );
211
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
221 $iftable_processors['procurve-chassis-100TX'] = array
222 (
223 'pattern' => '@^([[:digit:]]+)$@',
224 'replacement' => '\\1',
225 'dict_key' => 19,
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
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
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,
255 );
256
257 $iftable_processors['procurve-25-to-26-1000T'] = array
258 (
259 'pattern' => '@^(25|26)$@',
260 'replacement' => '\\1',
261 'dict_key' => 24,
262 'label' => '\\1',
263 'try_next_proc' => FALSE,
264 );
265
266 $iftable_processors['procurve-49-to-50-1000T'] = array
267 (
268 'pattern' => '@^(49|50)$@',
269 'replacement' => '\\1',
270 'dict_key' => 24,
271 'label' => '\\1',
272 'try_next_proc' => FALSE,
273 );
274
275 $iftable_processors['netgear-chassis-any-1000T'] = array
276 (
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
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',
297 'dict_key' => '4-1077',
298 'label' => '\\1F',
299 'try_next_proc' => TRUE,
300 );
301
302 $iftable_processors['nortel-any-1000T'] = array
303 (
304 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
305 'replacement' => '\\1',
306 'dict_key' => 24,
307 'label' => '\\1',
308 'try_next_proc' => FALSE,
309 );
310
311 $iftable_processors['juniper-DPCE-R-4XGE-XFP'] = array
312 (
313 'pattern' => '@^xe-([[:digit:]]+)/([[:digit:]]+/[[:digit:]]+)$@',
314 'replacement' => '\\0',
315 'dict_key' => '8-1082', // XFP/empty
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
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
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
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
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
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',
380 'try_next_proc' => FALSE,
381 );
382
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
411 $iftable_processors['summit-25-to-26-XFP-uplinks'] = array
412 (
413 'pattern' => '@^.+ Port (25|26)$@',
414 'replacement' => '\\1',
415 'dict_key' => '8-1082',
416 'label' => '\\1',
417 'try_next_proc' => FALSE,
418 );
419
420 $iftable_processors['summit-21-to-24-comboSFP'] = array
421 (
422 'pattern' => '@^.+ Port (21|22|23|24)$@',
423 'replacement' => '\\1',
424 'dict_key' => '4-1077',
425 'label' => '\\1',
426 'try_next_proc' => TRUE,
427 );
428
429 $iftable_processors['summit-any-1000T'] = array
430 (
431 'pattern' => '@^.+ Port ([[:digit:]]+)$@',
432 'replacement' => '\\1',
433 'dict_key' => '1-24',
434 'label' => '\\1',
435 'try_next_proc' => FALSE,
436 );
437
438 $iftable_processors['summit-management'] = array
439 (
440 'pattern' => '@^Management Port$@',
441 'replacement' => 'mgmt',
442 'dict_key' => '1-19',
443 'label' => 'management',
444 'try_next_proc' => FALSE,
445 );
446
447 $known_switches = array // key is system OID w/o "enterprises" prefix
448 (
449 '9.1.248' => array
450 (
451 'dict_key' => 393,
452 'text' => 'WS-C3524-XL: 24 RJ-45/10-100TX + 2 GBIC/1000',
453 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
454 ),
455 '9.1.324' => array
456 (
457 'dict_key' => 380,
458 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
459 'processors' => array ('catalyst-chassis-any-100TX'),
460 ),
461 '9.1.325' => array
462 (
463 'dict_key' => 382,
464 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
465 'processors' => array ('catalyst-chassis-25-to-26-100FX/MT-RJ', 'catalyst-chassis-any-100TX'),
466 ),
467 '9.1.695' => array
468 (
469 'dict_key' => 140,
470 'text' => 'WS-C2960-48TC-L: 48 RJ-45/10-100TX + 2 combo-gig',
471 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
472 ),
473 '9.1.799' => array
474 (
475 'dict_key' => 168,
476 'text' => 'WS-C2960G-8TC-L: 7 RJ-45/10-100-1000T(X) + 1 combo-gig',
477 'processors' => array ('catalyst-chassis-8-combo-1000SFP', 'catalyst-chassis-any-1000T'),
478 ),
479 '9.1.696' => array
480 (
481 'dict_key' => 167,
482 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
483 'processors' => array ('catalyst-chassis-21-to-24-combo-1000SFP', 'catalyst-chassis-any-1000T'),
484 ),
485 '9.1.697' => array
486 (
487 'dict_key' => 166,
488 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
489 'processors' => array ('catalyst-chassis-45-to-48-combo-1000SFP', 'catalyst-chassis-any-1000T'),
490 ),
491 '9.1.716' => array
492 (
493 'dict_key' => 164,
494 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
495 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
496 ),
497 '9.1.717' => array
498 (
499 'dict_key' => 162,
500 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
501 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
502 ),
503 '9.1.527' => array
504 (
505 'dict_key' => 210,
506 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
507 'processors' => array ('catalyst-chassis-any-1000T'),
508 ),
509 '9.1.561' => array
510 (
511 'dict_key' => 115,
512 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
513 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
514 ),
515 '9.1.633' => array
516 (
517 'dict_key' => 169,
518 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
519 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
520 ),
521 '9.1.634' => array
522 (
523 'dict_key' => 170,
524 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
525 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
526 ),
527 '9.1.563' => array
528 (
529 'dict_key' => 171,
530 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
531 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
532 ),
533 '9.1.564' => array
534 (
535 'dict_key' => 172,
536 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
537 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
538 ),
539 '9.1.614' => array
540 (
541 'dict_key' => 175,
542 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
543 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
544 ),
545 '9.1.615' => array
546 (
547 'dict_key' => 173,
548 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
549 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
550 ),
551 '9.1.616' => array
552 (
553 'dict_key' => 176,
554 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
555 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
556 ),
557 '9.1.617' => array
558 (
559 'dict_key' => 174,
560 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
561 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
562 ),
563 '9.1.626' => array
564 (
565 'dict_key' => 147,
566 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
567 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
568 ),
569 '9.1.659' => array
570 (
571 'dict_key' => 377,
572 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
573 'processors' => array ('catalyst-chassis-uplinks-10000X2', 'catalyst-chassis-uplinks-1000T', 'catalyst-chassis-mgmt'),
574 ),
575 '9.1.428' => array
576 (
577 'dict_key' => 389,
578 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
579 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
580 ),
581 '9.1.429' => array
582 (
583 'dict_key' => 390,
584 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
585 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
586 ),
587 '9.1.559' => array
588 (
589 'dict_key' => 387,
590 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
591 'processors' => array ('catalyst-chassis-uplinks-1000T', 'catalyst-chassis-any-100TX'),
592 ),
593 '9.1.560' => array
594 (
595 'dict_key' => 384,
596 'text' => 'WS-C2950SX-48: 48 RJ-45/10-100TX + 2 1000Base-SX',
597 'processors' => array ('catalyst-chassis-uplinks-1000SX', 'catalyst-chassis-any-100TX'),
598 ),
599 '9.1.749' => array
600 (
601 'dict_key' => 989,
602 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
603 'processors' => array ('catalyst-blade-11-to-12-1000T', 'catalyst-blade-13-to-16-1000SFP', 'catalyst-blade-any-bp/1000T'),
604 ),
605 '9.1.920' => array
606 (
607 'dict_key' => 795,
608 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
609 'processors' => array ('catalyst-blade-17-to-20-1000T', 'catalyst-blade-21-to-24-1000SFP', 'catalyst-blade-any-bp/1000T'),
610 ),
611 '9.1.367' => array
612 (
613 'dict_key' => 404,
614 'text' => 'WS-C3550-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
615 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000GBIC'),
616 ),
617 '9.1.368' => array
618 (
619 'dict_key' => 398,
620 'text' => 'WS-C3550-12T: 10 RJ-45/10-100-1000T(X) + 2 GBIC/1000',
621 'processors' => array ('catalyst-1-to-10-1000T', 'catalyst-11-to-12-GBIC'),
622 ),
623 '9.1.282' => array
624 (
625 'dict_key' => 154,
626 'text' => 'WS-C6506: modular device (INCOMPLETE!)',
627 'processors' => array ('catalyst-chassis-any-1000T'),
628 ),
629 '9.1.1104' => array
630 (
631 'dict_key' => 1348,
632 'text' => 'WS-C2350-48TD: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 w/TwinGig option',
633 'processors' => array
634 (
635 'catalyst-chassis-49-to-52-1000SFP', // TwinGig actually
636 'catalyst-chassis-any-1000T',
637 'catalyst-chassis-uplinks-10000X2',
638 'catalyst-chassis-mgmt',
639 ),
640 ),
641 '9.12.3.1.3.719' => array
642 (
643 'dict_key' => 960,
644 'text' => 'N5K-C5020: 40 SFP+/10000',
645 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
646 ),
647 '9.12.3.1.3.798' => array
648 (
649 'dict_key' => 959,
650 'text' => 'N5K-C5010: 20 SFP+/10000',
651 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
652 ),
653 '11.2.3.7.11.32' => array
654 (
655 'dict_key' => 871,
656 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
657 'processors' => array ('procurve-chassis-1000T'),
658 ),
659 '11.2.3.7.11.36' => array
660 (
661 'dict_key' => 865,
662 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
663 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
664 ),
665 '11.2.3.7.11.35' => array
666 (
667 'dict_key' => 867,
668 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
669 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
670 ),
671 '11.2.3.7.11.9' => array
672 (
673 'dict_key' => 1086,
674 'text' => 'J4121A: modular system',
675 'processors' => array ('procurve-modular-100TX'),
676 ),
677 '11.2.3.7.11.87' => array
678 (
679 'dict_key' => 1349,
680 'text' => 'J9147A: 44 RJ-45/10-100-1000T(X) + 4 combo-gig)',
681 'processors' => array ('procurve-45-to-48-combo-1000SFP', 'procurve-chassis-1000T'),
682 ),
683 '4526.100.2.2' => array
684 (
685 'dict_key' => 562,
686 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
687 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
688 ),
689 '45.3.68.5' => array
690 (
691 'dict_key' => 1085,
692 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
693 'processors' => array ('nortel-any-1000T'),
694 ),
695 '2636.1.1.1.2.29' => array
696 (
697 'dict_key' => 925,
698 'text' => 'MX240 modular router',
699 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
700 ),
701 '2011.2.23.96' => array
702 (
703 'dict_key' => 1321,
704 'text' => 'S5328C-EI-24S: 20 SFP-1000 + 4 combo-gig + 2 XFP slots',
705 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
706 ),
707 '2011.2.23.103' => array
708 (
709 'dict_key' => 1341,
710 'text' => 'S5352C-SI: 48 RJ-45/10-100-1000T(X) + optional 2xXFP/4xSFP slots',
711 'processors' => array ('quidway-slot1-SFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
712 ),
713 '2011.2.23.102' => array
714 (
715 'dict_key' => 1339,
716 'text' => 'S5328C-SI: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
717 'processors' => array ('quidway-21-to-24-comboSFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
718 ),
719 '1991.1.3.45.2.1.1.1' => array
720 (
721 'dict_key' => 127,
722 'text' => 'FGS648P: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
723 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
724 ),
725 '1991.1.3.45.2.2.1.1' => array
726 (
727 'dict_key' => 131,
728 'text' => 'FGS648P-POE: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
729 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
730 ),
731 '1916.2.71' => array
732 (
733 'dict_key' => 694,
734 'text' => 'X450a-24t: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + XFP uplinks slot',
735 'processors' => array ('summit-25-to-26-XFP-uplinks', 'summit-21-to-24-comboSFP', 'summit-any-1000T', 'summit-management'),
736 ),
737 );
738
739 function updateStickerForCell ($cell, $attr_id, $new_value)
740 {
741 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
742 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
743 }
744
745 // Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
746 // a record with IIF id = X and OIF id = Y.
747 function checkPIC ($port_type_id)
748 {
749 $matches = array();
750 switch (1)
751 {
752 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
753 $iif_id = $matches[1];
754 $oif_id = $matches[2];
755 break;
756 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
757 $iif_id = 1;
758 $oif_id = $matches[1];
759 break;
760 default:
761 return;
762 }
763 foreach (getPortInterfaceCompat() as $record)
764 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
765 return;
766 commitSupplementPIC ($iif_id, $oif_id);
767 }
768
769 $msgcode['doSNMPmining']['ERR1'] = 161;
770 $msgcode['doSNMPmining']['ERR2'] = 162;
771 $msgcode['doSNMPmining']['OK'] = 81;
772 function doSNMPmining ($object_id, $community)
773 {
774 $objectInfo = spotEntity ('object', $object_id);
775 $objectInfo['attrs'] = getAttrValues ($object_id);
776 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
777 if (count ($endpoints) == 0)
778 return buildRedirectURL (__FUNCTION__, 'ERR1'); // endpoint not found
779 if (count ($endpoints) > 1)
780 return buildRedirectURL (__FUNCTION__, 'ERR2'); // can't pick an address
781
782 switch ($objectInfo['objtype_id'])
783 {
784 case 7:
785 case 8:
786 return doSwitchSNMPmining ($objectInfo, $endpoints[0], $community);
787 case 2:
788 return doPDUSNMPmining ($objectInfo, $endpoints[0], $community);
789 }
790 }
791
792 $msgcode['doSwitchSNMPmining']['ERR3'] = 188;
793 $msgcode['doSwitchSNMPmining']['ERR4'] = 189;
794 function doSwitchSNMPmining ($objectInfo, $hostname, $community)
795 {
796 $log = emptyLog();
797 global $known_switches, $iftable_processors;
798
799 if (FALSE === ($sysObjectID = @snmpget ($hostname, $community, 'sysObjectID.0')))
800 return buildRedirectURL (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
801 $sysObjectID = preg_replace ('/^.*(enterprises\.)([\.[:digit:]]+)$/', '\\2', $sysObjectID);
802 $sysName = substr (@snmpget ($hostname, $community, 'sysName.0'), strlen ('STRING: '));
803 $sysDescr = substr (@snmpget ($hostname, $community, 'sysDescr.0'), strlen ('STRING: '));
804 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
805 if (!isset ($known_switches[$sysObjectID]))
806 return buildRedirectURL (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
807 foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
808 if (!array_key_exists ($known_switches[$sysObjectID]['processors'][$pkey], $iftable_processors))
809 {
810 $log = mergeLogs ($log, oneLiner (200, array ('processor "' . $known_switches[$sysObjectID]['processors'][$pkey] . '" not found')));
811 unset ($known_switches[$sysObjectID]['processors'][$pkey]);
812 }
813 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
814 updateStickerForCell ($objectInfo, 3, $sysName);
815 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
816 switch (1)
817 {
818 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
819 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
820 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
821 $ios_codes = array
822 (
823 '12.0' => 244,
824 '12.1' => 251,
825 '12.2' => 252,
826 );
827 updateStickerForCell ($objectInfo, 5, $exact_release);
828 if (array_key_exists ($major_line, $ios_codes))
829 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
830 $sysChassi = @snmpget ($hostname, $community, '1.3.6.1.4.1.9.3.6.3.0');
831 if ($sysChassi !== FALSE or $sysChassi !== NULL)
832 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
833 checkPIC ('1-29');
834 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
835 // blade devices are powered through internal circuitry of chassis
836 if ($sysObjectID != '9.1.749' and $sysObjectID != '9.1.920')
837 {
838 checkPIC ('1-16'); // AC input
839 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
840 }
841 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
842 break;
843 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
844 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
845 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
846 $nxos_codes = array
847 (
848 '4.0' => 963,
849 '4.1' => 964,
850 );
851 if (array_key_exists ($major_line, $nxos_codes))
852 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
853 updateStickerForCell ($objectInfo, 5, $exact_release);
854 checkPIC ('1-29');
855 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
856 checkPIC ('1-16'); // AC input
857 commitAddPort ($objectInfo['id'], 'AC-in-1', '1-16', 'AC1', '');
858 commitAddPort ($objectInfo['id'], 'AC-in-2', '1-16', 'AC2', '');
859 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
860 break;
861 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
862 $exact_release = preg_replace ('/^.* revision ([^ ]+), .*$/', '\\1', $sysDescr);
863 updateStickerForCell ($objectInfo, 5, $exact_release);
864 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
865 break;
866 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
867 checkPIC ('1-681');
868 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
869 $log = mergeLogs ($log, oneLiner (81, array ('netgear-generic')));
870 break;
871 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
872 checkPIC ('1-681');
873 commitAddPort ($objectInfo['id'], 'con0', '1-681', 'console', ''); // DB-9 RS-232 console
874 $log = mergeLogs ($log, oneLiner (81, array ('huawei-generic')));
875 break;
876 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
877 checkPIC ('1-681');
878 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
879 $log = mergeLogs ($log, oneLiner (81, array ('juniper-generic')));
880 break;
881 case preg_match ('/^1991\.1\.3\.45\./', $sysObjectID): // snFGSFamily
882 $exact_release = preg_replace ('/^.*, IronWare Version ([^ ]+) .*$/', '\\1', $sysDescr);
883 updateStickerForCell ($objectInfo, 5, $exact_release);
884 # FOUNDRY-SN-AGENT-MIB::snChasSerNum.0
885 $sysChassi = @snmpget ($hostname, $community, 'enterprises.1991.1.1.1.1.2.0');
886 if ($sysChassi !== FALSE or $sysChassi !== NULL)
887 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
888
889 # Type of uplink module installed.
890 # table: FOUNDRY-SN-AGENT-MIB::snAgentBrdMainBrdDescription
891 # Possible part numbers are:
892 # FGS-1XG1XGC (one fixed CX4 port)
893 # FGS-2XGC (two fixed CX4 ports)
894 # FGS-2XG (two XFP slots)
895 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.2.2.1.1.2') as $module_raw)
896 if (preg_match ('/^STRING: "(FGS-1XG1XGC|FGS-2XGC) /i', $module_raw))
897 {
898 $iftable_processors['fgs-uplinks']['dict_key'] = '1-40'; // CX4
899 break;
900 }
901
902 # AC inputs
903 # table: FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
904 # "Power supply 1 "
905 # "Power supply 2 "
906 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.1.2.1.1.2') as $PSU_raw)
907 {
908 $count = 0;
909 $PSU_cooked = trim (preg_replace ('/^string: "(.+)"$/i', '\\1', $PSU_raw, 1, $count));
910 if ($count)
911 {
912 checkPIC ('1-16');
913 commitAddPort ($objectInfo['id'], $PSU_cooked, '1-16', '', '');
914 }
915 }
916 # fixed console port
917 checkPIC ('1-681');
918 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
919 $log = mergeLogs ($log, oneLiner (81, array ('brocade-generic')));
920 break;
921 case preg_match ('/^1916\.2\./', $sysObjectID): // Extreme Networks Summit
922 $xos_release = preg_replace ('/^ExtremeXOS version ([[:digit:]]+)\..*$/', '\\1', $sysDescr);
923 $xos_codes = array
924 (
925 '10' => 1350,
926 '11' => 1351,
927 '12' => 1352,
928 );
929 if (array_key_exists ($xos_release, $xos_codes))
930 updateStickerForCell ($objectInfo, 4, $xos_codes[$xos_release]);
931 checkPIC ('1-681');
932 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232
933 checkPIC ('1-16');
934 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
935 $log = mergeLogs ($log, oneLiner (81, array ('summit-generic')));
936 break;
937 default: // Nortel...
938 break;
939 }
940 $ifInfo = array();
941 $tablename = 'ifDescr';
942 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
943 {
944 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
945 $value = trim (preg_replace ('/^.+: (.+)$/', '\\1', $value), '"');
946 $ifInfo[$randomindex][$tablename] = $value;
947 }
948 $tablename = 'ifPhysAddress';
949 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
950 {
951 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
952 $value = trim ($value);
953 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
954 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
955 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
956 if (preg_match ('/^string: [0-9a-f]{1,2}(:[0-9a-f]{1,2}){5}/i', $value)) // STRING: x:yy:z:xx:y:zz
957 {
958 list ($dummy, $value) = explode (' ', $value);
959 $addrbytes = explode (':', $value);
960 foreach ($addrbytes as $bidx => $bytestr)
961 if (strlen ($bytestr) == 1)
962 $addrbytes[$bidx] = '0' . $bytestr;
963 }
964 elseif (preg_match ('/^hex-string:( [0-9a-f]{2}){6}/i', $value)) // Hex-STRING: xx yy zz xx yy zz
965 $addrbytes = explode (' ', substr ($value, -17));
966 elseif (preg_match ('/22[0-9a-f]{12}22$/', bin2hex ($value))) // STRING: "??????"
967 $addrbytes = array (substr (bin2hex ($value), -14, 12));
968 else
969 continue; // martian format
970 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
971 }
972 // process each interface only once regardless of how many processors we have to run
973 foreach ($ifInfo as $iface)
974 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
975 {
976 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
977 if (!$count)
978 continue; // try next processor on current port
979 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
980 checkPIC ($iftable_processors[$processor_name]['dict_key']);
981 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
982 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
983 continue 2;
984 }
985 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
986 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
987 // No failure up to this point, thus leave current tab for the "Ports" one.
988 return buildWideRedirectURL ($log, NULL, 'ports');
989 }
990
991 $msgcode['doPDUSNMPmining']['OK'] = 0;
992 function doPDUSNMPmining ($objectInfo, $hostname, $community)
993 {
994 $log = emptyLog();
995 global $known_APC_SKUs;
996 $switch = new APCPowerSwitch ($hostname, $community);
997 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
998 updateStickerForCell ($objectInfo, 2, $dict_key);
999 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
1000 updateStickerForCell ($objectInfo, 3, $switch->getName());
1001 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
1002 checkPIC ('1-16');
1003 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
1004 $portno = 1;
1005 foreach ($switch->getPorts() as $name => $port)
1006 {
1007 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
1008 checkPIC ('1-1322');
1009 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
1010 $portno++;
1011 }
1012 $log = mergeLogs ($log, oneLiner (0, array ("Added ${portno} port(s)")));
1013 return buildWideRedirectURL ($log, NULL, 'ports');
1014 }
1015
1016 // APC SNMP code by Russ Garrett
1017 define('APC_STATUS_ON', 1);
1018 define('APC_STATUS_OFF', 2);
1019 define('APC_STATUS_REBOOT', 3);
1020
1021 class SNMPDevice {
1022 protected $hostname;
1023 protected $community;
1024
1025 function __construct($hostname, $community) {
1026 $this->hostname = $hostname;
1027 $this->community = $community;
1028 }
1029
1030 function getName() {
1031 return $this->getString('sysName.0');
1032 }
1033
1034 function getDescription() {
1035 return $this->getString('sysDescr.0');
1036 }
1037
1038 protected function snmpSet($oid, $type, $value) {
1039 return snmpset($this->hostname, $this->community, $oid, $type, $value);
1040 }
1041
1042 protected function getString($oid) {
1043 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, $oid)), '"');
1044 }
1045 }
1046
1047 class APCPowerSwitch extends SNMPDevice {
1048 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
1049
1050 function getPorts() {
1051 $data = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2");
1052 $status = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4");
1053 $out = array();
1054 foreach ($data as $id => $d) {
1055 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
1056 }
1057 return $out;
1058 }
1059
1060 function getPortStatus($id) {
1061 return trim(snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
1062 }
1063
1064 function getPortName($id) {
1065 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
1066 }
1067
1068 function setPortName($id, $name) {
1069 return snmpset($this->hostname, $this->community, "{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
1070 }
1071
1072 function portOff($id) {
1073 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
1074 }
1075
1076 function portOn($id) {
1077 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
1078 }
1079
1080 function portReboot($id) {
1081 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
1082 }
1083 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
1084 function getFWRev()
1085 {
1086 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.3.0"));
1087 }
1088 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
1089 function getHWSerial()
1090 {
1091 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.6.0"));
1092 }
1093 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
1094 function getHWModel()
1095 {
1096 return preg_replace ('/^STRING: "(.*)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.5.0"));
1097 }
1098 }
1099
1100 // Take address in the form XX:XX:XX:XX:XX:XX and return the next
1101 // address in the same form.
1102 function nextMACAddress ($addr)
1103 {
1104 if ($addr == '')
1105 return '';
1106 $bytes = array();
1107 foreach (explode (':', $addr) as $hex)
1108 $bytes[] = hexdec ($hex);
1109 for ($i = 5; $i >= 0; $i--)
1110 {
1111 $bytes[$i] += 1;
1112 if ($bytes[$i] <= 255) // FF
1113 break; // no roll over
1114 $bytes[$i] = 0;
1115 }
1116 foreach (array_keys ($bytes) as $key)
1117 $bytes[$key] = sprintf ('%02X', $bytes[$key]);
1118 return implode (':', $bytes);
1119 }
1120
1121 function generatePortsForCatModule ($object_id, $slotno = 1, $mtype = 'X6748', $mac_address = '')
1122 {
1123 global $dbxlink;
1124 $mac_address = l2addressFromDatabase (l2addressForDatabase ($mac_address));
1125 switch ($mtype)
1126 {
1127 case 'WS-X6748-GE-TX':
1128 $dbxlink->beginTransaction();
1129 for ($i = 1; $i <= 48; $i++)
1130 {
1131 if ('' != commitAddPort ($object_id, "gi${slotno}/${i}", '1-24', "slot ${slotno} port ${i}", $mac_address))
1132 {
1133 $dbxlink->rollBack();
1134 break 2;
1135 }
1136 $mac_address = nextMACAddress ($mac_address);
1137 }
1138 $dbxlink->commit();
1139 break;
1140 case 'WS-X6708-10GE':
1141 for ($i = 1; $i <= 8; $i++)
1142 {
1143 commitAddPort ($object_id, "te${slotno}/${i}", '6-1080', "slot ${slotno} port ${i}", $mac_address);
1144 $mac_address = nextMACAddress ($mac_address);
1145 }
1146 break;
1147 case 'VS-S720-10G':
1148 commitAddPort ($object_id, "gi${slotno}/1", '4-1077', "slot ${slotno} port 1", $mac_address);
1149 $mac_address = nextMACAddress ($mac_address);
1150 commitAddPort ($object_id, "gi${slotno}/2", '4-1077', "slot ${slotno} port 2", $mac_address);
1151 $mac_address = nextMACAddress ($mac_address);
1152 commitAddPort ($object_id, "gi${slotno}/3", '1-24', "slot ${slotno} port 3", $mac_address);
1153 $mac_address = nextMACAddress ($mac_address);
1154 commitAddPort ($object_id, "te${slotno}/4", '6-1080', "slot ${slotno} port 4", $mac_address);
1155 $mac_address = nextMACAddress ($mac_address);
1156 commitAddPort ($object_id, "te${slotno}/5", '6-1080', "slot ${slotno} port 5", $mac_address);
1157 break;
1158 case '3750G-24TS':
1159 // MAC address of 1st port is the next one after switch's address
1160 $mac_address = nextMACAddress ($mac_address);
1161 for ($i = 1; $i <= 24; $i++)
1162 {
1163 commitAddPort ($object_id, "gi${slotno}/0/${i}", '1-24', "unit ${slotno} port ${i}", $mac_address);
1164 $mac_address = nextMACAddress ($mac_address);
1165 }
1166 for ($i = 25; $i <= 28; $i++)
1167 {
1168 commitAddPort ($object_id, "gi${slotno}/0/${i}", '4-1077', "unit ${slotno} port ${i}", $mac_address);
1169 $mac_address = nextMACAddress ($mac_address);
1170 }
1171 break;
1172 }
1173 }
1174
1175 ?>