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
|
2
|
|
|
2
|
|
147066869
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
97
|
|
7
|
2
|
|
|
2
|
|
19
|
use warnings; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
99
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
804
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
400
|
|
10
|
2
|
|
|
2
|
|
739
|
use FusionInventory::Agent::Task::Inventory::BSD::Storages; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
22
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub isEnabled { |
13
|
0
|
|
|
0
|
0
|
0
|
return canRun('mfiutil'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _parseMfiutil { |
17
|
1
|
|
|
1
|
|
349
|
my $handle = getFileHandle(@_); |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
|
|
2
|
my @storages; |
20
|
1
|
|
|
|
|
26
|
while (my $line = <$handle>) { |
21
|
7
|
100
|
|
|
|
40
|
unless ( $line =~ m/^[^(]*\(\s+(\d+\w+)\)\s+\S+\s+<(\S+)\s+(\S+)\s+\S+\s+serial=(\S+)>\s+(\S+)\s+.*$/ ) { next; } |
|
1
|
|
|
|
|
4
|
|
22
|
6
|
|
|
|
|
27
|
my ( $size, $vendor, $model, $serial, $type ) = ( $1, $2, $3, $4, $5 ); |
23
|
|
|
|
|
|
|
|
24
|
6
|
50
|
|
|
|
21
|
if ( $size =~ /(\d+)G/ ){ |
|
|
0
|
|
|
|
|
|
25
|
6
|
|
|
|
|
14
|
$size = $1 * 1024; |
26
|
|
|
|
|
|
|
} elsif( $size =~ /(\d+)T/ ){ |
27
|
0
|
|
|
|
|
0
|
$size = $1 * 1024 * 1024; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
7
|
my $storage; |
31
|
6
|
|
|
|
|
19
|
$storage->{NAME} = "$vendor $model"; |
32
|
6
|
|
|
|
|
10
|
$storage->{DESCRIPTION} = $type; |
33
|
6
|
|
|
|
|
11
|
$storage->{TYPE} = 'disk'; |
34
|
6
|
|
|
|
|
9
|
$storage->{DISKSIZE} = $size; |
35
|
6
|
|
|
|
|
11
|
$storage->{SERIALNUMBER} = $serial; |
36
|
|
|
|
|
|
|
|
37
|
6
|
|
|
|
|
27
|
push @storages, $storage; |
38
|
|
|
|
|
|
|
} |
39
|
1
|
|
|
|
|
9
|
close $handle; |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
7
|
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; |