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