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