r3518 added C6506 closer
[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 ),
a9bd9e98
DO
548 '9.1.282' => array
549 (
550 'dict_key' => 154,
551 'text' => 'WS-C6506: modular device (INCOMPLETE!)',
552 'processors' => array ('catalyst-chassis-any-1000T'),
553 ),
74aee2dc
DO
554 '9.12.3.1.3.719' => array
555 (
556 'dict_key' => 960,
557 'text' => 'N5K-C5020: 40 SFP+/10000',
e7662d90 558 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
74aee2dc 559 ),
bc45a3a4
DO
560 '9.12.3.1.3.798' => array
561 (
562 'dict_key' => 959,
563 'text' => 'N5K-C5010: 20 SFP+/10000',
564 'processors' => array ('nexus-any-10000SFP+', 'nexus-mgmt'),
565 ),
56a797ef
DO
566 '11.2.3.7.11.32' => array
567 (
568 'dict_key' => 871,
569 'text' => 'J4904A: 48 RJ-45/10-100-1000T(X)',
570 'processors' => array ('procurve-chassis-1000T'),
571 ),
74aee2dc
DO
572 '11.2.3.7.11.36' => array
573 (
574 'dict_key' => 865,
575 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef 576 'processors' => array ('procurve-25-to-26-1000T', 'procurve-chassis-100TX'),
74aee2dc
DO
577 ),
578 '11.2.3.7.11.35' => array
579 (
580 'dict_key' => 867,
581 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
56a797ef
DO
582 'processors' => array ('procurve-49-to-50-1000T', 'procurve-chassis-100TX'),
583 ),
584 '11.2.3.7.11.9' => array
585 (
586 'dict_key' => 1086,
587 'text' => 'J4121A: modular system',
588 'processors' => array ('procurve-modular-100TX'),
74aee2dc 589 ),
4b43f713
DO
590 '11.2.3.7.11.87' => array
591 (
592 'dict_key' => 1349,
593 'text' => 'J9147A: 44 RJ-45/10-100-1000T(X) + 4 combo-gig)',
594 'processors' => array ('procurve-45-to-48-combo-1000SFP', 'procurve-chassis-1000T'),
595 ),
74aee2dc
DO
596 '4526.100.2.2' => array
597 (
598 'dict_key' => 562,
6be06cbb
DO
599 'text' => 'GSM7224: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
600 'processors' => array ('netgear-chassis-21-to-24-1000SFP', 'netgear-chassis-21-to-24-1000Tcombo', 'netgear-chassis-any-1000T'),
74aee2dc 601 ),
56a797ef
DO
602 '45.3.68.5' => array
603 (
604 'dict_key' => 1085,
605 'text' => 'BES50GE-12T PWR: 12 RJ-45/10-100-1000T(X)',
606 'processors' => array ('nortel-any-1000T'),
607 ),
91389980
DO
608 '2636.1.1.1.2.29' => array
609 (
610 'dict_key' => 925,
611 'text' => 'MX240 modular router',
612 'processors' => array ('juniper-DPCE-R-4XGE-XFP'),
613 ),
7d69a266
DO
614 '2011.2.23.96' => array
615 (
616 'dict_key' => 1321,
24c3e444 617 'text' => 'S5328C-EI-24S: 20 SFP-1000 + 4 combo-gig + 2 XFP slots',
7d69a266
DO
618 'processors' => array ('quidway-21-to-24-comboT', 'quidway-any-1000SFP', 'quidway-XFP', 'quidway-mgmt'),
619 ),
24c3e444
DO
620 '2011.2.23.102' => array
621 (
622 'dict_key' => 1339,
623 'text' => 'S5328C-SI: 20 RJ-45/10-100-1000T(X) + 4 combo-gig + 2 XFP slots',
624 'processors' => array ('quidway-21-to-24-comboSFP', 'quidway-any-1000T', 'quidway-XFP', 'quidway-mgmt'),
625 ),
661b3fdb
DO
626 '1991.1.3.45.2.1.1.1' => array
627 (
628 'dict_key' => 127,
629 'text' => 'FGS648P: 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 ),
632 '1991.1.3.45.2.2.1.1' => array
633 (
634 'dict_key' => 131,
635 'text' => 'FGS648P-POE: 48 RJ-45/10-100-1000T(X) + 4 combo-gig + uplink slot',
636 'processors' => array ('fgs-1-to-4-comboSFP', 'fgs-any-1000T', 'fgs-uplinks'),
637 ),
74aee2dc
DO
638);
639
74aee2dc
DO
640function updateStickerForCell ($cell, $attr_id, $new_value)
641{
642 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
643 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
644}
645
bdc91a5c
DO
646// Accept "X-Y" on input and make sure, that PortInterfaceCompat contains
647// a record with IIF id = X and OIF id = Y.
648function checkPIC ($port_type_id)
649{
650 $matches = array();
651 switch (1)
652 {
653 case preg_match ('/^([[:digit:]]+)-([[:digit:]]+)$/', $port_type_id, $matches):
654 $iif_id = $matches[1];
655 $oif_id = $matches[2];
656 break;
657 case preg_match ('/^([[:digit:]]+)$/', $port_type_id, $matches):
658 $iif_id = 1;
659 $oif_id = $matches[1];
660 break;
661 default:
662 return;
663 }
664 foreach (getPortInterfaceCompat() as $record)
665 if ($record['iif_id'] == $iif_id and $record['oif_id'] == $oif_id)
666 return;
667 commitSupplementPIC ($iif_id, $oif_id);
668}
669
8536e20a
DO
670$msgcode['doSNMPmining']['ERR1'] = 161;
671$msgcode['doSNMPmining']['ERR2'] = 162;
8536e20a 672$msgcode['doSNMPmining']['OK'] = 81;
56a797ef 673function doSNMPmining ($object_id, $community)
74aee2dc 674{
74aee2dc
DO
675 $objectInfo = spotEntity ('object', $object_id);
676 $objectInfo['attrs'] = getAttrValues ($object_id);
677 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
678 if (count ($endpoints) == 0)
8536e20a 679 return buildRedirectURL (__FUNCTION__, 'ERR1'); // endpoint not found
74aee2dc 680 if (count ($endpoints) > 1)
8536e20a 681 return buildRedirectURL (__FUNCTION__, 'ERR2'); // can't pick an address
4848a7e3
DO
682
683 switch ($objectInfo['objtype_id'])
684 {
24a6e3a2 685 case 7:
4848a7e3
DO
686 case 8:
687 return doSwitchSNMPmining ($objectInfo, $endpoints[0], $community);
688 case 2:
689 return doPDUSNMPmining ($objectInfo, $endpoints[0], $community);
690 }
691}
692
24a6e3a2 693$msgcode['doSwitchSNMPmining']['ERR3'] = 188;
e22f9600 694$msgcode['doSwitchSNMPmining']['ERR4'] = 189;
24a6e3a2 695function doSwitchSNMPmining ($objectInfo, $hostname, $community)
4848a7e3
DO
696{
697 $log = emptyLog();
698 global $known_switches, $iftable_processors;
74aee2dc 699
24a6e3a2 700 if (FALSE === ($sysObjectID = @snmpget ($hostname, $community, 'sysObjectID.0')))
8536e20a 701 return buildRedirectURL (__FUNCTION__, 'ERR3'); // // fatal SNMP failure
84986395 702 $sysObjectID = preg_replace ('/^.*(enterprises\.)([\.[:digit:]]+)$/', '\\2', $sysObjectID);
24a6e3a2
DO
703 $sysName = substr (@snmpget ($hostname, $community, 'sysName.0'), strlen ('STRING: '));
704 $sysDescr = substr (@snmpget ($hostname, $community, 'sysDescr.0'), strlen ('STRING: '));
74aee2dc
DO
705 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
706 if (!isset ($known_switches[$sysObjectID]))
8536e20a 707 return buildRedirectURL (__FUNCTION__, 'ERR4', array ($sysObjectID)); // unknown OID
5e193b67
DO
708 foreach (array_keys ($known_switches[$sysObjectID]['processors']) as $pkey)
709 if (!array_key_exists ($known_switches[$sysObjectID]['processors'][$pkey], $iftable_processors))
710 {
711 $log = mergeLogs ($log, oneLiner (200, array ('processor "' . $known_switches[$sysObjectID]['processors'][$pkey] . '" not found')));
712 unset ($known_switches[$sysObjectID]['processors'][$pkey]);
713 }
56a797ef 714 updateStickerForCell ($objectInfo, 2, $known_switches[$sysObjectID]['dict_key']);
74aee2dc 715 updateStickerForCell ($objectInfo, 3, $sysName);
56a797ef 716 $log = mergeLogs ($log, oneLiner (81, array ('generic')));
74aee2dc
DO
717 switch (1)
718 {
56a797ef 719 case preg_match ('/^9\.1\./', $sysObjectID): // Catalyst
84986395
DO
720 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
721 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
722 $ios_codes = array
723 (
724 '12.0' => 244,
725 '12.1' => 251,
726 '12.2' => 252,
727 );
728 updateStickerForCell ($objectInfo, 5, $exact_release);
6be06cbb
DO
729 if (array_key_exists ($major_line, $ios_codes))
730 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
24a6e3a2 731 $sysChassi = @snmpget ($hostname, $community, '1.3.6.1.4.1.9.3.6.3.0');
74aee2dc
DO
732 if ($sysChassi !== FALSE or $sysChassi !== NULL)
733 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
bdc91a5c
DO
734 checkPIC ('1-29');
735 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
facd0235
DO
736 // blade devices are powered through internal circuitry of chassis
737 if ($sysObjectID != '9.1.749' and $sysObjectID != '9.1.920')
738 {
739 checkPIC ('1-16'); // AC input
740 commitAddPort ($objectInfo['id'], 'AC-in', '1-16', '', '');
741 }
56a797ef 742 $log = mergeLogs ($log, oneLiner (81, array ('catalyst-generic')));
74aee2dc 743 break;
56a797ef 744 case preg_match ('/^9\.12\.3\.1\.3\./', $sysObjectID): // Nexus
84986395
DO
745 $exact_release = preg_replace ('/^.*, Version ([^ ]+), .*$/', '\\1', $sysDescr);
746 $major_line = preg_replace ('/^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*/', '\\1', $exact_release);
74aee2dc
DO
747 $nxos_codes = array
748 (
749 '4.0' => 963,
750 '4.1' => 964,
751 );
6be06cbb
DO
752 if (array_key_exists ($major_line, $nxos_codes))
753 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
74aee2dc 754 updateStickerForCell ($objectInfo, 5, $exact_release);
bdc91a5c 755 checkPIC ('1-29');
24a6e3a2 756 commitAddPort ($objectInfo['id'], 'con0', '1-29', 'console', ''); // RJ-45 RS-232 console
dcfa87d7
DO
757 checkPIC ('1-16'); // AC input
758 commitAddPort ($objectInfo['id'], 'AC-in-1', '1-16', 'AC1', '');
759 commitAddPort ($objectInfo['id'], 'AC-in-2', '1-16', 'AC2', '');
56a797ef 760 $log = mergeLogs ($log, oneLiner (81, array ('nexus-generic')));
74aee2dc 761 break;
56a797ef 762 case preg_match ('/^11\.2\.3\.7\.11\./', $sysObjectID): // ProCurve
84986395 763 $exact_release = preg_replace ('/^.* revision ([^ ]+), .*$/', '\\1', $sysDescr);
74aee2dc 764 updateStickerForCell ($objectInfo, 5, $exact_release);
56a797ef 765 $log = mergeLogs ($log, oneLiner (81, array ('procurve-generic')));
74aee2dc 766 break;
6be06cbb 767 case preg_match ('/^4526\.100\.2\./', $sysObjectID): // NETGEAR
bdc91a5c
DO
768 checkPIC ('1-681');
769 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
6be06cbb
DO
770 $log = mergeLogs ($log, oneLiner (81, array ('netgear-generic')));
771 break;
7d69a266 772 case preg_match ('/^2011\.2\.23\./', $sysObjectID): // Huawei
bdc91a5c
DO
773 checkPIC ('1-681');
774 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266
DO
775 $log = mergeLogs ($log, oneLiner (81, array ('huawei-generic')));
776 break;
777 case preg_match ('/^2636\.1\.1\.1\.2\./', $sysObjectID): // Juniper
bdc91a5c
DO
778 checkPIC ('1-681');
779 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
7d69a266 780 $log = mergeLogs ($log, oneLiner (81, array ('juniper-generic')));
661b3fdb
DO
781 break;
782 case preg_match ('/^1991\.1\.3\.45\./', $sysObjectID): // snFGSFamily
84986395 783 $exact_release = preg_replace ('/^.*, IronWare Version ([^ ]+) .*$/', '\\1', $sysDescr);
661b3fdb
DO
784 updateStickerForCell ($objectInfo, 5, $exact_release);
785 # FOUNDRY-SN-AGENT-MIB::snChasSerNum.0
786 $sysChassi = @snmpget ($hostname, $community, 'enterprises.1991.1.1.1.1.2.0');
787 if ($sysChassi !== FALSE or $sysChassi !== NULL)
788 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
789
790 # Type of uplink module installed.
791 # table: FOUNDRY-SN-AGENT-MIB::snAgentBrdMainBrdDescription
792 # Possible part numbers are:
793 # FGS-1XG1XGC (one fixed CX4 port)
794 # FGS-2XGC (two fixed CX4 ports)
795 # FGS-2XG (two XFP slots)
796 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.2.2.1.1.2') as $module_raw)
797 if (preg_match ('/^STRING: "(FGS-1XG1XGC|FGS-2XGC) /i', $module_raw))
798 {
799 $iftable_processors['fgs-uplinks']['dict_key'] = '1-40'; // CX4
800 break;
801 }
802
803 # AC inputs
804 # table: FOUNDRY-SN-AGENT-MIB::snChasPwrSupplyDescription
805 # "Power supply 1 "
806 # "Power supply 2 "
807 foreach (@snmpwalkoid ($hostname, $community, 'enterprises.1991.1.1.1.2.1.1.2') as $PSU_raw)
808 {
809 $count = 0;
810 $PSU_cooked = trim (preg_replace ('/^string: "(.+)"$/i', '\\1', $PSU_raw, 1, $count));
811 if ($count)
812 {
813 checkPIC ('1-16');
814 commitAddPort ($objectInfo['id'], $PSU_cooked, '1-16', '', '');
815 }
816 }
817 # fixed console port
818 checkPIC ('1-681');
819 commitAddPort ($objectInfo['id'], 'console', '1-681', 'console', ''); // DB-9 RS-232 console
820 $log = mergeLogs ($log, oneLiner (81, array ('brocade-generic')));
821 break;
7d69a266 822 default: // Nortel...
74aee2dc
DO
823 break;
824 }
56a797ef
DO
825 $ifInfo = array();
826 $tablename = 'ifDescr';
24a6e3a2 827 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef 828 {
84986395
DO
829 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
830 $value = trim (preg_replace ('/^.+: (.+)$/', '\\1', $value), '"');
56a797ef
DO
831 $ifInfo[$randomindex][$tablename] = $value;
832 }
833 $tablename = 'ifPhysAddress';
24a6e3a2 834 foreach (snmpwalkoid ($hostname, $community, $tablename) as $oid => $value)
56a797ef 835 {
84986395 836 $randomindex = preg_replace ("/^.*${tablename}\.(.+)\$/", '\\1', $oid);
56a797ef
DO
837 $value = trim ($value);
838 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
839 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
840 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
6a845dce 841 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
842 {
843 list ($dummy, $value) = explode (' ', $value);
844 $addrbytes = explode (':', $value);
845 foreach ($addrbytes as $bidx => $bytestr)
846 if (strlen ($bytestr) == 1)
847 $addrbytes[$bidx] = '0' . $bytestr;
848 }
6a845dce 849 elseif (preg_match ('/^hex-string:( [0-9a-f]{2}){6}/i', $value)) // Hex-STRING: xx yy zz xx yy zz
56a797ef 850 $addrbytes = explode (' ', substr ($value, -17));
6a845dce
DO
851 elseif (preg_match ('/22[0-9a-f]{12}22$/', bin2hex ($value))) // STRING: "??????"
852 $addrbytes = array (substr (bin2hex ($value), -14, 12));
56a797ef
DO
853 else
854 continue; // martian format
855 $ifInfo[$randomindex][$tablename] = implode ('', $addrbytes);
856 }
857 // process each interface only once regardless of how many processors we have to run
858 foreach ($ifInfo as $iface)
859 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
860 {
56a797ef
DO
861 $newname = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['replacement'], $iface['ifDescr'], 1, $count);
862 if (!$count)
863 continue; // try next processor on current port
864 $newlabel = preg_replace ($iftable_processors[$processor_name]['pattern'], $iftable_processors[$processor_name]['label'], $iface['ifDescr'], 1, $count);
bdc91a5c 865 checkPIC ($iftable_processors[$processor_name]['dict_key']);
24a6e3a2 866 commitAddPort ($objectInfo['id'], $newname, $iftable_processors[$processor_name]['dict_key'], $newlabel, $iface['ifPhysAddress']);
56a797ef
DO
867 if (!$iftable_processors[$processor_name]['try_next_proc']) // done with this port
868 continue 2;
869 }
870 foreach ($known_switches[$sysObjectID]['processors'] as $processor_name)
871 $log = mergeLogs ($log, oneLiner (81, array ($processor_name)));
8536e20a
DO
872 // No failure up to this point, thus leave current tab for the "Ports" one.
873 return buildWideRedirectURL ($log, NULL, 'ports');
74aee2dc
DO
874}
875
4848a7e3
DO
876$msgcode['doPDUSNMPmining']['OK'] = 0;
877function doPDUSNMPmining ($objectInfo, $hostname, $community)
38e05b77 878{
29de85b6
DO
879 $log = emptyLog();
880 global $known_APC_SKUs;
4848a7e3 881 $switch = new APCPowerSwitch ($hostname, $community);
29de85b6
DO
882 if (FALSE !== ($dict_key = array_search ($switch->getHWModel(), $known_APC_SKUs)))
883 updateStickerForCell ($objectInfo, 2, $dict_key);
884 updateStickerForCell ($objectInfo, 1, $switch->getHWSerial());
4848a7e3 885 updateStickerForCell ($objectInfo, 3, $switch->getName());
29de85b6 886 updateStickerForCell ($objectInfo, 5, $switch->getFWRev());
bdc91a5c 887 checkPIC ('1-16');
29de85b6 888 commitAddPort ($objectInfo['id'], 'input', '1-16', 'input', '');
4848a7e3
DO
889 $portno = 1;
890 foreach ($switch->getPorts() as $name => $port)
29de85b6
DO
891 {
892 $label = mb_strlen ($port[0]) ? $port[0] : $portno;
bdc91a5c 893 checkPIC ('1-1322');
29de85b6
DO
894 commitAddPort ($objectInfo['id'], $portno, '1-1322', $port[0], '');
895 $portno++;
896 }
912d98f8 897 $log = mergeLogs ($log, oneLiner (0, array ("Added ${portno} port(s)")));
29de85b6 898 return buildWideRedirectURL ($log, NULL, 'ports');
38e05b77
DO
899}
900
4848a7e3 901// APC SNMP code by Russ Garrett
38e05b77
DO
902define('APC_STATUS_ON', 1);
903define('APC_STATUS_OFF', 2);
904define('APC_STATUS_REBOOT', 3);
905
906class SNMPDevice {
907 protected $hostname;
908 protected $community;
909
910 function __construct($hostname, $community) {
911 $this->hostname = $hostname;
912 $this->community = $community;
913 }
914
915 function getName() {
916 return $this->getString('sysName.0');
917 }
918
919 function getDescription() {
920 return $this->getString('sysDescr.0');
921 }
922
923 protected function snmpSet($oid, $type, $value) {
924 return snmpset($this->hostname, $this->community, $oid, $type, $value);
925 }
926
927 protected function getString($oid) {
928 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, $oid)), '"');
929 }
930}
931
932class APCPowerSwitch extends SNMPDevice {
933 protected $snmpMib = 'SNMPv2-SMI::enterprises.318';
934
935 function getPorts() {
936 $data = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2");
937 $status = snmpwalk($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4");
938 $out = array();
939 foreach ($data as $id => $d) {
940 $out[$id + 1] = array(trim(str_replace('STRING: ', '', $d), '"'), str_replace('INTEGER: ', '', $status[$id]));
941 }
942 return $out;
943 }
944
945 function getPortStatus($id) {
946 return trim(snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.4.$id"), 'INTEGER: ');
947 }
948
949 function getPortName($id) {
950 return trim(str_replace('STRING: ', '', snmpget($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.3.3.1.1.2.$id")), '"');
951 }
952
953 function setPortName($id, $name) {
954 return snmpset($this->hostname, $this->community, "{$this->snmpMib}.1.1.4.5.2.1.3.$id", 's', $name);
955 }
956
957 function portOff($id) {
958 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_OFF);
959 }
960
961 function portOn($id) {
962 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_ON);
963 }
964
965 function portReboot($id) {
966 return $this->snmpSet("{$this->snmpMib}.1.1.12.3.3.1.1.4.$id", 'i', APC_STATUS_REBOOT);
967 }
30ad8bc4
DO
968 // rPDUIdentFirmwareRev.0 == .1.3.6.1.4.1.318.1.1.12.1.3.0 = STRING: "vN.N.N"
969 function getFWRev()
970 {
971 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.3.0"));
972 }
973 // rPDUIdentSerialNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.6.0 = STRING: "XXXXXXXXXXX"
974 function getHWSerial()
975 {
976 return preg_replace ('/^STRING: "(.+)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.6.0"));
977 }
978 // rPDUIdentModelNumber.0 == .1.3.6.1.4.1.318.1.1.12.1.5.0 = STRING: "APnnnn"
979 function getHWModel()
980 {
981 return preg_replace ('/^STRING: "(.*)"$/', '\\1', snmpget ($this->hostname, $this->community, "{$this->snmpMib}.1.1.12.1.5.0"));
982 }
38e05b77
DO
983}
984
2ffd5a2a 985?>