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
|
|
117133354
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
60
|
|
7
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
70
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
399
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
243
|
|
10
|
2
|
|
|
2
|
|
732
|
use FusionInventory::Agent::Task::Inventory::Linux::Storages; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
23
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub isEnabled { |
13
|
0
|
|
|
0
|
0
|
0
|
return canRun('megasasctl'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _parseMegasasctl { |
17
|
1
|
|
|
1
|
|
11
|
my $handle = getFileHandle( |
18
|
|
|
|
|
|
|
command => 'megasasctl -v', |
19
|
|
|
|
|
|
|
@_ |
20
|
|
|
|
|
|
|
); |
21
|
1
|
50
|
|
|
|
2
|
return unless $handle; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
2
|
my @storages; |
24
|
1
|
|
|
|
|
8
|
while (my $line = <$handle>) { |
25
|
11
|
100
|
|
|
|
54
|
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
|
|
|
|
|
10
|
|
26
|
6
|
|
|
|
|
14
|
my ( $disk_addr, $vendor, $model, $size ) = ( $1, $2, $3, $4 ); |
27
|
|
|
|
|
|
|
|
28
|
6
|
50
|
|
|
|
16
|
if ( $size =~ /(\d+)GiB/ ){ |
29
|
6
|
|
|
|
|
8
|
$size = $1 * 1024; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
2
|
my $storage; |
33
|
6
|
|
|
|
|
9
|
$storage->{NAME} = $disk_addr; |
34
|
6
|
|
|
|
|
6
|
$storage->{MANUFACTURER} = $vendor; |
35
|
6
|
|
|
|
|
6
|
$storage->{MODEL} = $model; |
36
|
6
|
|
|
|
|
3
|
$storage->{DESCRIPTION} = 'SAS'; |
37
|
6
|
|
|
|
|
6
|
$storage->{TYPE} = 'disk'; |
38
|
6
|
|
|
|
|
7
|
$storage->{DISKSIZE} = $size; |
39
|
|
|
|
|
|
|
|
40
|
6
|
|
|
|
|
15
|
push @storages, $storage; |
41
|
|
|
|
|
|
|
} |
42
|
1
|
|
|
|
|
6
|
close $handle; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
4
|
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; |