line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::Storages::Adaptec; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
144631286
|
use strict; |
|
2
|
|
|
|
|
26
|
|
|
2
|
|
|
|
|
143
|
|
4
|
2
|
|
|
2
|
|
26
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
197
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
15
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
94
|
|
|
2
|
|
|
|
|
46
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
3370
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
419
|
|
9
|
2
|
|
|
2
|
|
1287
|
use FusionInventory::Agent::Tools::Linux; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
1381
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
12
|
0
|
|
|
0
|
0
|
0
|
return -r '/proc/scsi/scsi'; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub doInventory { |
16
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
19
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
0
|
my @devices = getDevicesFromUdev(logger => $logger); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
0
|
foreach my $device (@devices) { |
24
|
0
|
0
|
|
|
|
0
|
next unless $device->{MANUFACTURER}; |
25
|
|
|
|
|
|
|
next unless |
26
|
|
|
|
|
|
|
$device->{MANUFACTURER} eq 'Adaptec' || |
27
|
|
|
|
|
|
|
$device->{MANUFACTURER} eq 'Sun' || |
28
|
0
|
0
|
0
|
|
|
0
|
$device->{MANUFACTURER} eq 'ServeRA'; |
|
|
|
0
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisksFromProc( |
31
|
|
|
|
|
|
|
controller => 'scsi' . $device->{SCSI_COID}, |
32
|
|
|
|
|
|
|
name => $device->{NAME}, |
33
|
|
|
|
|
|
|
logger => $logger |
34
|
|
|
|
|
|
|
)) { |
35
|
|
|
|
|
|
|
# merge with smartctl info |
36
|
0
|
|
|
|
|
0
|
my $info = getInfoFromSmartctl(device => $disk->{device}); |
37
|
0
|
0
|
|
|
|
0
|
next unless $info->{TYPE} =~ /disk/i; |
38
|
0
|
|
|
|
|
0
|
foreach my $key (qw/SERIALNUMBER DESCRIPTION TYPE DISKSIZE MANUFACTURER/) { |
39
|
0
|
|
|
|
|
0
|
$disk->{$key} = $info->{$key}; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
0
|
delete $disk->{device}; |
42
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _getDisksFromProc { |
48
|
2
|
|
|
2
|
|
395
|
my (%params) = ( |
49
|
|
|
|
|
|
|
file => '/proc/scsi/scsi', |
50
|
|
|
|
|
|
|
@_ |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
2
|
50
|
|
|
|
11
|
return unless $params{controller}; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
13
|
my $handle = getFileHandle(%params); |
56
|
2
|
50
|
|
|
|
9
|
return unless $handle; |
57
|
|
|
|
|
|
|
|
58
|
2
|
|
|
|
|
4
|
my @disks; |
59
|
|
|
|
|
|
|
my $disk; |
60
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
4
|
my $count = -1; |
62
|
2
|
|
|
|
|
48
|
while (my $line = <$handle>) { |
63
|
38
|
100
|
|
|
|
106
|
if ($line =~ /^Host: (\w+)/) { |
64
|
12
|
|
|
|
|
14
|
$count++; |
65
|
12
|
50
|
|
|
|
41
|
if ($1 eq $params{controller}) { |
66
|
|
|
|
|
|
|
# that's the controller we're looking for |
67
|
|
|
|
|
|
|
$disk = { |
68
|
|
|
|
|
|
|
NAME => $params{name}, |
69
|
12
|
|
|
|
|
36
|
}; |
70
|
|
|
|
|
|
|
} else { |
71
|
|
|
|
|
|
|
# that's another controller |
72
|
0
|
|
|
|
|
0
|
undef $disk; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
38
|
100
|
|
|
|
198
|
if ($line =~ /Model: \s (\S.+\S) \s+ Rev: \s (\S+)/x) { |
77
|
12
|
50
|
|
|
|
27
|
next unless $disk; |
78
|
12
|
|
|
|
|
45
|
$disk->{MODEL} = $1; |
79
|
12
|
|
|
|
|
28
|
$disk->{FIRMWARE} = $2; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# that's the controller itself, not a disk |
82
|
12
|
100
|
|
|
|
62
|
next if $disk->{MODEL} =~ /raid|virtual/i; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
$disk->{MANUFACTURER} = getCanonicalManufacturer( |
85
|
|
|
|
|
|
|
$disk->{MODEL} |
86
|
11
|
|
|
|
|
38
|
); |
87
|
11
|
|
|
|
|
28
|
$disk->{device} = "/dev/sg$count"; |
88
|
|
|
|
|
|
|
|
89
|
11
|
|
|
|
|
45
|
push @disks, $disk; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
2
|
|
|
|
|
62
|
close $handle; |
93
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
17
|
return @disks; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |