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