line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Storages::Megaraid; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Authors: Egor Shornikov , Egor Morozov |
4
|
|
|
|
|
|
|
# License: GPLv2+ |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
141501305
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
113
|
|
7
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
146
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1099
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
399
|
|
10
|
2
|
|
|
2
|
|
1285
|
use FusionInventory::Agent::Task::Inventory::Linux::Storages; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
33
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub isEnabled { |
13
|
0
|
|
|
0
|
0
|
0
|
return canRun('megasasctl'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _parseMegasasctl { |
17
|
1
|
|
|
1
|
|
14
|
my $handle = getFileHandle( |
18
|
|
|
|
|
|
|
command => 'megasasctl -v', |
19
|
|
|
|
|
|
|
@_ |
20
|
|
|
|
|
|
|
); |
21
|
1
|
50
|
|
|
|
4
|
return unless $handle; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
1
|
my @storages; |
24
|
1
|
|
|
|
|
13
|
while (my $line = <$handle>) { |
25
|
11
|
100
|
|
|
|
89
|
unless( $line =~ /\s*([a-z]\d[a-z]\d+[a-z]\d+)\s+(\S+)\s+(\S+)\s*(\S+)\s+\S+\s+\S+\s*/ ){ next; } |
|
5
|
|
|
|
|
13
|
|
26
|
6
|
|
|
|
|
27
|
my ( $disk_addr, $vendor, $model, $size ) = ( $1, $2, $3, $4 ); |
27
|
|
|
|
|
|
|
|
28
|
6
|
50
|
|
|
|
23
|
if ( $size =~ /(\d+)GiB/ ){ |
29
|
6
|
|
|
|
|
13
|
$size = $1 * 1024; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
7
|
my $storage; |
33
|
6
|
|
|
|
|
13
|
$storage->{NAME} = $disk_addr; |
34
|
6
|
|
|
|
|
11
|
$storage->{MANUFACTURER} = $vendor; |
35
|
6
|
|
|
|
|
9
|
$storage->{MODEL} = $model; |
36
|
6
|
|
|
|
|
8
|
$storage->{DESCRIPTION} = 'SAS'; |
37
|
6
|
|
|
|
|
12
|
$storage->{TYPE} = 'disk'; |
38
|
6
|
|
|
|
|
8
|
$storage->{DISKSIZE} = $size; |
39
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
27
|
push @storages, $storage; |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
8
|
close $handle; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
7
|
return @storages; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub doInventory { |
49
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
foreach my $storage (_parseMegasasctl(@_)) { |
54
|
0
|
|
|
|
|
|
$inventory->addEntry(section => 'STORAGES', entry => $storage); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |