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