line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Solaris::Storages; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
118084008
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
85
|
|
4
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
197
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
766
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1922
|
|
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
|
|
1069
|
my $handle = getFileHandle(@_); |
43
|
|
|
|
|
|
|
|
44
|
4
|
50
|
|
|
|
11
|
return unless $handle; |
45
|
|
|
|
|
|
|
|
46
|
4
|
|
|
|
|
5
|
my @storages; |
47
|
|
|
|
|
|
|
my $storage; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
109
|
while (my $line = <$handle>) { |
50
|
1066
|
100
|
|
|
|
2465
|
if ($line =~ /^(\S+)\s+Soft/) { |
51
|
214
|
|
|
|
|
601
|
$storage->{NAME} = $1; |
52
|
|
|
|
|
|
|
} |
53
|
1066
|
100
|
|
|
|
2772
|
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
|
|
|
|
|
457
|
$storage->{MANUFACTURER} = $1; |
60
|
214
|
|
|
|
|
430
|
$storage->{MODEL} = $2; |
61
|
214
|
|
|
|
|
426
|
$storage->{FIRMWARE} = $3; |
62
|
214
|
100
|
|
|
|
477
|
$storage->{SERIALNUMBER} = $4 if $4; |
63
|
|
|
|
|
|
|
} |
64
|
1066
|
100
|
|
|
|
2430
|
if ($line =~ /<(\d+) bytes/) { |
65
|
214
|
|
|
|
|
557
|
$storage->{DISKSIZE} = int($1/(1000*1000)); |
66
|
|
|
|
|
|
|
} |
67
|
1066
|
100
|
|
|
|
3800
|
if ($line =~ /^Illegal/) { # Last ligne |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
## To be removed when SERIALNUMBER will be supported |
70
|
214
|
100
|
|
|
|
433
|
if ($storage->{SERIALNUMBER}) { |
71
|
|
|
|
|
|
|
$storage->{DESCRIPTION} = $storage->{DESCRIPTION} ? |
72
|
|
|
|
|
|
|
$storage->{DESCRIPTION} . " S/N:" . $storage->{SERIALNUMBER} : |
73
|
1
|
50
|
|
|
|
7
|
"S/N:" . $storage->{SERIALNUMBER} ; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
## To be removed when FIRMWARE will be supported |
78
|
214
|
50
|
|
|
|
432
|
if ($storage->{FIRMWARE}) { |
79
|
|
|
|
|
|
|
$storage->{DESCRIPTION} = $storage->{DESCRIPTION} ? |
80
|
|
|
|
|
|
|
$storage->{DESCRIPTION} . " FW:" . $storage->{FIRMWARE} : |
81
|
214
|
100
|
|
|
|
621
|
"FW:" . $storage->{FIRMWARE} ; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
214
|
50
|
|
|
|
436
|
if ($storage->{MANUFACTURER}) { |
85
|
|
|
|
|
|
|
## Workaround for MANUFACTURER == ATA case |
86
|
214
|
100
|
66
|
|
|
1257
|
if ( |
87
|
|
|
|
|
|
|
$storage->{MANUFACTURER} eq 'ATA' && |
88
|
|
|
|
|
|
|
$storage->{MODEL} =~ /^(Hitachi|Seagate|INTEL) (.+)/i) { |
89
|
204
|
|
|
|
|
344
|
$storage->{MANUFACTURER} = $1; |
90
|
204
|
|
|
|
|
367
|
$storage->{MODEL} = $2; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
## Drop the (R) from the manufacturer string |
94
|
214
|
|
|
|
|
467
|
$storage->{MANUFACTURER} =~ s/\(R\)$//i; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
214
|
|
|
|
|
278
|
push @storages, $storage; |
99
|
214
|
|
|
|
|
722
|
undef $storage; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
4
|
|
|
|
|
75
|
close $handle; |
103
|
|
|
|
|
|
|
|
104
|
4
|
|
|
|
|
56
|
return @storages; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |