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