line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Storages::Megaraid; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Authors: Egor Shornikov , Egor Morozov |
4
|
|
|
|
|
|
|
# License: GPLv2+ |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
116556347
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
92
|
|
7
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
63
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
535
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
165
|
|
10
|
1
|
|
|
1
|
|
573
|
use FusionInventory::Agent::Task::Inventory::BSD::Storages; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
19
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub isEnabled { |
13
|
0
|
|
|
0
|
0
|
|
return canRun('mfiutil'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _parseMfiutil { |
17
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my @storages; |
20
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
21
|
0
|
0
|
|
|
|
|
unless ( $line =~ m/^[^(]*\(\s+(\d+\w+)\)\s+\S+\s+<(\S+)\s+(\S+)\s+\S+\s+serial=(\S+)>\s+(\S+)\s+.*$/ ) { next; } |
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my ( $size, $vendor, $model, $serial, $type ) = ( $1, $2, $3, $4, $5 ); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if ( $size =~ /(\d+)G/ ){ |
|
|
0
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$size = $1 * 1024; |
26
|
|
|
|
|
|
|
} elsif( $size =~ /(\d+)T/ ){ |
27
|
0
|
|
|
|
|
|
$size = $1 * 1024 * 1024; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $storage; |
31
|
0
|
|
|
|
|
|
$storage->{NAME} = "$vendor $model"; |
32
|
0
|
|
|
|
|
|
$storage->{DESCRIPTION} = $type; |
33
|
0
|
|
|
|
|
|
$storage->{TYPE} = 'disk'; |
34
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} = $size; |
35
|
0
|
|
|
|
|
|
$storage->{SERIALNUMBER} = $serial; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
push @storages, $storage; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
close $handle; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return @storages; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub doInventory { |
45
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
foreach my $storage (_parseMfiutil( |
50
|
|
|
|
|
|
|
logger => $params{logger}, |
51
|
|
|
|
|
|
|
command => 'mfiutil show drives')) { |
52
|
0
|
|
|
|
|
|
$inventory->addEntry(section => 'STORAGES', entry => $storage); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |