r2993 - renderIPv4SpaceEditor(): dismiss "update name" form for each network due...
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
74aee2dc
DO
3$iftable_processors = array();
4$iftable_processors['catalyst-any-100TX'] = array
5(
56a797ef 6 'pattern' => '@^FastEthernet(([[:digit:]]+/)?[[:digit:]]+)$@',
74aee2dc
DO
7 'replacement' => 'fa\\1',
8 'dict_key' => 19,
56a797ef
DO
9 'label' => '\\1X',
10 'try_next_proc' => FALSE,
11);
12
13$iftable_processors['catalyst-25-to-26-100FX/MT-RJ'] = array
14(
15 'pattern' => '@^FastEthernet([[:digit:]]+/(25|26))$@',
16 'replacement' => 'fa\\1',
17 'dict_key' => 1083,
18 'label' => '\\1',
19 'try_next_proc' => FALSE,
74aee2dc
DO
20);
21
22$iftable_processors['catalyst-any-1000T'] = array
23(
56a797ef 24 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+)$@',
74aee2dc
DO
25 'replacement' => 'gi\\1',
26 'dict_key' => 24,
56a797ef
DO
27 'label' => '\\1X',
28 'try_next_proc' => FALSE,
29);
30
31$iftable_processors['catalyst-any-bp/1000T'] = array
32(
33 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+)$@',
34 'replacement' => 'gi\\1',
35 'dict_key' => 1087,
36 'label' => '',
37 'try_next_proc' => FALSE,
74aee2dc
DO
38);
39
40$iftable_processors['catalyst-any-1000SFP'] = array
41(
56a797ef
DO
42 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+)$@',
43 'replacement' => 'gi\\1',
44 'dict_key' => 1077,
45 'label' => '\\1',
46 'try_next_proc' => FALSE,
47);
48
49$iftable_processors['catalyst-any-1000GBIC'] = array
50(
51 'pattern' => '@^GigabitEthernet([[:digit:]]+/[[:digit:]]+)$@',
74aee2dc 52 'replacement' => 'gi\\1',
56a797ef
DO
53 'dict_key' => 1078,
54 'label' => '\\1',
55 'try_next_proc' => FALSE,
56);
57
58$iftable_processors['catalyst-21-to-24-combo-1000SFP'] = array
59(
60 'pattern' => '@^GigabitEthernet([[:digit:]]+/(21|22|23|24))$@',
61 'replacement' => 'gi\\1',
62 'dict_key' => 1077,
63 'label' => '\\1',
64 'try_next_proc' => TRUE,
65);
66
67$iftable_processors['catalyst-45-to-48-combo-1000SFP'] = array
68(
69 'pattern' => '@^GigabitEthernet([[:digit:]]+/(45|46|47|48))$@',
70 'replacement' => 'gi\\1',
71 'dict_key' => 1077,
72 'label' => '\\1',
73 'try_next_proc' => TRUE,
74);
75
76$iftable_processors['catalyst-any-10000X2'] = array
77(
78 'pattern' => '@^TenGigabitEthernet([[:digit:]]+/[[:digit:]]+)$@',
79 'replacement' => 'te\\1',
80 'dict_key' => 1080,
81 'label' => '\\1',
82 'try_next_proc' => FALSE,
74aee2dc
DO
83);
84
85$iftable_processors['catalyst-25-to-28-1000SFP'] = array
86(
56a797ef 87 'pattern' => '@^GigabitEthernet(0/(25|26|27|28))$@',
74aee2dc 88 'replacement' => 'gi\\1',
56a797ef
DO
89 'dict_key' => 1077,
90 'label' => '\\1',
91 'try_next_proc' => FALSE,
74aee2dc
DO
92);
93
94$iftable_processors['catalyst-49-to-52-1000SFP'] = array
95(
56a797ef 96 'pattern' => '@^GigabitEthernet(0/(49|50|51|52))$@',
74aee2dc 97 'replacement' => 'gi\\1',
56a797ef
DO
98 'dict_key' => 1077,
99 'label' => '\\1',
100 'try_next_proc' => FALSE,
74aee2dc
DO
101);
102
103$iftable_processors['catalyst-13-to-16-1000SFP'] = array
104(
56a797ef 105 'pattern' => '@^GigabitEthernet(0/(13|14|15|16))$@',
74aee2dc 106 'replacement' => 'gi\\1',
56a797ef
DO
107 'dict_key' => 1077,
108 'label' => '\\1',
109 'try_next_proc' => FALSE,
74aee2dc
DO
110);
111
112$iftable_processors['catalyst-21-to-24-1000SFP'] = array
113(
56a797ef 114 'pattern' => '@^GigabitEthernet(0/(21|22|23|24))$@',
74aee2dc 115 'replacement' => 'gi\\1',
56a797ef
DO
116 'dict_key' => 1077,
117 'label' => '\\1',
118 'try_next_proc' => FALSE,
74aee2dc
DO
119);
120
121$iftable_processors['nexus-any-10000SFP+'] = array
122(
56a797ef 123 'pattern' => '@^Ethernet([[:digit:]]/[[:digit:]]+)$@',
74aee2dc 124 'replacement' => 'e\\1',
56a797ef
DO
125 'dict_key' => 1084,
126 'label' => '\\1',
127 'try_next_proc' => FALSE,
74aee2dc
DO
128);
129
56a797ef 130$iftable_processors['procurve-chassis-100TX'] = array
74aee2dc 131(
56a797ef 132 'pattern' => '@^([[:digit:]]+)$@',
74aee2dc
DO
133 'replacement' => '\\1',
134 'dict_key' => 19,
56a797ef
DO
135 'label' => '\\1',
136 'try_next_proc' => FALSE,
137);
138
139$iftable_processors['procurve-chassis-1000T'] = array
140(
141 'pattern' => '@^([[:digit:]]+)$@',
142 'replacement' => '\\1',
143 'dict_key' => 24,
144 'label' => '\\1',
145 'try_next_proc' => FALSE,
146);
147
148$iftable_processors['procurve-modular-100TX'] = array
149(
150 'pattern' => '@^([A-Z][[:digit:]]+)$@',
151 'replacement' => '\\1',
152 'dict_key' => 19,
153 'label' => '\\1',
154 'try_next_proc' => FALSE,
74aee2dc
DO
155);
156
157$iftable_processors['procurve-25-to-26-1000T'] = array
158(
56a797ef 159 'pattern' => '@^(25|26)$@',
74aee2dc
DO
160 'replacement' => '\\1',
161 'dict_key' => 24,
56a797ef
DO
162 'label' => '\\1',
163 'try_next_proc' => FALSE,
74aee2dc
DO
164);
165
166$iftable_processors['procurve-49-to-50-1000T'] = array
167(
56a797ef 168 'pattern' => '@^(49|50)$@',
74aee2dc
DO
169 'replacement' => '\\1',
170 'dict_key' => 24,
56a797ef
DO
171 'label' => '\\1',
172 'try_next_proc' => FALSE,
74aee2dc
DO
173);
174
175$iftable_processors['netgear-any-1000T'] = array
176(
56a797ef
DO
177 'pattern' => '@^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$@',
178 'replacement' => '\\1',
179 'dict_key' => 24,
180 'label' => '\\1',
181 'try_next_proc' => FALSE,
182);
183
184$iftable_processors['nortel-any-1000T'] = array
185(
186 'pattern' => '@^Ethernet Port on unit 1, port ([[:digit:]]+)$@',
74aee2dc
DO
187 'replacement' => '\\1',
188 'dict_key' => 24,
56a797ef
DO
189 'label' => '\\1',
190 'try_next_proc' => FALSE,
74aee2dc
DO
191);
192
193$known_switches = array // key is system OID w/o "enterprises" prefix
194(
195 '9.1.324' => array
196 (
197 'dict_key' => 380,
198 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
199 'processors' => array ('catalyst-any-100TX'),
200 ),
201 '9.1.325' => array
202 (
203 'dict_key' => 382,
204 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
56a797ef 205 'processors' => array ('catalyst-25-to-26-100FX/MT-RJ', 'catalyst-any-100TX'),
74aee2dc
DO
206 ),
207 '9.1.696' => array
208 (
209 'dict_key' => 167,
210 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
56a797ef 211 'processors' => array ('catalyst-21-to-24-combo-1000SFP', 'catalyst-any-1000T'),
74aee2dc
DO
212 ),
213 '9.1.697' => array
214 (
215 'dict_key' => 166,
216 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
56a797ef 217 'processors' => array ('catalyst-45-to-48-combo-1000SFP', 'catalyst-any-1000T'),
74aee2dc
DO
218 ),
219 '9.1.716' => array
220 (
221 'dict_key' => 164,
222 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
223 'processors' => array ('catalyst-any-100TX', 'catalyst-any-1000T'),
224 ),
225 '9.1.717' => array
226 (
227 'dict_key' => 162,
228 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
229 'processors' => array ('catalyst-any-100TX', 'catalyst-any-1000T'),
230 ),
231 '9.1.527' => array
232 (
233 'dict_key' => 210,
234 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
235 'processors' => array ('catalyst-any-1000T'),
236 ),
237 '9.1.561' => array
238 (
239 'dict_key' => 115,
240 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
241 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
242 ),
243 '9.1.633' => array
244 (
245 'dict_key' => 169,
246 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
247 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
248 ),
249 '9.1.634' => array
250 (
251 'dict_key' => 170,
252 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
253 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
254 ),
255 '9.1.563' => array
256 (
257 'dict_key' => 171,
258 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
259 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
260 ),
261 '9.1.564' => array
262 (
263 'dict_key' => 172,
264 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
265 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
266 ),
267 '9.1.516' => array
268 (
269 'dict_key' => 179,
270 'text' => 'WS-C3750-xxPS: 24 or 48 RJ-45/10-100TX + 4 SFP/1000',
271 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
272 ),
273 '9.1.614' => array
274 (
275 'dict_key' => 175,
276 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
277 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
278 ),
279 '9.1.615' => array
280 (
281 'dict_key' => 173,
282 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
283 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
284 ),
285 '9.1.616' => array
286 (
287 'dict_key' => 176,
288 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
289 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T'),
290 ),
291 '9.1.617' => array
292 (
293 'dict_key' => 174,
294 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
295 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T'),
296 ),
297 '9.1.624' => array
298 (
299 'dict_key' => 143,
300 'text' => 'WS-C3750G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
301 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
302 ),
303 '9.1.626' => array
304 (
305 'dict_key' => 147,
56a797ef
DO
306 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000 + 1 RJ-45/100TX (OOB mgmt)',
307 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T', 'catalyst-any-100TX'),
74aee2dc
DO
308 ),
309 '9.1.659' => array
310 (
311 'dict_key' => 377,
56a797ef
DO
312 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000 + 1 RJ-45/100TX (OOB mgmt)',
313 'processors' => array ('catalyst-any-10000X2', 'catalyst-any-1000T', 'catalyst-any-100TX'),
74aee2dc
DO
314 ),
315 '9.1.428' => array
316 (
317 'dict_key' => 389,
318 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
319 'processors' => array ('catalyst-any-1000GBIC', 'catalyst-any-100TX'),
320 ),
321 '9.1.429' => array
322 (
323 'dict_key' => 390,
324 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
325 'processors' => array ('catalyst-any-1000GBIC', 'catalyst-any-100TX'),
326 ),
327 '9.1.559' => array
328 (
329 'dict_key' => 387,
330 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
331 'processors' => array ('catalyst-any-1000T', 'catalyst-any-100TX'),
332 ),
333 '9.1.749' => array
334 (
335 'dict_key' => 989,
336 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
56a797ef 337 'processors' => array ('catalyst-11-to-12-1000T', 'catalyst-13-to-16-1000SFP', 'catalyst-any-bp/1000T'),
74aee2dc
DO
338 ),
339 '9.1.920' => array
340 (
341 'dict_key' => 795,
342 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
56a797ef 343 'processors' => array ('catalyst-17-to-20-1000T', 'catalyst-21-to-24-1000SFP', 'catalyst-any-bp/1000T'),
74aee2dc
DO
344 ),
345 '9.12.3.1.3.719' => array
346 (
347 'dict_key' => 960,
348 'text' => 'N5K-C5020: 40 SFP+/10000',
349 'processors' => array ('nexus-any-10000SFP+'),
350 ),
56a797ef
DO
351 '11.2.3.7.11.32' => array
352 (
353 'dict_key' => 871,
354 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
355 'processors' => array ('procurve-chassis-1000T'),
356 ),
74aee2dc
DO
357 '11.2.3.7.11.36' => array
358 (
359 'dict_key' => 865,
360 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 361 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
362 ),
363 '11.2.3.7.11.35' => array
364 (
365 'dict_key' => 867,
366 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
367 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
368 ),
369 '11.2.3.7.11.9' => array
370 (
371 'dict_key' => 1086,
372 'text' => 'J4121A: modular system',
373 'processors' => array ('procurve-modular-100TX'),
74aee2dc
DO
374 ),
375 '4526.100.2.2' => array
376 (
377 'dict_key' => 562,
378 'text' => 'GSM7224: 24 RJ-45/10-100-1000T(X)',
379 'processors' => array ('netgear-any-1000T'),
380 ),
56a797ef
DO
381 '45.3.68.5' => array
382 (
383 'dict_key' => 1085,
384 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
385 'processors' => array ('nortel-any-1000T'),
386 ),
74aee2dc
DO
387);
388
56a797ef
DO
389// This function is only kept here for reference, it will be removed after we
390// make sure, that the new code performs everything correctly.
391function doSNMPmining_old ($object_id, $community)
2ffd5a2a 392{
74aee2dc 393 return; // overhaul in progress
7056988c 394 // FIXME: switch to message log version 2
2ffd5a2a
DO
395 $log = array();
396// IDs: http://cisco.com/en/US/products/sw/cscowork/ps2064/products_device_support_table09186a0080803bb4.html
397// 2950: http://www.cisco.com/en/US/products/hw/switches/ps628/prod_models_home.html
398// 2960: http://www.cisco.com/en/US/products/ps6406/prod_models_comparison.html
399// 2970: http://cisco.com/en/US/products/hw/switches/ps5206/products_qanda_item09186a00801b1750.shtml
b1101095 400// 3030: http://www.cisco.com/en/US/products/ps6764/index.html
2ffd5a2a
DO
401// 3500XL: http://cisco.com/en/US/products/hw/switches/ps637/products_eol_models.html
402// 3560: http://cisco.com/en/US/products/hw/switches/ps5528/products_data_sheet09186a00801f3d7f.html
403// 3750: http://cisco.com/en/US/products/hw/switches/ps5023/products_data_sheet09186a008016136f.html
404
389e01ee 405 // Cisco sysObjectID to model (not product number, i.e. image code is missing) decoder
74aee2dc
DO
406 $verb_model = array
407 (
408 '9.1.278' => 'WS-C3548-XL (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
409 '9.1.283' => 'WS-C6509-E (9-slot system)',
410 '9.1.324' => 'WS-C2950-24 (24 Ethernet 10/100 ports)',
411 '9.1.325' => 'WS-C2950C-24 (24 Ethernet 10/100 ports and 2 100FX uplinks)',
412# '9.1.694' => 'WS-C2960-24TC-L (24 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
413# '9.1.695' => 'WS-C2960-48TC-L (48 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
414 '9.1.696' => 'WS-C2960G-24TC-L (20 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
415 '9.1.697' => 'WS-C2960G-48TC-L (44 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
416 '9.1.716' => 'WS-C2960-24TT-L (24 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
417 '9.1.717' => 'WS-C2960-48TT-L (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
418 '9.1.527' => 'WS-C2970G-24T (24 Ethernet 10/100/1000 ports)',
419 '9.1.561' => 'WS-C2970G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
420 '9.1.633' => 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)',
421 '9.1.634' => 'WS-C3560-48TS (48 Ethernet 10/100 ports and 4 10/100/1000 SFP uplinks)',
422 '9.1.563' => 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)',
423 '9.1.564' => 'WS-C3560-48PS (48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
424 '9.1.516' => 'WS-C3750-XXPS (24 or 48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
425 '9.1.614' => 'WS-C3560G-24PS (24 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
426 '9.1.615' => 'WS-C3560G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
427 '9.1.616' => 'WS-C3560G-48PS (48 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
428 '9.1.617' => 'WS-C3560G-48TS (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
429 '9.1.624' => 'WS-C3750G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
430 '9.1.58' => 'WS-C4503 (3-slot system)',
431 '9.1.503' => '4503 (3-slot system)',
432 '9.1.59' => 'WS-C4506 (6-slot system)',
433 '9.1.502' => '4506 (6-slot system)',
434 '9.1.626' => 'WS-C4948 (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
435 '9.1.659' => 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)',
436 '9.1.428' => 'WS-C2950G-24 (24 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
437 '9.1.429' => 'WS-C2950G-48 (48 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
438 '9.1.559' => 'WS-C2950T-48 (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
439 '9.1.749' => 'WS-CBS3030-DEL (12 Ethernet 10/100/1000 and 4 10/100/1000 SFP uplinks)',
440 '9.1.920' => 'WS-CBS3032-DEL-F (16 Ethernet 10/100/1000 and up to 8 10/100/1000 uplinks)',
441 '9.12.3.1.3.719' => 'N5K-C5020 (40-ports system)',
442 '11.2.3.7.11.36' => 'HP J8164A (24 Ethernet 10/100 ports and 2 100/1000 uplinks)',
443 '11.2.3.7.11.35' => 'HP J8165A (48 Ethernet 10/100 ports and 2 100/1000 uplinks)',
444 '4526.100.2.2' => 'NETGEAR GSM7224 (24 Ethernet 10/100/1000 ports)',
2ffd5a2a 445 );
389e01ee 446 // Cisco sysObjectID to Dictionary dict_key map
2ffd5a2a
DO
447 $hwtype = array
448 (
74aee2dc
DO
449 '9.1.278' => 395,
450 '9.1.283' => 148,
451 '9.1.324' => 380,
452 '9.1.325' => 382,
453 '9.1.696' => 167,
454 '9.1.697' => 166,
455 '9.1.527' => 210,
456 '9.1.561' => 115,
457 '9.1.633' => 169,
458 '9.1.634' => 170,
459 '9.1.563' => 171,
460 '9.1.564' => 172,
461 '9.1.614' => 175,
462 '9.1.615' => 173,
463 '9.1.616' => 176,
464 '9.1.617' => 174,
465 '9.1.624' => 143,
466 '9.1.58' => 145,
467 '9.1.503' => 145,
468 '9.1.59' => 156,
469 '9.1.502' => 156,
470 '9.1.626' => 147,
471 '9.1.659' => 377,
472 '9.1.428' => 389,
473 '9.1.429' => 390,
474 '9.1.559' => 387,
475 '9.1.516' => 179,
476 '9.1.716' => 164,
477 '9.1.717' => 162,
478 '9.1.920' => 795,
479 '9.12.3.1.3.719' => 960,
480 '9.1.749' => 989,
481 '11.2.3.7.11.36' => 865,
482 '11.2.3.7.11.35' => 867,
483 '4526.100.2.2' => 562,
b3f866fc
AD
484 );
485 // Cisco portType to Dictionary dict_key map
486 $porttype = array
487 (
488 18 => 19, // 10/100BaseT => RJ-45/100Base-T
489 28 => 25, // 1000BaseSX => SC/1000Base-SX
490 31 => 440, // No Transceiver => unknown
491 61 => 24, // 10/100/1000BaseT => RJ-45/1000Base-T
2ffd5a2a
DO
492 );
493
2ffd5a2a
DO
494 switch ($sysObjectID)
495 {
74aee2dc 496 case '9.1.516': // WS-C3750G-24TS OR WS-C3750-48PS
b3f866fc
AD
497 // FIXME: only handles 2 models of 3750, make it handle all of them
498 // see if it has 24 or 48 ports
499 $numports = substr (snmpget ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.3.1.1.14.1'), strlen('INTEGER: '));
500
501 if ($numports == 28) // has 24 ports (+4 SFP) meaning it's a WS-C3750G-24TS
069c186f 502 {
b3f866fc
AD
503 for ($i = 1; $i <= 28; $i++)
504 {
505 $label = "${i}";
506 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
507 if ($error == '')
508 $newports++;
509 else
510 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
511 }
069c186f 512 }
b3f866fc 513 elseif ($numports == 52) // has 48 ports (+4 SFP) meaning it's a WS-C3750-48PS
069c186f 514 {
b3f866fc
AD
515 for ($i = 1; $i <= 48; $i++)
516 {
517 $label = "${i}X";
518 $error = commitAddPort ($object_id, 'fa1/0/' . $i, 19, $label, $ifList2["FastEthernet1/0/${i}"]['phyad']);
519 if ($error == '')
520 $newports++;
521 else
522 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
523 }
524 for ($i = 1; $i <= 4; $i++)
525 {
526 $label = "${i}";
527 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
528 if ($error == '')
529 $newports++;
530 else
531 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
532 }
069c186f
DO
533 }
534 break;
b3f866fc
AD
535 // For modular devices we issue a separate SNMP query to determine port type,
536 // then extract blade & port numbers from the results.
74aee2dc
DO
537 case '9.1.58': // WS-C4503
538 case '9.1.503': // WS-C4503
539 case '9.1.59': // WS-C4506
540 case '9.1.502': // WS-C4506
541 case '9.1.283': // WS-C6509-E
b3f866fc
AD
542 // get slot #, port # and port type using Cisco's MIB
543 $portType = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.5');
544 $ifList = array();
545 $i = 0;
546 foreach ($portType as $key => $val)
2ffd5a2a 547 {
b3f866fc
AD
548 // slot = $portIndex[8]
549 // port = $portIndex[9]
550 $portIndex = explode('.', $key);
551 $ifList[$i]['slotno'] = $portIndex[8];
552 $ifList[$i]['portno'] = $portIndex[9];
553
554 // note the Cisco port type and corresponding RackTables port type
555 list ($dummy, $cptype) = explode (' ', $val);
556 $ifList[$i]['cptype'] = $cptype;
557 if (array_key_exists($cptype, $porttype))
558 $ifList[$i]['ptype'] = $porttype[$cptype];
559 else
560 $ifList[$i]['ptype'] = null;
561 $i++;
562 }
563
564 // use Cisco's ifIndex attribute to map Cisco table to standard SNMP table
565 $ifIndex = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.11');
566 $i = 0;
567 foreach ($ifIndex as $val)
568 {
569 if (is_null($ifList[$i]['ptype']))
2ffd5a2a 570 {
b3f866fc
AD
571 $log[] = array ('code' => 'error', 'message' => 'Unknown port type: ' . $ifList[$i]['cptype']);
572 } else {
573 switch ($ifList[$i]['ptype'])
574 {
575 case 19: // fast eth
576 $prefix = 'fa';
577 break;
578 case 28: // 1000base-sx
579 case 61: // gig eth
580 $prefix = 'gi';
581 break;
582 default: // unknown, default to gig eth
583 $prefix = 'gi';
584 }
585 $pname = "{$prefix}{$ifList[$i]['slotno']}/{$ifList[$i]['portno']}";
586 $label = "slot {$ifList[$i]['slotno']} port {$ifList[$i]['portno']}";
587 list($dummy, $index) = explode(' ', $val);
588
589 // if l2address already exists in DB, nullify value so new row gets added without error
590 if (!is_null(searchByl2address($ifList1[$index]['phyad']))) $ifList1[$index]['phyad'] = null;
591
592 $error = commitAddPort ($object_id, $pname, $ifList[$i]['ptype'], $label, $ifList1[$index]['phyad']);
593 if ($error == '')
594 $newports++;
595 else
596 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $pname . ': ' . $error);
2ffd5a2a 597 }
b3f866fc
AD
598 $i++;
599 }
600 break;
2ffd5a2a 601 default:
4466c276 602 $log[] = array ('code' => 'error', 'message' => "Unexpected sysObjectID '${sysObjectID}'");
2ffd5a2a
DO
603 }
604 $error = commitAddPort ($object_id, 'con0', 29, 'console', '');
2ffd5a2a
DO
605}
606
74aee2dc
DO
607function updateStickerForCell ($cell, $attr_id, $new_value)
608{
609 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
610 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
611}
612
56a797ef 613function doSNMPmining ($object_id, $community)
74aee2dc
DO
614{
615 $log = emptyLog();
616 global $known_switches, $iftable_processors;
617
618 $objectInfo = spotEntity ('object', $object_id);
619 $objectInfo['attrs'] = getAttrValues ($object_id);
620 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
621 if (count ($endpoints) == 0)
622 return oneLiner (161); // endpoint not found
623 if (count ($endpoints) > 1)
624 return oneLiner (162); // can't pick an address
625
626 if (FALSE === ($sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0')))
627 return oneLiner (188); // fatal SNMP failure
628 $sysObjectID = ereg_replace ('^.*(enterprises\.)([\.[:digit:]]+)$', '\\2', $sysObjectID);
56a797ef 629 $sysName = substr (snmpget ($endpoints[0], $community, 'sysName.0'), strlen ('STRING: '));
74aee2dc
DO
630 $sysDescr = substr (snmpget ($endpoints[0], $community, 'sysDescr.0'), strlen ('STRING: '));
631 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
632 if (!isset ($known_switches[$sysObjectID]))
633 return oneLiner (189, array ($sysObjectID)); // unknown OID
56a797ef 634 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 635 updateStickerForCell ($objectInfo, 3, $sysName);
56a797ef 636 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
74aee2dc
DO
637 switch (1)
638 {
56a797ef 639 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
74aee2dc
DO
640 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
641 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
642 $ios_codes = array
643 (
644 '12.0' => 244,
645 '12.1' => 251,
646 '12.2' => 252,
647 );
648 updateStickerForCell ($objectInfo, 5, $exact_release);
649 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
650 $sysChassi = snmpget ($endpoints[0], $community, '1.3.6.1.4.1.9.3.6.3.0');
651 if ($sysChassi !== FALSE or $sysChassi !== NULL)
652 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
56a797ef 653 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
74aee2dc 654 break;
56a797ef 655 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
74aee2dc
DO
656 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
657 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
658 $nxos_codes = array
659 (
660 '4.0' => 963,
661 '4.1' => 964,
662 );
663 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
664 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 665 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
74aee2dc 666 break;
56a797ef 667 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
74aee2dc
DO
668 $exact_release = ereg_replace ('^.* revision ([^ ]+), .*$', '\\1', $sysDescr);
669 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 670 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
74aee2dc 671 break;
56a797ef 672 default: // Nortel, NETGEAR...
74aee2dc
DO
673 break;
674 }
56a797ef
DO
675 $ifInfo = array();
676 $tablename = 'ifDescr';
677 foreach (snmpwalkoid ($endpoints[0], $community, $tablename) as $oid => $value)
678 {
679 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
680 $value = trim (ereg_replace ('^.+: (.+)$', '\\1', $value), '"');
681 $ifInfo[$randomindex][$tablename] = $value;
682 }
683 $tablename = 'ifPhysAddress';
684 foreach (snmpwalkoid ($endpoints[0], $community, $tablename) as $oid => $value)
685 {
686 $randomindex = ereg_replace ("^.*${tablename}\.(.+)\$", '\\1', $oid);
687 $value = trim ($value);
688 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
689 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
690 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
691 if (preg_match ('/^string: /i', $value)) // STRING: x:yy:z:xx:y:zz
692 {
693 list ($dummy, $value) = explode (' ', $value);
694 $addrbytes = explode (':', $value);
695 foreach ($addrbytes as $bidx => $bytestr)
696 if (strlen ($bytestr) == 1)
697 $addrbytes[$bidx] = '0' . $bytestr;
698 }
699 elseif (preg_match ('/^hex-string: /i', $value)) // Hex-STRING: xx yy zz xx yy zz
700 $addrbytes = explode (' ', substr ($value, -17));
701 else
702 continue; // martian format
703 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
704 }
705 // process each interface only once regardless of how many processors we have to run
706 foreach ($ifInfo as $iface)
707 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
708 {
709// echo "subject == '" . $iface['ifDescr'] . "'<br>";
710// echo "pattern == '" . $iftable_processors[$processor_name]['pattern'] . "', replacement == '" . $iftable_processors[$processor_name]['replacement'] . "'<br>";
711 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
712 if (!$count)
713 continue; // try next processor on current port
714 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
715 commitAddPort ($object_id, $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
716 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
717 continue 2;
718 }
719 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
720 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
721 return $log;
74aee2dc
DO
722}
723
2ffd5a2a 724?>