r3284 doSwitchSNMPmining(): produce a warning message for each missing processor...
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
74aee2dc 3$iftable_processors = array();
6be06cbb
DO
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
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
6be06cbb 50$iftable_processors['catalyst-chassis-any-1000SFP'] = array
74aee2dc 51(
6be06cbb
DO
52 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
53 'replacement' => 'gi\\1\\2',
8536e20a 54 'dict_key' => '4-1077',
6be06cbb 55 'label' => '\\2',
56a797ef
DO
56 'try_next_proc' => FALSE,
57);
58
6be06cbb 59$iftable_processors['catalyst-chassis-any-1000GBIC'] = array
56a797ef 60(
6be06cbb
DO
61 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
62 'replacement' => 'gi\\1\\2',
8536e20a 63 'dict_key' => '3-1078',
6be06cbb 64 'label' => '\\2',
56a797ef
DO
65 'try_next_proc' => FALSE,
66);
67
7e87a291
DO
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
6be06cbb 77$iftable_processors['catalyst-chassis-21-to-24-combo-1000SFP'] = array
56a797ef 78(
6be06cbb
DO
79 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
80 'replacement' => 'gi\\1\\2',
8536e20a 81 'dict_key' => '4-1077',
6be06cbb 82 'label' => '\\2',
56a797ef
DO
83 'try_next_proc' => TRUE,
84);
85
6be06cbb 86$iftable_processors['catalyst-chassis-45-to-48-combo-1000SFP'] = array
56a797ef 87(
6be06cbb
DO
88 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(45|46|47|48)$@',
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-uplinks-10000X2'] = array
56a797ef 96(
6be06cbb
DO
97 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/)?([[:digit:]]+)$@',
98 'replacement' => 'te\\1\\2',
8536e20a 99 'dict_key' => '6-1080',
6be06cbb 100 'label' => '\\2',
56a797ef 101 'try_next_proc' => FALSE,
74aee2dc
DO
102);
103
6be06cbb 104$iftable_processors['catalyst-chassis-25-to-28-1000SFP'] = array
74aee2dc 105(
6be06cbb
DO
106 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(25|26|27|28)$@',
107 'replacement' => 'gi\\1\\2',
8536e20a 108 'dict_key' => '4-1077',
6be06cbb 109 'label' => '\\2',
56a797ef 110 'try_next_proc' => FALSE,
74aee2dc
DO
111);
112
6be06cbb 113$iftable_processors['catalyst-chassis-49-to-52-1000SFP'] = array
74aee2dc 114(
6be06cbb
DO
115 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(49|50|51|52)$@',
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
71d6b313 122$iftable_processors['catalyst-blade-13-to-16-1000SFP'] = array
74aee2dc 123(
6be06cbb
DO
124 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(13|14|15|16)$@',
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-21-to-24-1000SFP'] = array
74aee2dc 132(
6be06cbb
DO
133 'pattern' => '@^GigabitEthernet([[:digit:]]+/)?(21|22|23|24)$@',
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
DO
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
7e87a291
DO
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
74aee2dc
DO
185$iftable_processors['nexus-any-10000SFP+'] = array
186(
56a797ef 187 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
74aee2dc 188 'replacement' => 'e\\1',
8536e20a 189 'dict_key' => '9-1084',
56a797ef
DO
190 'label' => '\\1',
191 'try_next_proc' => FALSE,
74aee2dc
DO
192);
193
e7662d90
DO
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
56a797ef 203$iftable_processors['procurve-chassis-100TX'] = array
74aee2dc 204(
56a797ef 205 'pattern' => '@^([[:digit:]]+)$@',
74aee2dc
DO
206 'replacement' => '\\1',
207 'dict_key' => 19,
56a797ef
DO
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,
74aee2dc
DO
228);
229
230$iftable_processors['procurve-25-to-26-1000T'] = array
231(
56a797ef 232 'pattern' => '@^(25|26)$@',
74aee2dc
DO
233 'replacement' => '\\1',
234 'dict_key' => 24,
56a797ef
DO
235 'label' => '\\1',
236 'try_next_proc' => FALSE,
74aee2dc
DO
237);
238
239$iftable_processors['procurve-49-to-50-1000T'] = array
240(
56a797ef 241 'pattern' => '@^(49|50)$@',
74aee2dc
DO
242 'replacement' => '\\1',
243 'dict_key' => 24,
56a797ef
DO
244 'label' => '\\1',
245 'try_next_proc' => FALSE,
74aee2dc
DO
246);
247
6be06cbb 248$iftable_processors['netgear-chassis-any-1000T'] = array
74aee2dc 249(
56a797ef
DO
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
6be06cbb
DO
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',
8536e20a 270 'dict_key' => '4-1077',
6be06cbb
DO
271 'label' => '\\1F',
272 'try_next_proc' => TRUE,
273);
274
56a797ef
DO
275$iftable_processors['nortel-any-1000T'] = array
276(
277 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
74aee2dc
DO
278 'replacement' => '\\1',
279 'dict_key' => 24,
56a797ef
DO
280 'label' => '\\1',
281 'try_next_proc' => FALSE,
74aee2dc
DO
282);
283
91389980
DO
284$iftable_processors['juniper-DPCE-R-4XGE-XFP'] = array
285(
7d69a266
DO
286 'pattern' => '@^xe-([[:digit:]]+)/([[:digit:]]+/[[:digit:]]+)$@',
287 'replacement' => '\\0',
91389980 288 'dict_key' => '8-1082', // XFP/empty
7d69a266
DO
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-any-1000SFP'] = array
303(
304 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
305 'replacement' => 'gi\\1\\2',
306 'dict_key' => '4-1077', // empty SFP-1000
307 'label' => '\\2',
308 'try_next_proc' => FALSE,
309);
310
311$iftable_processors['quidway-XFP'] = array
312(
313 'pattern' => '@^XGigabitEthernet([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
314 'replacement' => 'xg\\1\\2',
315 'dict_key' => '8-1082',
316 'label' => '\\2',
317 'try_next_proc' => FALSE,
318);
319
320$iftable_processors['quidway-mgmt'] = array
321(
322 'pattern' => '@^MEth([[:digit:]]+/[[:digit:]]+/)([[:digit:]]+)$@',
323 'replacement' => 'me\\1\\2',
324 'dict_key' => '1-19',
325 'label' => 'eth',
91389980
DO
326 'try_next_proc' => FALSE,
327);
328
74aee2dc
DO
329$known_switches = array // key is system OID w/o "enterprises" prefix
330(
331 '9.1.324' => array
332 (
333 'dict_key' => 380,
334 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
6be06cbb 335 'processors' => array ('catalyst-chassis-any-100TX'),
74aee2dc
DO
336 ),
337 '9.1.325' => array
338 (
339 'dict_key' => 382,
340 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
6be06cbb 341 'processors' => array ('catalyst-chassis-25-to-26-100FX/MT-RJ', 'catalyst-chassis-any-100TX'),
74aee2dc 342 ),
7e87a291
DO
343 '9.1.695' => array
344 (
345 'dict_key' => 140,
346 'text' => 'WS-C2960-48TC-L: 48 RJ-45/10-100TX + 2 combo-gig',
347 'processors' => array ('catalyst-chassis-1-to-2-combo-1000SFP', 'catalyst-chassis-any-1000T', 'catalyst-chassis-any-100TX'),
348 ),
74aee2dc
DO
349 '9.1.696' => array
350 (
351 'dict_key' => 167,
352 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 353 'processors' => array ('catalyst-chassis-21-to-24-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
354 ),
355 '9.1.697' => array
356 (
357 'dict_key' => 166,
358 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
6be06cbb 359 'processors' => array ('catalyst-chassis-45-to-48-combo-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
360 ),
361 '9.1.716' => array
362 (
363 'dict_key' => 164,
364 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 365 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
366 ),
367 '9.1.717' => array
368 (
369 'dict_key' => 162,
370 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 371 'processors' => array ('catalyst-chassis-any-100TX', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
372 ),
373 '9.1.527' => array
374 (
375 'dict_key' => 210,
376 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
6be06cbb 377 'processors' => array ('catalyst-chassis-any-1000T'),
74aee2dc
DO
378 ),
379 '9.1.561' => array
380 (
381 'dict_key' => 115,
382 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 383 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
384 ),
385 '9.1.633' => array
386 (
387 'dict_key' => 169,
388 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 389 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
390 ),
391 '9.1.634' => array
392 (
393 'dict_key' => 170,
394 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 395 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
396 ),
397 '9.1.563' => array
398 (
399 'dict_key' => 171,
400 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
6be06cbb 401 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
402 ),
403 '9.1.564' => array
404 (
405 'dict_key' => 172,
406 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
6be06cbb 407 'processors' => array ('catalyst-chassis-any-1000SFP', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
408 ),
409 '9.1.614' => array
410 (
411 'dict_key' => 175,
412 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 413 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
414 ),
415 '9.1.615' => array
416 (
417 'dict_key' => 173,
418 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 419 'processors' => array ('catalyst-chassis-25-to-28-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
420 ),
421 '9.1.616' => array
422 (
423 'dict_key' => 176,
424 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 425 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
426 ),
427 '9.1.617' => array
428 (
429 'dict_key' => 174,
430 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
6be06cbb 431 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-any-1000T'),
74aee2dc
DO
432 ),
433 '9.1.626' => array
434 (
435 'dict_key' => 147,
56a797ef 436 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
6be06cbb 437 'processors' => array ('catalyst-chassis-49-to-52-1000SFP', 'catalyst-chassis-uplinks-1000T', 'catalyst-4948-mgmt'),
74aee2dc
DO
438 ),
439 '9.1.659' => array
440 (
441 'dict_key' => 377,
56a797ef 442 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
6be06cbb 443 'processors' => array ('catalyst-chassis-uplinks-10000X2', 'catalyst-chassis-uplinks-1000T', 'catalyst-4948-mgmt'),
74aee2dc
DO
444 ),
445 '9.1.428' => array
446 (
447 'dict_key' => 389,
448 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 449 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
450 ),
451 '9.1.429' => array
452 (
453 'dict_key' => 390,
454 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
6be06cbb 455 'processors' => array ('catalyst-chassis-any-1000GBIC', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
456 ),
457 '9.1.559' => array
458 (
459 'dict_key' => 387,
460 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
6be06cbb 461 'processors' => array ('catalyst-chassis-uplinks-1000T', 'catalyst-chassis-any-100TX'),
74aee2dc
DO
462 ),
463 '9.1.749' => array
464 (
465 'dict_key' => 989,
466 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 467 'processors' => array ('catalyst-blade-11-to-12-1000T', 'catalyst-blade-13-to-16-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc
DO
468 ),
469 '9.1.920' => array
470 (
471 'dict_key' => 795,
472 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
71d6b313 473 'processors' => array ('catalyst-blade-17-to-20-1000T', 'catalyst-blade-21-to-24-1000SFP', 'catalyst-blade-any-bp/1000T'),
74aee2dc 474 ),
7e87a291
DO
475 '9.1.368' => array
476 (
477 'dict_key' => 398,
478 'text' => 'WS-C3550-12T: 10 RJ-45/10-100-1000T(X) + 2 GBIC/1000',
479 'processors' => array ('catalyst-1-to-10-1000T', 'catalyst-11-to-12-GBIC'),
480 ),
74aee2dc
DO
481 '9.12.3.1.3.719' => array
482 (
483 'dict_key' => 960,
484 'text' => 'N5K-C5020: 40 SFP+/10000',
e7662d90 485 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
74aee2dc 486 ),
56a797ef
DO
487 '11.2.3.7.11.32' => array
488 (
489 'dict_key' => 871,
490 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
491 'processors' => array ('procurve-chassis-1000T'),
492 ),
74aee2dc
DO
493 '11.2.3.7.11.36' => array
494 (
495 'dict_key' => 865,
496 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 497 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
498 ),
499 '11.2.3.7.11.35' => array
500 (
501 'dict_key' => 867,
502 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
503 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
504 ),
505 '11.2.3.7.11.9' => array
506 (
507 'dict_key' => 1086,
508 'text' => 'J4121A: modular system',
509 'processors' => array ('procurve-modular-100TX'),
74aee2dc
DO
510 ),
511 '4526.100.2.2' => array
512 (
513 'dict_key' => 562,
6be06cbb
DO
514 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
515 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
74aee2dc 516 ),
56a797ef
DO
517 '45.3.68.5' => array
518 (
519 'dict_key' => 1085,
520 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
521 'processors' => array ('nortel-any-1000T'),
522 ),
91389980
DO
523 '2636.1.1.1.2.29' => array
524 (
525 'dict_key' => 925,
526 'text' => 'MX240 modular router',
527 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
528 ),
7d69a266
DO
529 '2011.2.23.96' => array
530 (
531 'dict_key' => 1321,
532 'text' => 'S5328C-EI-24S: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
533 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
534 ),
74aee2dc
DO
535);
536
74aee2dc
DO
537function updateStickerForCell ($cell, $attr_id, $new_value)
538{
539 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
540 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
541}
542
bdc91a5c
DO
543// Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
544// a record with IIF id = X and OIF id = Y.
545function checkPIC ($port_type_id)
546{
547 $matches = array();
548 switch (1)
549 {
550 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
551 $iif_id = $matches[1];
552 $oif_id = $matches[2];
553 break;
554 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
555 $iif_id = 1;
556 $oif_id = $matches[1];
557 break;
558 default:
559 return;
560 }
561 foreach (getPortInterfaceCompat() as $record)
562 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
563 return;
564 commitSupplementPIC ($iif_id, $oif_id);
565}
566
8536e20a
DO
567$msgcode['doSNMPmining']['ERR1'] = 161;
568$msgcode['doSNMPmining']['ERR2'] = 162;
8536e20a 569$msgcode['doSNMPmining']['OK'] = 81;
56a797ef 570function doSNMPmining ($object_id, $community)
74aee2dc 571{
74aee2dc
DO
572 $objectInfo = spotEntity ('object', $object_id);
573 $objectInfo['attrs'] = getAttrValues ($object_id);
574 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
575 if (count ($endpoints) == 0)
8536e20a 576 return buildRedirectURL (__FUNCTION__, 'ERR1'); // endpoint not found
74aee2dc 577 if (count ($endpoints) > 1)
8536e20a 578 return buildRedirectURL (__FUNCTION__, 'ERR2'); // can't pick an address
4848a7e3
DO
579
580 switch ($objectInfo['objtype_id'])
581 {
24a6e3a2 582 case 7:
4848a7e3
DO
583 case 8:
584 return doSwitchSNMPmining ($objectInfo, $endpoints[0], $community);
585 case 2:
586 return doPDUSNMPmining ($objectInfo, $endpoints[0], $community);
587 }
588}
589
24a6e3a2 590$msgcode['doSwitchSNMPmining']['ERR3'] = 188;
e22f9600 591$msgcode['doSwitchSNMPmining']['ERR4'] = 189;
24a6e3a2 592function doSwitchSNMPmining ($objectInfo, $hostname, $community)
4848a7e3
DO
593{
594 $log = emptyLog();
595 global $known_switches, $iftable_processors;
74aee2dc 596
24a6e3a2 597 if (FALSE === ($sysObjectID = @snmpget ($hostname, $community, 'sysObjectID.0')))
8536e20a 598 return buildRedirectURL (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
74aee2dc 599 $sysObjectID = ereg_replace ('^.*(enterprises\.)([\.[:digit:]]+)$', '\\2', $sysObjectID);
24a6e3a2
DO
600 $sysName = substr (@snmpget ($hostname, $community, 'sysName.0'), strlen ('STRING: '));
601 $sysDescr = substr (@snmpget ($hostname, $community, 'sysDescr.0'), strlen ('STRING: '));
74aee2dc
DO
602 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
603 if (!isset ($known_switches[$sysObjectID]))
8536e20a 604 return buildRedirectURL (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
5e193b67
DO
605 foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
606 if (!array_key_exists ($known_switches[$sysObjectID]['processors'][$pkey], $iftable_processors))
607 {
608 $log = mergeLogs ($log, oneLiner (200, array ('processor "' . $known_switches[$sysObjectID]['processors'][$pkey] . '" not found')));
609 unset ($known_switches[$sysObjectID]['processors'][$pkey]);
610 }
56a797ef 611 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 612 updateStickerForCell ($objectInfo, 3, $sysName);
56a797ef 613 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
74aee2dc
DO
614 switch (1)
615 {
56a797ef 616 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
74aee2dc
DO
617 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
618 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
619 $ios_codes = array
620 (
621 '12.0' => 244,
622 '12.1' => 251,
623 '12.2' => 252,
624 );
625 updateStickerForCell ($objectInfo, 5, $exact_release);
6be06cbb
DO
626 if (array_key_exists ($major_line, $ios_codes))
627 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
24a6e3a2 628 $sysChassi = @snmpget ($hostname, $community, '1.3.6.1.4.1.9.3.6.3.0');
74aee2dc
DO
629 if ($sysChassi !== FALSE or $sysChassi !== NULL)
630 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
bdc91a5c
DO
631 checkPIC ('1-29');
632 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
633 checkPIC ('1-16');
24a6e3a2 634 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', ''); // AC input
56a797ef 635 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
74aee2dc 636 break;
56a797ef 637 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
74aee2dc
DO
638 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
639 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
640 $nxos_codes = array
641 (
642 '4.0' => 963,
643 '4.1' => 964,
644 );
6be06cbb
DO
645 if (array_key_exists ($major_line, $nxos_codes))
646 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
74aee2dc 647 updateStickerForCell ($objectInfo, 5, $exact_release);
bdc91a5c 648 checkPIC ('1-29');
24a6e3a2 649 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
56a797ef 650 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
74aee2dc 651 break;
56a797ef 652 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
74aee2dc
DO
653 $exact_release = ereg_replace ('^.* revision ([^ ]+), .*$', '\\1', $sysDescr);
654 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 655 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
74aee2dc 656 break;
6be06cbb 657 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
bdc91a5c
DO
658 checkPIC ('1-681');
659 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
6be06cbb
DO
660 $log = mergeLogs ($log, oneLiner (81, array ('netgear-generic')));
661 break;
7d69a266 662 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
bdc91a5c
DO
663 checkPIC ('1-681');
664 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
665 $log = mergeLogs ($log, oneLiner (81, array ('huawei-generic')));
666 break;
667 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
bdc91a5c
DO
668 checkPIC ('1-681');
669 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
670 $log = mergeLogs ($log, oneLiner (81, array ('juniper-generic')));
671 default: // Nortel...
74aee2dc
DO
672 break;
673 }
56a797ef
DO
674 $ifInfo = array();
675 $tablename = 'ifDescr';
24a6e3a2 676 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef
DO
677 {
678 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
679 $value = trim (ereg_replace ('^.+: (.+)$', '\\1', $value), '"');
680 $ifInfo[$randomindex][$tablename] = $value;
681 }
682 $tablename = 'ifPhysAddress';
24a6e3a2 683 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef
DO
684 {
685 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
686 $value = trim ($value);
687 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
688 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
689 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
690 if (preg_match ('/^string: /i', $value)) // STRING: x:yy:z:xx:y:zz
691 {
692 list ($dummy, $value) = explode (' ', $value);
693 $addrbytes = explode (':', $value);
694 foreach ($addrbytes as $bidx => $bytestr)
695 if (strlen ($bytestr) == 1)
696 $addrbytes[$bidx] = '0' . $bytestr;
697 }
698 elseif (preg_match ('/^hex-string: /i', $value)) // Hex-STRING: xx yy zz xx yy zz
699 $addrbytes = explode (' ', substr ($value, -17));
700 else
701 continue; // martian format
702 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
703 }
704 // process each interface only once regardless of how many processors we have to run
705 foreach ($ifInfo as $iface)
706 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
707 {
56a797ef
DO
708 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
709 if (!$count)
710 continue; // try next processor on current port
711 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
bdc91a5c 712 checkPIC ($iftable_processors[$processor_name]['dict_key']);
24a6e3a2 713 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
56a797ef
DO
714 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
715 continue 2;
716 }
717 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
718 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
8536e20a
DO
719 // No failure up to this point, thus leave current tab for the "Ports" one.
720 return buildWideRedirectURL ($log, NULL, 'ports');
74aee2dc
DO
721}
722
4848a7e3
DO
723$msgcode['doPDUSNMPmining']['OK'] = 0;
724function doPDUSNMPmining ($objectInfo, $hostname, $community)
38e05b77 725{
29de85b6
DO
726 $log = emptyLog();
727 global $known_APC_SKUs;
4848a7e3 728 $switch = new APCPowerSwitch ($hostname, $community);
29de85b6
DO
729 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
730 updateStickerForCell ($objectInfo, 2, $dict_key);
731 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
4848a7e3 732 updateStickerForCell ($objectInfo, 3, $switch->getName());
29de85b6 733 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
bdc91a5c 734 checkPIC ('1-16');
29de85b6 735 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
4848a7e3
DO
736 $portno = 1;
737 foreach ($switch->getPorts() as $name => $port)
29de85b6
DO
738 {
739 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
bdc91a5c 740 checkPIC ('1-1322');
29de85b6
DO
741 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
742 $portno++;
743 }
912d98f8 744 $log = mergeLogs ($log, oneLiner (0, array ("Added ${portno} port(s)")));
29de85b6 745 return buildWideRedirectURL ($log, NULL, 'ports');
38e05b77
DO
746}
747
4848a7e3 748// APC SNMP code by Russ Garrett
38e05b77
DO
749define('APC_STATUS_ON', 1);
750define('APC_STATUS_OFF', 2);
751define('APC_STATUS_REBOOT', 3);
752
753class SNMPDevice {
754 protected $hostname;
755 protected $community;
756
757 function __construct($hostname, $community) {
758 $this->hostname = $hostname;
759 $this->community = $community;
760 }
761
762 function getName() {
763 return $this->getString('sysName.0');
764 }
765
766 function getDescription() {
767 return $this->getString('sysDescr.0');
768 }
769
770 protected function snmpSet($oid, $type, $value) {
771 return snmpset($this->hostname, $this->community, $oid, $type, $value);
772 }
773
774 protected function getString($oid) {
775 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, $oid)), '"');
776 }
777}
778
779class APCPowerSwitch extends SNMPDevice {
780 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
781
782 function getPorts() {
783 $data = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2");
784 $status = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4");
785 $out = array();
786 foreach ($data as $id => $d) {
787 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
788 }
789 return $out;
790 }
791
792 function getPortStatus($id) {
793 return trim(snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
794 }
795
796 function getPortName($id) {
797 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
798 }
799
800 function setPortName($id, $name) {
801 return snmpset($this->hostname, $this->community, "{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
802 }
803
804 function portOff($id) {
805 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
806 }
807
808 function portOn($id) {
809 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
810 }
811
812 function portReboot($id) {
813 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
814 }
30ad8bc4
DO
815 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
816 function getFWRev()
817 {
818 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.3.0"));
819 }
820 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
821 function getHWSerial()
822 {
823 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.6.0"));
824 }
825 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
826 function getHWModel()
827 {
828 return preg_replace ('/^STRING: "(.*)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.5.0"));
829 }
38e05b77
DO
830}
831
2ffd5a2a 832?>