Line 0
Link Here
|
|
|
1 |
--- lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Storages/Megaraid.pm.orig 1970-01-01 01:00:00.000000000 +0100 |
2 |
+++ lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Storages/Megaraid.pm 2012-08-24 11:02:56.000000000 +0200 |
3 |
@@ -0,0 +1,50 @@ |
4 |
+package FusionInventory::Agent::Task::Inventory::Input::BSD::Storages::Megaraid; |
5 |
+ |
6 |
+# Authors: Egor Shornikov <se@wbr.su>, Egor Morozov <akrus@flygroup.st> |
7 |
+# License: GPLv2+ |
8 |
+ |
9 |
+use strict; |
10 |
+use warnings; |
11 |
+ |
12 |
+use FusionInventory::Agent::Tools; |
13 |
+use FusionInventory::Agent::Task::Inventory::Input::BSD::Storages; |
14 |
+ |
15 |
+sub isEnabled { |
16 |
+ return canRun('mfiutil'); |
17 |
+} |
18 |
+ |
19 |
+sub doInventory { |
20 |
+ my (%params) = @_; |
21 |
+ |
22 |
+ my $inventory = $params{inventory}; |
23 |
+ my $logger = $params{logger}; |
24 |
+ |
25 |
+ my $handle = getFileHandle( |
26 |
+ logger => $logger, |
27 |
+ command => 'mfiutil show drives' |
28 |
+ ); |
29 |
+ return unless $handle; |
30 |
+ |
31 |
+ while (my $line = <$handle>) { |
32 |
+ unless ( $line =~ m/^[^(]*\(\s+(\d+\w+)\)\s+\S+\s+<(\S+)\s+(\S+)\s+\S+\s+serial=(\S+)>\s+(\S+)\s+.*$/ ) { next; } |
33 |
+ my ( $size, $vendor, $model, $serial, $type ) = ( $1, $2, $3, $4, $5 ); |
34 |
+ |
35 |
+ if ( $size =~ /(\d+)G/ ){ |
36 |
+ $size = $1 * 1024; |
37 |
+ } elsif( $size =~ /(\d+)T/ ){ |
38 |
+ $size = $1 * 1024 * 1024; |
39 |
+ } |
40 |
+ |
41 |
+ my $storage; |
42 |
+ $storage->{NAME} = "$vendor $model"; |
43 |
+ $storage->{DESCRIPTION} = $type; |
44 |
+ $storage->{TYPE} = 'disk'; |
45 |
+ $storage->{DISKSIZE} = $size; |
46 |
+ $storage->{SERIALNUMBER} = $serial; |
47 |
+ |
48 |
+ $inventory->addEntry(section => 'STORAGES', entry => $storage); |
49 |
+ } |
50 |
+ close $handle; |
51 |
+} |
52 |
+ |
53 |
+1; |
54 |
--- lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Storages/3ware.pm.orig 1970-01-01 01:00:00.000000000 +0100 |
55 |
+++ lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Storages/3ware.pm 2012-08-24 10:58:20.000000000 +0200 |
56 |
@@ -0,0 +1,178 @@ |
57 |
+package FusionInventory::Agent::Task::Inventory::Input::Generic::Storages::3ware; |
58 |
+ |
59 |
+use strict; |
60 |
+use warnings; |
61 |
+ |
62 |
+use FusionInventory::Agent::Tools; |
63 |
+use FusionInventory::Agent::Tools::Linux; |
64 |
+ |
65 |
+use English qw(-no_match_vars); |
66 |
+ |
67 |
+# Tested on 2.6.* kernels |
68 |
+# |
69 |
+# Cards tested : |
70 |
+# |
71 |
+# 8006-2LP |
72 |
+# 9500S-4LP |
73 |
+# 9550SXU-4LP |
74 |
+# 9550SXU-8LP |
75 |
+# 9650SE-2LP |
76 |
+# 9650SE-4LPML |
77 |
+# 9650SE-8LPML |
78 |
+# |
79 |
+# AMCC/3ware CLI (version 2.00.0X.XXX) |
80 |
+ |
81 |
+sub isEnabled { |
82 |
+ return canRun('tw_cli'); |
83 |
+} |
84 |
+ |
85 |
+sub doInventory { |
86 |
+ my (%params) = @_; |
87 |
+ |
88 |
+ my $inventory = $params{inventory}; |
89 |
+ my $logger = $params{logger}; |
90 |
+ |
91 |
+ my @devices; |
92 |
+ |
93 |
+ foreach my $card (_getCards()) { |
94 |
+ foreach my $unit (_getUnits($card)) { |
95 |
+ |
96 |
+ # Try do get unit's serial in order to compare it to what was found |
97 |
+ # in udev db. |
98 |
+ # Works only on newer cards. |
99 |
+ # Allow us to associate a node to a drive : sda -> WD-WMANS1648590 |
100 |
+ my $sn = getFirstMatch( |
101 |
+ logger => $logger, |
102 |
+ command => "tw_cli info $card->{id} $unit->{id} serial", |
103 |
+ pattern => qr/serial number\s=\s(\w+)/ |
104 |
+ ); |
105 |
+ |
106 |
+ foreach my $port (_getPorts($card, $unit)) { |
107 |
+ # Finally, getting drives' values. |
108 |
+ my $storage = _getStorage($card, $port); |
109 |
+ |
110 |
+ if ($OSNAME eq 'Linux') { |
111 |
+ |
112 |
+ @devices = getDevicesFromUdev(logger => $logger) unless @devices; |
113 |
+ |
114 |
+ foreach my $device (@devices) { |
115 |
+# How does this work with multiple older cards |
116 |
+# where serial for units is not implemented ? |
117 |
+# Need to be tested on a system with multiple |
118 |
+# 3ware cards. |
119 |
+ if ( |
120 |
+ $device->{SERIALNUMBER} eq 'AMCC_' . $sn || |
121 |
+ $device->{MODEL} eq 'Logical_Disk_' . $unit->{index} |
122 |
+ ) { |
123 |
+ $storage->{NAME} = $device->{NAME}; |
124 |
+ } |
125 |
+ } |
126 |
+ } |
127 |
+ |
128 |
+ $inventory->addEntry(section => 'STORAGES', entry => $storage); |
129 |
+ } |
130 |
+ } |
131 |
+ } |
132 |
+} |
133 |
+ |
134 |
+ |
135 |
+sub _getCards { |
136 |
+ my ($file) = @_; |
137 |
+ |
138 |
+ my $handle = getFileHandle( |
139 |
+ file => $file, |
140 |
+ command => "tw_cli info" |
141 |
+ ); |
142 |
+ return unless $handle; |
143 |
+ |
144 |
+ my @cards; |
145 |
+ while (my $line = <$handle>) { |
146 |
+ next unless $line =~ /^(c\d+)\s+([\w-]+)/; |
147 |
+ push @cards, { id => $1, model => $2 }; |
148 |
+ } |
149 |
+ close $handle; |
150 |
+ |
151 |
+ return @cards; |
152 |
+} |
153 |
+ |
154 |
+sub _getUnits { |
155 |
+ my ($card, $file) = @_; |
156 |
+ |
157 |
+ my $handle = getFileHandle( |
158 |
+ file => $file, |
159 |
+ command => "tw_cli info $card->{id}" |
160 |
+ ); |
161 |
+ return unless $handle; |
162 |
+ |
163 |
+ my @units; |
164 |
+ while (my $line = <$handle>) { |
165 |
+ next unless $line =~ /^(u(\d+))/; |
166 |
+ push @units, { id => $1, index => $2 }; |
167 |
+ } |
168 |
+ close $handle; |
169 |
+ |
170 |
+ return @units; |
171 |
+} |
172 |
+ |
173 |
+sub _getPorts { |
174 |
+ my ($card, $unit, $file) = @_; |
175 |
+ |
176 |
+ my $handle = getFileHandle( |
177 |
+ file => $file, |
178 |
+ command => "tw_cli info $card->{id} $unit->{id}" |
179 |
+ ); |
180 |
+ return unless $handle; |
181 |
+ |
182 |
+ my @ports; |
183 |
+ while (my $line = <$handle>) { |
184 |
+ next unless $line =~ /(p\d+)/; |
185 |
+ push @ports, { id => $1 }; |
186 |
+ } |
187 |
+ close $handle; |
188 |
+ |
189 |
+ return @ports; |
190 |
+} |
191 |
+ |
192 |
+sub _getStorage { |
193 |
+ my ($card, $port, $file) = @_; |
194 |
+ |
195 |
+ my $handle = getFileHandle( |
196 |
+ file => $file, |
197 |
+ command => |
198 |
+ "tw_cli info $card->{id} $port->{id} model serial capacity firmware" |
199 |
+ ); |
200 |
+ return unless $handle; |
201 |
+ |
202 |
+ my $storage; |
203 |
+ while (my $line = <$handle>) { |
204 |
+ if ($line =~ /Model\s=\s(.*)/) { |
205 |
+ $storage->{MODEL} = $1; |
206 |
+ } elsif ($line =~ /Serial\s=\s(.*)/) { |
207 |
+ $storage->{SERIALNUMBER} = $1; |
208 |
+ } elsif ($line =~ /Capacity\s=\s(\S+)\sGB.*/) { |
209 |
+ $storage->{DISKSIZE} = 1024 * $1; |
210 |
+ } elsif ($line =~ /Firmware Version\s=\s(.*)/) { |
211 |
+ $storage->{FIRMWARE} = $1 |
212 |
+ } |
213 |
+ } |
214 |
+ close $handle; |
215 |
+ |
216 |
+ $storage->{MANUFACTURER} = getCanonicalManufacturer( |
217 |
+ $storage->{MODEL} |
218 |
+ ); |
219 |
+ $storage->{TYPE} = 'disk'; |
220 |
+ |
221 |
+ # Getting description from card model, very basic |
222 |
+ # and unreliable |
223 |
+ # Assuming only IDE drives can be plugged in |
224 |
+ # 5xxx/6xxx cards and |
225 |
+ # SATA drives only to 7xxx/8xxx/9xxxx cards |
226 |
+ $storage->{DESCRIPTION} = |
227 |
+ $card->{model} =~ /^[56]/ ? 'IDE' : |
228 |
+ $card->{model} =~ /^[789]/ ? 'SATA' : |
229 |
+ undef; |
230 |
+ |
231 |
+ return $storage; |
232 |
+} |
233 |
+ |
234 |
+1; |
235 |
--- lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/3ware.pm.orig 2012-08-24 10:57:58.000000000 +0200 |
236 |
+++ lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/3ware.pm 1970-01-01 01:00:00.000000000 +0100 |
237 |
@@ -1,171 +0,0 @@ |
238 |
-package FusionInventory::Agent::Task::Inventory::Input::Linux::Storages::3ware; |
239 |
- |
240 |
-use strict; |
241 |
-use warnings; |
242 |
- |
243 |
-use FusionInventory::Agent::Tools; |
244 |
-use FusionInventory::Agent::Tools::Linux; |
245 |
- |
246 |
-# Tested on 2.6.* kernels |
247 |
-# |
248 |
-# Cards tested : |
249 |
-# |
250 |
-# 8006-2LP |
251 |
-# 9500S-4LP |
252 |
-# 9550SXU-4LP |
253 |
-# 9550SXU-8LP |
254 |
-# 9650SE-2LP |
255 |
-# 9650SE-4LPML |
256 |
-# 9650SE-8LPML |
257 |
-# |
258 |
-# AMCC/3ware CLI (version 2.00.0X.XXX) |
259 |
- |
260 |
-sub isEnabled { |
261 |
- return canRun('tw_cli'); |
262 |
-} |
263 |
- |
264 |
-sub doInventory { |
265 |
- my (%params) = @_; |
266 |
- |
267 |
- my $inventory = $params{inventory}; |
268 |
- my $logger = $params{logger}; |
269 |
- |
270 |
- my @devices = getDevicesFromUdev(logger => $logger); |
271 |
- |
272 |
- foreach my $card (_getCards()) { |
273 |
- foreach my $unit (_getUnits($card)) { |
274 |
- |
275 |
- # Try do get unit's serial in order to compare it to what was found |
276 |
- # in udev db. |
277 |
- # Works only on newer cards. |
278 |
- # Allow us to associate a node to a drive : sda -> WD-WMANS1648590 |
279 |
- my $sn = getFirstMatch( |
280 |
- logger => $logger, |
281 |
- command => "tw_cli info $card->{id} $unit->{id} serial", |
282 |
- pattern => qr/serial number\s=\s(\w+)/ |
283 |
- ); |
284 |
- |
285 |
- foreach my $port (_getPorts($card, $unit)) { |
286 |
- # Finally, getting drives' values. |
287 |
- my $storage = _getStorage($card, $port); |
288 |
- |
289 |
- foreach my $device (@devices) { |
290 |
- # How does this work with multiple older cards |
291 |
- # where serial for units is not implemented ? |
292 |
- # Need to be tested on a system with multiple |
293 |
- # 3ware cards. |
294 |
- if ( |
295 |
- $device->{SERIALNUMBER} eq 'AMCC_' . $sn || |
296 |
- $device->{MODEL} eq 'Logical_Disk_' . $unit->{index} |
297 |
- ) { |
298 |
- $storage->{NAME} = $device->{NAME}; |
299 |
- } |
300 |
- } |
301 |
- |
302 |
- $inventory->addEntry(section => 'STORAGES', entry => $storage); |
303 |
- } |
304 |
- } |
305 |
- } |
306 |
-} |
307 |
- |
308 |
- |
309 |
-sub _getCards { |
310 |
- my ($file) = @_; |
311 |
- |
312 |
- my $handle = getFileHandle( |
313 |
- file => $file, |
314 |
- command => "tw_cli info" |
315 |
- ); |
316 |
- return unless $handle; |
317 |
- |
318 |
- my @cards; |
319 |
- while (my $line = <$handle>) { |
320 |
- next unless $line =~ /^(c\d+)\s+([\w-]+)/; |
321 |
- push @cards, { id => $1, model => $2 }; |
322 |
- } |
323 |
- close $handle; |
324 |
- |
325 |
- return @cards; |
326 |
-} |
327 |
- |
328 |
-sub _getUnits { |
329 |
- my ($card, $file) = @_; |
330 |
- |
331 |
- my $handle = getFileHandle( |
332 |
- file => $file, |
333 |
- command => "tw_cli info $card->{id}" |
334 |
- ); |
335 |
- return unless $handle; |
336 |
- |
337 |
- my @units; |
338 |
- while (my $line = <$handle>) { |
339 |
- next unless $line =~ /^(u(\d+))/; |
340 |
- push @units, { id => $1, index => $2 }; |
341 |
- } |
342 |
- close $handle; |
343 |
- |
344 |
- return @units; |
345 |
-} |
346 |
- |
347 |
-sub _getPorts { |
348 |
- my ($card, $unit, $file) = @_; |
349 |
- |
350 |
- my $handle = getFileHandle( |
351 |
- file => $file, |
352 |
- command => "tw_cli info $card->{id} $unit->{id}" |
353 |
- ); |
354 |
- return unless $handle; |
355 |
- |
356 |
- my @ports; |
357 |
- while (my $line = <$handle>) { |
358 |
- next unless $line =~ /(p\d+)/; |
359 |
- push @ports, { id => $1 }; |
360 |
- } |
361 |
- close $handle; |
362 |
- |
363 |
- return @ports; |
364 |
-} |
365 |
- |
366 |
-sub _getStorage { |
367 |
- my ($card, $port, $file) = @_; |
368 |
- |
369 |
- my $handle = getFileHandle( |
370 |
- file => $file, |
371 |
- command => |
372 |
- "tw_cli info $card->{id} $port->{id} model serial capacity firmware" |
373 |
- ); |
374 |
- return unless $handle; |
375 |
- |
376 |
- my $storage; |
377 |
- while (my $line = <$handle>) { |
378 |
- if ($line =~ /Model\s=\s(.*)/) { |
379 |
- $storage->{MODEL} = $1; |
380 |
- } elsif ($line =~ /Serial\s=\s(.*)/) { |
381 |
- $storage->{SERIALNUMBER} = $1; |
382 |
- } elsif ($line =~ /Capacity\s=\s(\S+)\sGB.*/) { |
383 |
- $storage->{DISKSIZE} = 1024 * $1; |
384 |
- } elsif ($line =~ /Firmware Version\s=\s(.*)/) { |
385 |
- $storage->{FIRMWARE} = $1 |
386 |
- } |
387 |
- } |
388 |
- close $handle; |
389 |
- |
390 |
- $storage->{MANUFACTURER} = getCanonicalManufacturer( |
391 |
- $storage->{MODEL} |
392 |
- ); |
393 |
- $storage->{TYPE} = 'disk'; |
394 |
- |
395 |
- # Getting description from card model, very basic |
396 |
- # and unreliable |
397 |
- # Assuming only IDE drives can be plugged in |
398 |
- # 5xxx/6xxx cards and |
399 |
- # SATA drives only to 7xxx/8xxx/9xxxx cards |
400 |
- $storage->{DESCRIPTION} = |
401 |
- $card->{model} =~ /^[56]/ ? 'IDE' : |
402 |
- $card->{model} =~ /^[789]/ ? 'SATA' : |
403 |
- undef; |
404 |
- |
405 |
- return $storage; |
406 |
-} |
407 |
- |
408 |
-1; |
409 |
--- MANIFEST.orig 2012-08-24 11:06:47.000000000 +0200 |
410 |
+++ MANIFEST 2012-08-24 11:07:32.000000000 +0200 |
411 |
@@ -67,6 +67,7 @@ |
412 |
lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Networks.pm |
413 |
lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Softwares.pm |
414 |
lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Storages.pm |
415 |
+lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Storages/Megaraid.pm |
416 |
lib/FusionInventory/Agent/Task/Inventory/Input/BSD/Uptime.pm |
417 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic.pm |
418 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Dmidecode.pm |
419 |
@@ -94,6 +95,7 @@ |
420 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Softwares/RPM.pm |
421 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Softwares/Slackware.pm |
422 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Storages.pm |
423 |
+lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Storages/3ware.pm |
424 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Storages/HP.pm |
425 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/USB.pm |
426 |
lib/FusionInventory/Agent/Task/Inventory/Input/Generic/Users.pm |
427 |
@@ -128,7 +130,6 @@ |
428 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Memory.pm |
429 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Networks.pm |
430 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages.pm |
431 |
-lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/3ware.pm |
432 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/Adaptec.pm |
433 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/Lsilogic.pm |
434 |
lib/FusionInventory/Agent/Task/Inventory/Input/Linux/Storages/ServeRaid.pm |
435 |
@@ -160,6 +161,7 @@ |
436 |
lib/FusionInventory/Agent/Task/Inventory/Input/Solaris/Storages.pm |
437 |
lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization.pm |
438 |
lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Hpvm.pm |
439 |
+lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Jails.pm |
440 |
lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Libvirt.pm |
441 |
lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Lxc.pm |
442 |
lib/FusionInventory/Agent/Task/Inventory/Input/Virtualization/Parallels.pm |