r2968 - maintenance->trunk sync of changesets 2918, 2922, 2924~2927
[racktables] / inc / snmp.php
CommitLineData
2ffd5a2a
DO
1<?php
2
74aee2dc
DO
3$iftable_processors = array();
4$iftable_processors['catalyst-any-100TX'] = array
5(
6 'pattern' => '^FastEthernet(0/[[:digit:]]+)$',
7 'replacement' => 'fa\\1',
8 'dict_key' => 19,
9);
10
11$iftable_processors['catalyst-any-1000T'] = array
12(
13 'pattern' => '^GigabitEthernet(0/[[:digit:]]+)$',
14 'replacement' => 'gi\\1',
15 'dict_key' => 24,
16);
17
18$iftable_processors['catalyst-any-1000SFP'] = array
19(
20 'pattern' => '^GigabitEthernet(0/[[:digit:]]+)$',
21 'replacement' => 'gi\\1',
22 'dict_key' => 440,
23);
24
25$iftable_processors['catalyst-25-to-28-1000SFP'] = array
26(
27 'pattern' => '^GigabitEthernet(0/(25|26|27|28))$',
28 'replacement' => 'gi\\1',
29 'dict_key' => 440,
30);
31
32$iftable_processors['catalyst-49-to-52-1000SFP'] = array
33(
34 'pattern' => '^GigabitEthernet(0/(49|50|51|52))$',
35 'replacement' => 'gi\\1',
36 'dict_key' => 440,
37);
38
39$iftable_processors['catalyst-13-to-16-1000SFP'] = array
40(
41 'pattern' => '^GigabitEthernet(0/(13|14|15|16))$',
42 'replacement' => 'gi\\1',
43 'dict_key' => 440,
44);
45
46$iftable_processors['catalyst-21-to-24-1000SFP'] = array
47(
48 'pattern' => '^GigabitEthernet(0/(21|22|23|24))$',
49 'replacement' => 'gi\\1',
50 'dict_key' => 440,
51);
52
53$iftable_processors['nexus-any-10000SFP+'] = array
54(
55 'pattern' => '^Ethernet([[:digit:]]/[[:digit:]]+)$',
56 'replacement' => 'e\\1',
57 'dict_key' => 440,
58);
59
60$iftable_processors['procurve-any-100TX'] = array
61(
62 'pattern' => '^([[:digit:]]+)$',
63 'replacement' => '\\1',
64 'dict_key' => 19,
65);
66
67$iftable_processors['procurve-25-to-26-1000T'] = array
68(
69 'pattern' => '^(25|26)$',
70 'replacement' => '\\1',
71 'dict_key' => 24,
72);
73
74$iftable_processors['procurve-49-to-50-1000T'] = array
75(
76 'pattern' => '^(49|50)$',
77 'replacement' => '\\1',
78 'dict_key' => 24,
79);
80
81$iftable_processors['netgear-any-1000T'] = array
82(
83 'pattern' => '^Unit: 1 Slot: 0 Port: ([[:digit:]]+) Gigabit - Level$',
84 'replacement' => '\\1',
85 'dict_key' => 24,
86);
87
88$known_switches = array // key is system OID w/o "enterprises" prefix
89(
90 '9.1.324' => array
91 (
92 'dict_key' => 380,
93 'text' => 'WS-C2950-24: 24 RJ-45/10-100TX',
94 'processors' => array ('catalyst-any-100TX'),
95 ),
96 '9.1.325' => array
97 (
98 'dict_key' => 382,
99 'text' => 'WS-C2950C-24: 24 RJ-45/10-100TX + 2 MT-RJ/100FX fiber',
100 'processors' => array ('catalyst-25-to-26-100FX/MT-RJ', 'catalyst-any-Nx100TX'),
101 ),
102 '9.1.696' => array
103 (
104 'dict_key' => 167,
105 'text' => 'WS-C2960G-24TC-L: 20 RJ-45/10-100-1000T(X) + 4 combo-gig',
106 'processors' => array ('catalyst-any-1000T'),
107 ),
108 '9.1.697' => array
109 (
110 'dict_key' => 166,
111 'text' => 'WS-C2960G-48TC-L: 44 RJ-45/10-100-1000T(X) + 4 combo-gig',
112 'processors' => array ('catalyst-any-1000T'),
113 ),
114 '9.1.716' => array
115 (
116 'dict_key' => 164,
117 'text' => 'WS-C2960-24TT-L: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
118 'processors' => array ('catalyst-any-100TX', 'catalyst-any-1000T'),
119 ),
120 '9.1.717' => array
121 (
122 'dict_key' => 162,
123 'text' => 'WS-C2960-48TT-L: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
124 'processors' => array ('catalyst-any-100TX', 'catalyst-any-1000T'),
125 ),
126 '9.1.527' => array
127 (
128 'dict_key' => 210,
129 'text' => 'WS-C2970G-24T: 24 RJ-45/10-100-1000T(X)',
130 'processors' => array ('catalyst-any-1000T'),
131 ),
132 '9.1.561' => array
133 (
134 'dict_key' => 115,
135 'text' => 'WS-C2970G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
136 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
137 ),
138 '9.1.633' => array
139 (
140 'dict_key' => 169,
141 'text' => 'WS-C3560-24TS: 24 RJ-45/10-100TX + 2 SFP/1000',
142 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
143 ),
144 '9.1.634' => array
145 (
146 'dict_key' => 170,
147 'text' => 'WS-C3560-48TS: 48 RJ-45/10-100TX + 4 SFP/1000',
148 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
149 ),
150 '9.1.563' => array
151 (
152 'dict_key' => 171,
153 'text' => 'WS-C3560-24PS: 24 RJ-45/10-100TX + 2 SFP/1000',
154 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
155 ),
156 '9.1.564' => array
157 (
158 'dict_key' => 172,
159 'text' => 'WS-C3560-48PS: 48 RJ-45/10-100TX + 4 SFP/1000',
160 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
161 ),
162 '9.1.516' => array
163 (
164 'dict_key' => 179,
165 'text' => 'WS-C3750-xxPS: 24 or 48 RJ-45/10-100TX + 4 SFP/1000',
166 'processors' => array ('catalyst-any-1000SFP', 'catalyst-any-100TX'),
167 ),
168 '9.1.614' => array
169 (
170 'dict_key' => 175,
171 'text' => 'WS-C3560G-24PS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
172 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
173 ),
174 '9.1.615' => array
175 (
176 'dict_key' => 173,
177 'text' => 'WS-C3560G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
178 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
179 ),
180 '9.1.616' => array
181 (
182 'dict_key' => 176,
183 'text' => 'WS-C3560G-48PS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
184 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T'),
185 ),
186 '9.1.617' => array
187 (
188 'dict_key' => 174,
189 'text' => 'WS-C3560G-48TS: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
190 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T'),
191 ),
192 '9.1.624' => array
193 (
194 'dict_key' => 143,
195 'text' => 'WS-C3750G-24TS: 24 RJ-45/10-100-1000T(X) + 4 SFP/1000',
196 'processors' => array ('catalyst-25-to-28-1000SFP', 'catalyst-any-1000T'),
197 ),
198 '9.1.626' => array
199 (
200 'dict_key' => 147,
201 'text' => 'WS-C4948: 48 RJ-45/10-100-1000T(X) + 4 SFP/1000',
202 'processors' => array ('catalyst-49-to-52-1000SFP', 'catalyst-any-1000T'),
203 ),
204 '9.1.659' => array
205 (
206 'dict_key' => 377,
207 'text' => 'WS-C4948-10GE: 48 RJ-45/10-100-1000T(X) + 2 X2/10000',
208 'processors' => array ('catalyst-any-10000X2', 'catalyst-any-1000T'),
209 ),
210 '9.1.428' => array
211 (
212 'dict_key' => 389,
213 'text' => 'WS-C2950G-24: 24 RJ-45/10-100TX + 2 GBIC/1000',
214 'processors' => array ('catalyst-any-1000GBIC', 'catalyst-any-100TX'),
215 ),
216 '9.1.429' => array
217 (
218 'dict_key' => 390,
219 'text' => 'WS-C2950G-48: 48 RJ-45/10-100TX + 2 GBIC/1000',
220 'processors' => array ('catalyst-any-1000GBIC', 'catalyst-any-100TX'),
221 ),
222 '9.1.559' => array
223 (
224 'dict_key' => 387,
225 'text' => 'WS-C2950T-48: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
226 'processors' => array ('catalyst-any-1000T', 'catalyst-any-100TX'),
227 ),
228 '9.1.749' => array
229 (
230 'dict_key' => 989,
231 'text' => 'WS-CBS3030-DEL: 10 internal/10-100-1000T(X) + 2 RJ-45/10-100-1000T(X) + 4 SFP/1000',
232 'processors' => array ('catalyst-11-to-12-1000T', 'catalyst-13-to-16-1000SFP', 'catalyst-any-1000Tbp'),
233 ),
234 '9.1.920' => array
235 (
236 'dict_key' => 795,
237 'text' => 'WS-CBS3032-DEL: 16 internal/10-100-1000T(X) + 4 RJ-45/10-100-1000T(X) + 4 SFP/1000',
238 'processors' => array ('catalyst-17-to-20-1000T', 'catalyst-21-to-24-1000SFP', 'catalyst-any-1000Tbp'),
239 ),
240 '9.12.3.1.3.719' => array
241 (
242 'dict_key' => 960,
243 'text' => 'N5K-C5020: 40 SFP+/10000',
244 'processors' => array ('nexus-any-10000SFP+'),
245 ),
246 '11.2.3.7.11.36' => array
247 (
248 'dict_key' => 865,
249 'text' => 'J8164A: 24 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
250 'processors' => array ('procurve-25-to-26-1000T', 'procurve-any-100TX'),
251 ),
252 '11.2.3.7.11.35' => array
253 (
254 'dict_key' => 867,
255 'text' => 'J8165A: 48 RJ-45/10-100TX + 2 RJ-45/10-100-1000T(X)',
256 'processors' => array ('procurve-49-to-50-1000T', 'procurve-any-100TX'),
257 ),
258 '4526.100.2.2' => array
259 (
260 'dict_key' => 562,
261 'text' => 'GSM7224: 24 RJ-45/10-100-1000T(X)',
262 'processors' => array ('netgear-any-1000T'),
263 ),
264);
265
2ffd5a2a
DO
266function doSNMPmining ($object_id, $community)
267{
74aee2dc 268 return; // overhaul in progress
7056988c 269 // FIXME: switch to message log version 2
2ffd5a2a
DO
270 $log = array();
271// IDs: http://cisco.com/en/US/products/sw/cscowork/ps2064/products_device_support_table09186a0080803bb4.html
272// 2950: http://www.cisco.com/en/US/products/hw/switches/ps628/prod_models_home.html
273// 2960: http://www.cisco.com/en/US/products/ps6406/prod_models_comparison.html
274// 2970: http://cisco.com/en/US/products/hw/switches/ps5206/products_qanda_item09186a00801b1750.shtml
b1101095 275// 3030: http://www.cisco.com/en/US/products/ps6764/index.html
2ffd5a2a
DO
276// 3500XL: http://cisco.com/en/US/products/hw/switches/ps637/products_eol_models.html
277// 3560: http://cisco.com/en/US/products/hw/switches/ps5528/products_data_sheet09186a00801f3d7f.html
278// 3750: http://cisco.com/en/US/products/hw/switches/ps5023/products_data_sheet09186a008016136f.html
279
389e01ee 280 // Cisco sysObjectID to model (not product number, i.e. image code is missing) decoder
74aee2dc
DO
281 $verb_model = array
282 (
283 '9.1.278' => 'WS-C3548-XL (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
284 '9.1.283' => 'WS-C6509-E (9-slot system)',
285 '9.1.324' => 'WS-C2950-24 (24 Ethernet 10/100 ports)',
286 '9.1.325' => 'WS-C2950C-24 (24 Ethernet 10/100 ports and 2 100FX uplinks)',
287# '9.1.694' => 'WS-C2960-24TC-L (24 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
288# '9.1.695' => 'WS-C2960-48TC-L (48 Ethernet 10/100 ports and 2 dual-purpose uplinks)',
289 '9.1.696' => 'WS-C2960G-24TC-L (20 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
290 '9.1.697' => 'WS-C2960G-48TC-L (44 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)',
291 '9.1.716' => 'WS-C2960-24TT-L (24 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
292 '9.1.717' => 'WS-C2960-48TT-L (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
293 '9.1.527' => 'WS-C2970G-24T (24 Ethernet 10/100/1000 ports)',
294 '9.1.561' => 'WS-C2970G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
295 '9.1.633' => 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)',
296 '9.1.634' => 'WS-C3560-48TS (48 Ethernet 10/100 ports and 4 10/100/1000 SFP uplinks)',
297 '9.1.563' => 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)',
298 '9.1.564' => 'WS-C3560-48PS (48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
299 '9.1.516' => 'WS-C3750-XXPS (24 or 48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)',
300 '9.1.614' => 'WS-C3560G-24PS (24 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
301 '9.1.615' => 'WS-C3560G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
302 '9.1.616' => 'WS-C3560G-48PS (48 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)',
303 '9.1.617' => 'WS-C3560G-48TS (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
304 '9.1.624' => 'WS-C3750G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
305 '9.1.58' => 'WS-C4503 (3-slot system)',
306 '9.1.503' => '4503 (3-slot system)',
307 '9.1.59' => 'WS-C4506 (6-slot system)',
308 '9.1.502' => '4506 (6-slot system)',
309 '9.1.626' => 'WS-C4948 (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)',
310 '9.1.659' => 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)',
311 '9.1.428' => 'WS-C2950G-24 (24 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
312 '9.1.429' => 'WS-C2950G-48 (48 Ethernet 10/100 ports and 2 1000 GBIC uplinks)',
313 '9.1.559' => 'WS-C2950T-48 (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)',
314 '9.1.749' => 'WS-CBS3030-DEL (12 Ethernet 10/100/1000 and 4 10/100/1000 SFP uplinks)',
315 '9.1.920' => 'WS-CBS3032-DEL-F (16 Ethernet 10/100/1000 and up to 8 10/100/1000 uplinks)',
316 '9.12.3.1.3.719' => 'N5K-C5020 (40-ports system)',
317 '11.2.3.7.11.36' => 'HP J8164A (24 Ethernet 10/100 ports and 2 100/1000 uplinks)',
318 '11.2.3.7.11.35' => 'HP J8165A (48 Ethernet 10/100 ports and 2 100/1000 uplinks)',
319 '4526.100.2.2' => 'NETGEAR GSM7224 (24 Ethernet 10/100/1000 ports)',
2ffd5a2a 320 );
389e01ee 321 // Cisco sysObjectID to Dictionary dict_key map
2ffd5a2a
DO
322 $hwtype = array
323 (
74aee2dc
DO
324 '9.1.278' => 395,
325 '9.1.283' => 148,
326 '9.1.324' => 380,
327 '9.1.325' => 382,
328 '9.1.696' => 167,
329 '9.1.697' => 166,
330 '9.1.527' => 210,
331 '9.1.561' => 115,
332 '9.1.633' => 169,
333 '9.1.634' => 170,
334 '9.1.563' => 171,
335 '9.1.564' => 172,
336 '9.1.614' => 175,
337 '9.1.615' => 173,
338 '9.1.616' => 176,
339 '9.1.617' => 174,
340 '9.1.624' => 143,
341 '9.1.58' => 145,
342 '9.1.503' => 145,
343 '9.1.59' => 156,
344 '9.1.502' => 156,
345 '9.1.626' => 147,
346 '9.1.659' => 377,
347 '9.1.428' => 389,
348 '9.1.429' => 390,
349 '9.1.559' => 387,
350 '9.1.516' => 179,
351 '9.1.716' => 164,
352 '9.1.717' => 162,
353 '9.1.920' => 795,
354 '9.12.3.1.3.719' => 960,
355 '9.1.749' => 989,
356 '11.2.3.7.11.36' => 865,
357 '11.2.3.7.11.35' => 867,
358 '4526.100.2.2' => 562,
b3f866fc
AD
359 );
360 // Cisco portType to Dictionary dict_key map
361 $porttype = array
362 (
363 18 => 19, // 10/100BaseT => RJ-45/100Base-T
364 28 => 25, // 1000BaseSX => SC/1000Base-SX
365 31 => 440, // No Transceiver => unknown
366 61 => 24, // 10/100/1000BaseT => RJ-45/1000Base-T
2ffd5a2a
DO
367 );
368
74aee2dc
DO
369 // TODO: to make all processing purely OID-based, it may help to call:
370 // snmp_set_oid_output_format (SNMP_OID_OUTPUT_NUMERIC) (in PHP 5.2+)
371 $objectInfo = spotEntity ('object', $object_id);
2ffd5a2a 372 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
4f6c1921 373 $sysName = @snmpget ($endpoints[0], $community, 'sysName.0');
fe5c487c 374 if ($sysName === FALSE)
4f6c1921
JT
375 {
376 $log[] = array ('code' => 'error', 'message' => 'SNMP error connecting to "' . $endpoints[0] . '"');
377 return $log;
378 }
379 $sysName = substr ($sysName, strlen ('STRING: '));
2ffd5a2a 380 $sysDescr = snmpget ($endpoints[0], $community, 'sysDescr.0');
601b058b
DO
381 // Don't generate error for agents other than IOS.
382 $sysChassi = @snmpget ($endpoints[0], $community, '1.3.6.1.4.1.9.3.6.3.0');
383 if ($sysChassi === FALSE or $sysChassi == NULL)
384 $sysChassi = '';
2c610c64
DO
385 else
386 $sysChassi = str_replace ('"', '', substr ($sysChassi, strlen ('STRING: ')));
2ffd5a2a
DO
387 // Strip the object type, it's always string here.
388 $sysDescr = substr ($sysDescr, strlen ('STRING: '));
32c0b3e2
JT
389 $sysDescr = str_replace(array("\n", "\r"), "", $sysDescr); // Make it one line
390 if (FALSE !== ereg ('^(Cisco )?(Internetwork Operating System Software )?IOS .+$', $sysDescr))
2c610c64 391 {
4466c276 392 $swfamily = 'IOS';
2c610c64
DO
393 $swversion = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
394 $swrelease = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $swversion);
395 }
4466c276 396 elseif (FALSE !== ereg ('^Cisco NX-OS.+$', $sysDescr))
2c610c64 397 {
4466c276 398 $swfamily = 'NX-OS';
2c610c64
DO
399 $swversion = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
400 $swrelease = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $swversion);
401 }
402 elseif
403 (
404 FALSE !== ereg ('^HP [[:alnum:]]+ ProCurve Switch', $sysDescr) or
405 FALSE !== ereg ('^ProCurve [[:alnum:]]+ Switch', $sysDescr)
406 )
407 {
408 $swfamily = 'HP';
409 $swversion = ereg_replace ('^.* revision ([^ ]+), .*$', '\\1', $sysDescr);
410 $swrelease = 'HP';
411 }
74aee2dc
DO
412 elseif (FALSE !== ereg ('^GSM[[:alnum:]]+ L2 Managed Gigabit Switch$', $sysDescr))
413 {
414 $swfamily = 'NETGEAR';
415 $swrelease = 'NETGEAR';
416 }
2ffd5a2a 417 else
2ffd5a2a 418 $log[] = array ('code' => 'error', 'message' => 'No idea how to handle ' . $sysDescr);
2ffd5a2a
DO
419 $attrs = getAttrValues ($object_id);
420 // Only fill in attribute values, if they are not set.
421 // FIXME: this is hardcoded
422
59a83bd8 423 if (!strlen ($attrs[3]['value']) && strlen ($sysName)) // FQDN
2ffd5a2a
DO
424 {
425 $error = commitUpdateAttrValue ($object_id, 3, $sysName);
426 if ($error == TRUE)
427 $log[] = array ('code' => 'success', 'message' => 'FQDN set to ' . $sysName);
428 else
429 $log[] = array ('code' => 'error', 'message' => 'Failed settig FQDN: ' . $error);
430 }
431
59a83bd8 432 if (!strlen ($attrs[5]['value']) and strlen ($swversion) > 0) // SW version
2ffd5a2a 433 {
4466c276 434 $error = commitUpdateAttrValue ($object_id, 5, $swversion);
2ffd5a2a 435 if ($error == TRUE)
4466c276 436 $log[] = array ('code' => 'success', 'message' => 'SW version set to ' . $swversion);
2ffd5a2a
DO
437 else
438 $log[] = array ('code' => 'error', 'message' => 'Failed settig SW version: ' . $error);
439 }
440
59a83bd8 441 if (!strlen ($attrs[1]['value']) and strlen ($sysChassi) > 0) // OEM Serial #1
2ffd5a2a
DO
442 {
443 $error = commitUpdateAttrValue ($object_id, 1, $sysChassi);
444 if ($error == TRUE)
445 $log[] = array ('code' => 'success', 'message' => 'OEM S/N 1 set to ' . $sysChassi);
446 else
447 $log[] = array ('code' => 'error', 'message' => 'Failed settig OEM S/N 1: ' . $error);
448 }
449
74aee2dc 450 if (!strlen ($attrs[4]['value']) and ($swfamily == 'IOS' or $swfamily == 'NX-OS')) // switch OS type
3ec29bf4 451 {
4466c276 452 switch ($swfamily . '-' . $swrelease)
2ffd5a2a 453 {
4466c276 454 case 'IOS-12.2':
2ffd5a2a
DO
455 $error = commitUpdateAttrValue ($object_id, 4, 252);
456 break;
4466c276 457 case 'IOS-12.1':
2ffd5a2a
DO
458 $error = commitUpdateAttrValue ($object_id, 4, 251);
459 break;
4466c276 460 case 'IOS-12.0':
2ffd5a2a
DO
461 $error = commitUpdateAttrValue ($object_id, 4, 244);
462 break;
4466c276
DO
463 case 'NX-OS-4.0':
464 $error = commitUpdateAttrValue ($object_id, 4, 963);
465 break;
466 case 'NX-OS-4.1':
467 $error = commitUpdateAttrValue ($object_id, 4, 964);
468 break;
3ec29bf4 469 default:
4466c276 470 $log[] = array ('code' => 'error', 'message' => "Unknown SW version ${swversion}");
32c0b3e2
JT
471 // The logic for 'error' is backwards...
472 // This should be set 'FALSE' if there is an error
473 $error = FALSE;
3ec29bf4 474 break;
2ffd5a2a 475 }
3ec29bf4 476 if ($error == TRUE)
4466c276 477 $log[] = array ('code' => 'success', 'message' => "Switch OS type set to ${swfamily} ${swrelease}");
3ec29bf4
DO
478 else
479 $log[] = array ('code' => 'error', 'message' => 'Failed setting Switch OS type');
480 }
2ffd5a2a
DO
481
482 $sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0');
483 // Transform OID
74aee2dc
DO
484 $sysObjectID = ereg_replace ('^.*(enterprises\.)([\.[:digit:]]+)$', '\\2', $sysObjectID);
485 if (!isset ($verb_model[$sysObjectID]))
2ffd5a2a 486 {
74aee2dc 487 $log[] = array ('code' => 'error', 'message' => 'Could not guess exact HW model (system OID is ' . $sysObjectID . ')!');
3ec29bf4 488 return $log;
2ffd5a2a 489 }
74aee2dc 490 $log[] = array ('code' => 'success', 'message' => 'HW is ' . $verb_model[$sysObjectID]);
59a83bd8 491 if (!strlen ($attrs[2]['value']) and isset ($hwtype[$sysObjectID])) // switch HW type
2ffd5a2a
DO
492 {
493 $error = commitUpdateAttrValue ($object_id, 2, $hwtype[$sysObjectID]);
494 if ($error == TRUE)
495 $log[] = array ('code' => 'success', 'message' => 'HW type updated Ok');
496 else
497 $log[] = array ('code' => 'error', 'message' => 'Failed settig HW type: ' . $error);
498 }
499 // Now fetch ifType, ifDescr and ifPhysAddr and let model-specific code sort the data out.
500 $ifType = snmpwalkoid ($endpoints[0], $community, 'ifType');
74aee2dc 501 $ifDescr = snmpwalkoid ($endpoints[0], $community, 'ifDescr');
2ffd5a2a
DO
502 $ifPhysAddress = snmpwalkoid ($endpoints[0], $community, 'ifPhysAddress');
503 // Combine 3 tables into 1...
504 $ifList1 = array();
505 foreach ($ifType as $key => $val)
506 {
507 list ($dummy, $ifIndex) = explode ('.', $key);
508 list ($dummy, $type) = explode (' ', $val);
509 $ifList1[$ifIndex]['type'] = $type;
510 }
511 foreach ($ifDescr as $key => $val)
512 {
513 list ($dummy, $ifIndex) = explode ('.', $key);
514 list ($dummy, $descr) = explode (' ', $val);
515 $ifList1[$ifIndex]['descr'] = trim ($descr, '"');
516 }
517 foreach ($ifPhysAddress as $key => $val)
518 {
5fc57c5b 519 $val = trim ($val);
2ffd5a2a 520 list ($dummy, $ifIndex) = explode ('.', $key);
5fc57c5b
DO
521 // NET-SNMP may return MAC addresses in one of two (?) formats depending on
522 // DISPLAY-HINT internal database. The best we can do about it is to accept both.
523 // Bug originally reported by Walery Wysotsky against openSUSE 11.0.
524 if (preg_match ('/^string: /i', $val)) // STRING: x:yy:z:xx:y:zz
525 {
526 list ($dummy, $val) = explode (' ', $val);
527 $addrbytes = explode (':', $val);
528 foreach ($addrbytes as $bidx => $bytestr)
529 if (strlen ($bytestr) == 1)
530 $addrbytes[$bidx] = '0' . $bytestr;
531 }
532 elseif (preg_match ('/^hex-string: /i', $val)) // Hex-STRING: xx yy zz xx yy zz
533 $addrbytes = explode (' ', substr ($val, -17));
534 else
535 continue; // martian format
536 $ifList1[$ifIndex]['phyad'] = implode ('', $addrbytes);
2ffd5a2a
DO
537 }
538 // ...and then reverse it inside out to make description the key.
539 $ifList2 = array();
540 foreach ($ifList1 as $ifIndex => $data)
541 {
542 $ifList2[$data['descr']]['type'] = $data['type'];
543 $ifList2[$data['descr']]['phyad'] = $data['phyad'];
544 $ifList2[$data['descr']]['idx'] = $ifIndex;
545 }
546 $newports = 0;
547 // Now we can directly pick necessary ports from the table accordingly
548 // to our known hardware model.
549 switch ($sysObjectID)
550 {
551 // FIXME: chassis edge switches often share a common naming scheme, so
552 // the sequences below have to be generalized. Let's have some duplicated
553 // code for the time being, as this is the first implementation ever.
74aee2dc 554 case '9.1.697': // WS-C2960G-48TC-L
2ffd5a2a
DO
555 // 44 copper ports: 1X, 2X, 3X...
556 // 4 combo ports: 45, 46, 47, 48. Don't list SFP connectors atm, as it's not
557 // clear how to fit them into current Ports table structure.
558 for ($i = 1; $i <= 48; $i++)
559 {
560 $label = ($i >= 45) ? "${i}" : "${i}X";
561 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
562 if ($error == '')
563 $newports++;
564 else
565 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
bbcf1dde
AD
566 }
567 break;
74aee2dc 568 case '9.1.325': // WS-C2950C-24
1f5d0fa0
DO
569 for ($i = 1; $i <= 26; $i++)
570 {
571 $label = "${i}X";
bb438b4d 572 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
1f5d0fa0
DO
573 if ($error == '')
574 $newports++;
575 else
576 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
577 }
578 break;
74aee2dc 579 case '9.1.324': // WS-C2950-24
bbcf1dde
AD
580 for ($i = 1; $i <= 24; $i++)
581 {
582 $label = "${i}X";
bb438b4d 583 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
bbcf1dde
AD
584 if ($error == '')
585 $newports++;
586 else
587 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
2ffd5a2a
DO
588 }
589 break;
74aee2dc
DO
590 case '9.1.624': // WS-C3750-24TS
591 case '9.1.696': // WS-C2960G-24TC-L
2ffd5a2a
DO
592 // Quite similar to the above.
593 for ($i = 1; $i <= 24; $i++)
594 {
595 $label = ($i >= 21) ? "${i}" : "${i}X";
596 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
597 if ($error == '')
598 $newports++;
599 else
600 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
601 }
602 break;
74aee2dc
DO
603 case '9.1.716': // WS-C2960-24TT-L
604 case '9.1.563': // WS-C3560-24PS
605 case '9.1.633': // WS-C3560-24TS
606 case '9.1.428': // WS-C2950G-24
2ffd5a2a
DO
607 for ($i = 1; $i <= 24; $i++)
608 {
609 $label = "${i}X";
610 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
611 if ($error == '')
612 $newports++;
613 else
614 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
615 }
616 for ($i = 1; $i <= 2; $i++)
617 {
618 $label = "${i}";
619 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
620 if ($error == '')
621 $newports++;
622 else
623 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
624 }
625 break;
74aee2dc
DO
626 case '9.1.717': // WS-C2960-48TT-L
627 case '9.1.429': // WS-C2950G-48
628 case '9.1.559': // WS-C2950T-48
3ec29bf4
DO
629 for ($i = 1; $i <= 48; $i++)
630 {
631 $label = "${i}X";
632 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
633 if ($error == '')
634 $newports++;
635 else
636 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
637 }
638 for ($i = 1; $i <= 2; $i++)
639 {
640 $label = "${i}";
641 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
642 if ($error == '')
643 $newports++;
644 else
645 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
646 }
647 break;
74aee2dc 648 case '9.1.516': // WS-C3750G-24TS OR WS-C3750-48PS
b3f866fc
AD
649 // FIXME: only handles 2 models of 3750, make it handle all of them
650 // see if it has 24 or 48 ports
651 $numports = substr (snmpget ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.3.1.1.14.1'), strlen('INTEGER: '));
652
653 if ($numports == 28) // has 24 ports (+4 SFP) meaning it's a WS-C3750G-24TS
069c186f 654 {
b3f866fc
AD
655 for ($i = 1; $i <= 28; $i++)
656 {
657 $label = "${i}";
658 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
659 if ($error == '')
660 $newports++;
661 else
662 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
663 }
069c186f 664 }
b3f866fc 665 elseif ($numports == 52) // has 48 ports (+4 SFP) meaning it's a WS-C3750-48PS
069c186f 666 {
b3f866fc
AD
667 for ($i = 1; $i <= 48; $i++)
668 {
669 $label = "${i}X";
670 $error = commitAddPort ($object_id, 'fa1/0/' . $i, 19, $label, $ifList2["FastEthernet1/0/${i}"]['phyad']);
671 if ($error == '')
672 $newports++;
673 else
674 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
675 }
676 for ($i = 1; $i <= 4; $i++)
677 {
678 $label = "${i}";
679 $error = commitAddPort ($object_id, 'gi1/0/' . $i, 24, $label, $ifList2["GigabitEthernet1/0/${i}"]['phyad']);
680 if ($error == '')
681 $newports++;
682 else
683 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
684 }
069c186f
DO
685 }
686 break;
74aee2dc
DO
687 case '9.1.564': // WS-C3560-48PS
688 case '9.1.634': // WS-C3560-48TS
2ffd5a2a
DO
689 for ($i = 1; $i <= 48; $i++)
690 {
691 $label = "${i}X";
692 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
693 if ($error == '')
694 $newports++;
695 else
696 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
697 }
698 for ($i = 1; $i <= 4; $i++)
699 {
700 $label = "${i}";
701 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
702 if ($error == '')
703 $newports++;
704 else
705 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
706 }
707 break;
74aee2dc
DO
708 case '9.1.614': // WS-C3560G-24PS
709 case '9.1.615': // WS-C3560G-24TS
710 case '9.1.527': // WS-C2970G-24T
711 case '9.1.561': // WS-C2970G-24TS
2ffd5a2a
DO
712 for ($i = 1; $i <= 24; $i++)
713 {
714 $label = "${i}X";
715 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
716 if ($error == '')
717 $newports++;
718 else
719 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
720 }
721 break;
74aee2dc
DO
722 case '9.1.616': // WS-C3560G-48PS
723 case '9.1.617': // WS-C3560G-48TS
2ffd5a2a
DO
724 for ($i = 1; $i <= 48; $i++)
725 {
726 $label = "${i}X";
727 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
728 if ($error == '')
729 $newports++;
730 else
731 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
732 }
733 break;
74aee2dc
DO
734 case '9.1.626': // WS-C4948
735 case '9.1.659': // WS-C4948-10GE
2ffd5a2a
DO
736 for ($i = 1; $i <= 48; $i++)
737 {
738 $label = "${i}X";
739 $error = commitAddPort ($object_id, 'gi1/' . $i, 24, $label, $ifList2["GigabitEthernet1/${i}"]['phyad']);
740 if ($error == '')
741 $newports++;
742 else
743 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
744 }
745 break;
b3f866fc
AD
746 // For modular devices we issue a separate SNMP query to determine port type,
747 // then extract blade & port numbers from the results.
74aee2dc
DO
748 case '9.1.58': // WS-C4503
749 case '9.1.503': // WS-C4503
750 case '9.1.59': // WS-C4506
751 case '9.1.502': // WS-C4506
752 case '9.1.283': // WS-C6509-E
b3f866fc
AD
753 // get slot #, port # and port type using Cisco's MIB
754 $portType = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.5');
755 $ifList = array();
756 $i = 0;
757 foreach ($portType as $key => $val)
2ffd5a2a 758 {
b3f866fc
AD
759 // slot = $portIndex[8]
760 // port = $portIndex[9]
761 $portIndex = explode('.', $key);
762 $ifList[$i]['slotno'] = $portIndex[8];
763 $ifList[$i]['portno'] = $portIndex[9];
764
765 // note the Cisco port type and corresponding RackTables port type
766 list ($dummy, $cptype) = explode (' ', $val);
767 $ifList[$i]['cptype'] = $cptype;
768 if (array_key_exists($cptype, $porttype))
769 $ifList[$i]['ptype'] = $porttype[$cptype];
770 else
771 $ifList[$i]['ptype'] = null;
772 $i++;
773 }
774
775 // use Cisco's ifIndex attribute to map Cisco table to standard SNMP table
776 $ifIndex = snmpwalkoid ($endpoints[0], $community, '.1.3.6.1.4.1.9.5.1.4.1.1.11');
777 $i = 0;
778 foreach ($ifIndex as $val)
779 {
780 if (is_null($ifList[$i]['ptype']))
2ffd5a2a 781 {
b3f866fc
AD
782 $log[] = array ('code' => 'error', 'message' => 'Unknown port type: ' . $ifList[$i]['cptype']);
783 } else {
784 switch ($ifList[$i]['ptype'])
785 {
786 case 19: // fast eth
787 $prefix = 'fa';
788 break;
789 case 28: // 1000base-sx
790 case 61: // gig eth
791 $prefix = 'gi';
792 break;
793 default: // unknown, default to gig eth
794 $prefix = 'gi';
795 }
796 $pname = "{$prefix}{$ifList[$i]['slotno']}/{$ifList[$i]['portno']}";
797 $label = "slot {$ifList[$i]['slotno']} port {$ifList[$i]['portno']}";
798 list($dummy, $index) = explode(' ', $val);
799
800 // if l2address already exists in DB, nullify value so new row gets added without error
801 if (!is_null(searchByl2address($ifList1[$index]['phyad']))) $ifList1[$index]['phyad'] = null;
802
803 $error = commitAddPort ($object_id, $pname, $ifList[$i]['ptype'], $label, $ifList1[$index]['phyad']);
804 if ($error == '')
805 $newports++;
806 else
807 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $pname . ': ' . $error);
2ffd5a2a 808 }
b3f866fc
AD
809 $i++;
810 }
811 break;
74aee2dc 812 case '9.1.278': // WS-C3548-XL
b3f866fc
AD
813 for ($i = 1; $i <= 48; $i++)
814 {
815 $label = "${i}X";
816 $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']);
2ffd5a2a
DO
817 if ($error == '')
818 $newports++;
819 else
b3f866fc
AD
820 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
821 }
822 for ($i = 1; $i <= 2; $i++)
823 {
824 $label = "${i}";
825 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
826 if ($error == '')
827 $newports++;
828 else
829 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
830 }
831 break;
74aee2dc 832 case '9.1.920': // WS-CBS3032-DEL-F
b3f866fc
AD
833 for ($i = 1; $i <= 24; $i++)
834 {
835 $label = "${i}";
836 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
837 if ($error == '')
838 $newports++;
839 else
840 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
2ffd5a2a 841 }
b1101095 842 break;
74aee2dc 843 case '9.1.749': // WS-CBS3030-DEL-F (or WS-CBS3030-DEL-S)
b1101095
JT
844 for ($i = 1; $i <= 16; $i++)
845 {
846 $label = "${i}";
847 $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']);
848 if ($error == '')
849 $newports++;
850 else
851 $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error);
852 }
2ffd5a2a 853 break;
74aee2dc 854 case '9.12.3.1.3.719': // N5K-C5020
4466c276 855 break;
74aee2dc 856 case '11.2.3.7.11.35':
2c610c64
DO
857 $n100 = 48;
858 // fall through
74aee2dc
DO
859 case '11.2.3.7.11.36':
860 if ($sysObjectID == '11.2.3.7.11.36')
2c610c64
DO
861 $n100 = 24;
862 $n1000 = 2;
863 for ($i = 1; $i <= $n100; $i++)
864 if ('' == ($error = commitAddPort ($object_id, $i, 19, $i, $ifList2[$i]['phyad'])))
865 $newports++;
866 else
867 $log[] = array ('code' => 'error', 'message' => "Failed to add port ${i}: " . $error);
868 for ($i = $n100 + 1; $i <= $n100 + $n1000; $i++)
869 if ('' == ($error = commitAddPort ($object_id, $i, 24, $i, $ifList2[$i]['phyad'])))
870 $newports++;
871 else
872 $log[] = array ('code' => 'error', 'message' => "Failed to add port ${i}: " . $error);
873 break;
74aee2dc
DO
874 case '4526.100.2.2':
875 for ($i = 1; $i <= 24; $i++)
876 if ('' == ($error = commitAddPort ($object_id, $i, 24, '', $ifList2["Unit: 1 Slot: 0 Port: ${i} Gigabit - Level"]['phyad'])))
877 $newports++;
878 else
879 $log[] = array ('code' => 'error', 'message' => "Failed to add port ${label}: ${error}");
880 break;
2ffd5a2a 881 default:
4466c276 882 $log[] = array ('code' => 'error', 'message' => "Unexpected sysObjectID '${sysObjectID}'");
2ffd5a2a
DO
883 }
884 $error = commitAddPort ($object_id, 'con0', 29, 'console', '');
885 if ($error == '')
886 $newports++;
887 else
888 $log[] = array ('code' => 'error', 'message' => 'Failed to add console port : ' . $error);
889 if ($newports > 0)
890 $log[] = array ('code' => 'success', 'message' => "Added ${newports} new ports");
891 return $log;
892}
893
74aee2dc
DO
894
895function updateStickerForCell ($cell, $attr_id, $new_value)
896{
897 if (!strlen ($cell['attrs'][$attr_id]['value']) && strlen ($new_value))
898 commitUpdateAttrValue ($cell['id'], $attr_id, $new_value);
899}
900
901function doSNMPmining_new ($object_id, $community)
902{
903 $log = emptyLog();
904 global $known_switches, $iftable_processors;
905
906 $objectInfo = spotEntity ('object', $object_id);
907 $objectInfo['attrs'] = getAttrValues ($object_id);
908 $endpoints = findAllEndpoints ($object_id, $objectInfo['name']);
909 if (count ($endpoints) == 0)
910 return oneLiner (161); // endpoint not found
911 if (count ($endpoints) > 1)
912 return oneLiner (162); // can't pick an address
913
914 if (FALSE === ($sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0')))
915 return oneLiner (188); // fatal SNMP failure
916 $sysObjectID = ereg_replace ('^.*(enterprises\.)([\.[:digit:]]+)$', '\\2', $sysObjectID);
917 $sysName = snmpget ($endpoints[0], $community, 'sysName.0');
918 $sysDescr = substr (snmpget ($endpoints[0], $community, 'sysDescr.0'), strlen ('STRING: '));
919 $sysDescr = str_replace (array ("\n", "\r"), " ", $sysDescr); // Make it one line
920 if (!isset ($known_switches[$sysObjectID]))
921 return oneLiner (189, array ($sysObjectID)); // unknown OID
922 updateStickerForCell ($objectInfo, 2, $hwtype[$sysObjectID]);
923 updateStickerForCell ($objectInfo, 3, $sysName);
924 switch (1)
925 {
926 case preg_match ('^9\.1\.', $sysObjectID): // Catalyst
927 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
928 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
929 $ios_codes = array
930 (
931 '12.0' => 244,
932 '12.1' => 251,
933 '12.2' => 252,
934 );
935 updateStickerForCell ($objectInfo, 5, $exact_release);
936 updateStickerForCell ($objectInfo, 4, $ios_codes[$major_line]);
937 $sysChassi = snmpget ($endpoints[0], $community, '1.3.6.1.4.1.9.3.6.3.0');
938 if ($sysChassi !== FALSE or $sysChassi !== NULL)
939 updateStickerForCell ($objectInfo, 1, str_replace ('"', '', substr ($sysChassi, strlen ('STRING: '))));
940 break;
941 case preg_match ('^9\.12\.3\.1\.3\.', $sysObjectID): // Nexus
942 $exact_release = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr);
943 $major_line = ereg_replace ('^([[:digit:]]+\.[[:digit:]]+)[^[:digit:]].*', '\\1', $exact_release);
944 $nxos_codes = array
945 (
946 '4.0' => 963,
947 '4.1' => 964,
948 );
949 updateStickerForCell ($objectInfo, 4, $nxos_codes[$major_line]);
950 updateStickerForCell ($objectInfo, 5, $exact_release);
951 break;
952 case preg_match ('^11\.2\.3\.7\.11\.', $sysObjectID): // ProCurve
953 $exact_release = ereg_replace ('^.* revision ([^ ]+), .*$', '\\1', $sysDescr);
954 updateStickerForCell ($objectInfo, 5, $exact_release);
955 break;
956 case preg_match ('^4526\.100\.2\.', $sysObjectID): // NETGEAR
957 break;
958 }
959}
960
2ffd5a2a 961?>