line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::Storages; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
89661243
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
77
|
|
4
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
514
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
790
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
10
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{storage}; |
11
|
0
|
|
|
|
|
|
return canRun('iostat'); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub doInventory { |
15
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
18
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @storages = _getStorages( |
21
|
|
|
|
|
|
|
logger => $logger, command => 'iostat -En' |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
foreach my $storage (@storages) { |
25
|
0
|
0
|
|
|
|
|
if (-l "/dev/rdsk/$storage->{NAME}s2") { |
26
|
0
|
|
|
|
|
|
my $rdisk_path = getFirstLine( |
27
|
|
|
|
|
|
|
command => "ls -l /dev/rdsk/$storage->{NAME}s2" |
28
|
|
|
|
|
|
|
); |
29
|
0
|
0
|
|
|
|
|
$storage->{TYPE} = |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$rdisk_path =~ /->.*scsi_vhci/ ? 'MPxIO' : |
31
|
|
|
|
|
|
|
$rdisk_path =~ /->.*fp@/ ? 'FC' : |
32
|
|
|
|
|
|
|
$rdisk_path =~ /->.*scsi@/ ? 'SCSI' : |
33
|
|
|
|
|
|
|
undef ; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$inventory->addEntry(section => 'STORAGES', entry => $storage); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _getStorages { |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
|
|
my $handle = getFileHandle(@_); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
return unless $handle; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my @storages; |
47
|
|
|
|
|
|
|
my $storage; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
50
|
0
|
0
|
|
|
|
|
if ($line =~ /^(\S+)\s+Soft/) { |
51
|
0
|
|
|
|
|
|
$storage->{NAME} = $1; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
0
|
|
|
|
|
if ($line =~ /^ |
54
|
|
|
|
|
|
|
Vendor: \s (\S+) \s+ |
55
|
|
|
|
|
|
|
Product: \s (\S.*?\S) \s+ |
56
|
|
|
|
|
|
|
Revision: \s (\S+) \s+ |
57
|
|
|
|
|
|
|
Serial \s No: \s (\S*) |
58
|
|
|
|
|
|
|
/x) { |
59
|
0
|
|
|
|
|
|
$storage->{MANUFACTURER} = $1; |
60
|
0
|
|
|
|
|
|
$storage->{MODEL} = $2; |
61
|
0
|
|
|
|
|
|
$storage->{FIRMWARE} = $3; |
62
|
0
|
0
|
|
|
|
|
$storage->{SERIALNUMBER} = $4 if $4; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
0
|
|
|
|
|
if ($line =~ /<(\d+) bytes/) { |
65
|
0
|
|
|
|
|
|
$storage->{DISKSIZE} = int($1/(1000*1000)); |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
|
if ($line =~ /^Illegal/) { # Last ligne |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## To be removed when SERIALNUMBER will be supported |
70
|
0
|
0
|
|
|
|
|
if ($storage->{SERIALNUMBER}) { |
71
|
0
|
0
|
|
|
|
|
$storage->{DESCRIPTION} = $storage->{DESCRIPTION} ? |
72
|
|
|
|
|
|
|
$storage->{DESCRIPTION} . " S/N:" . $storage->{SERIALNUMBER} : |
73
|
|
|
|
|
|
|
"S/N:" . $storage->{SERIALNUMBER} ; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
## To be removed when FIRMWARE will be supported |
78
|
0
|
0
|
|
|
|
|
if ($storage->{FIRMWARE}) { |
79
|
0
|
0
|
|
|
|
|
$storage->{DESCRIPTION} = $storage->{DESCRIPTION} ? |
80
|
|
|
|
|
|
|
$storage->{DESCRIPTION} . " FW:" . $storage->{FIRMWARE} : |
81
|
|
|
|
|
|
|
"FW:" . $storage->{FIRMWARE} ; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ($storage->{MANUFACTURER}) { |
85
|
|
|
|
|
|
|
## Workaround for MANUFACTURER == ATA case |
86
|
0
|
0
|
0
|
|
|
|
if ( |
87
|
|
|
|
|
|
|
$storage->{MANUFACTURER} eq 'ATA' && |
88
|
|
|
|
|
|
|
$storage->{MODEL} =~ /^(Hitachi|Seagate|INTEL) (.+)/i) { |
89
|
0
|
|
|
|
|
|
$storage->{MANUFACTURER} = $1; |
90
|
0
|
|
|
|
|
|
$storage->{MODEL} = $2; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
## Drop the (R) from the manufacturer string |
94
|
0
|
|
|
|
|
|
$storage->{MANUFACTURER} =~ s/\(R\)$//i; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
push @storages, $storage; |
99
|
0
|
|
|
|
|
|
undef $storage; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
0
|
|
|
|
|
|
close $handle; |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
return @storages; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |