line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::AIX::Storages; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
87187223
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
69
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
92
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
366
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
232
|
|
7
|
2
|
|
|
2
|
|
707
|
use FusionInventory::Agent::Tools::AIX; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
2038
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
11
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{storage}; |
12
|
|
|
|
|
|
|
return |
13
|
0
|
|
0
|
|
|
0
|
canRun('lsdev') && |
14
|
|
|
|
|
|
|
canRun('lsattr'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
18
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
21
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# index VPD infos by AX field |
24
|
0
|
|
|
|
|
0
|
my $infos = _getIndexedLsvpdInfos(logger => $logger); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks(logger => $logger, subclass => 'scsi', infos => $infos)) { |
27
|
0
|
|
|
|
|
0
|
$disk->{DISKSIZE} = _getCapacity($disk->{NAME}, $params{logger}); |
28
|
|
|
|
|
|
|
$disk->{SERIAL} = getFirstMatch( |
29
|
|
|
|
|
|
|
command => "lscfg -p -v -s -l $disk->{NAME}", |
30
|
|
|
|
|
|
|
logger => $params{logger}, |
31
|
0
|
|
|
|
|
0
|
pattern => qr/Serial Number\.*(.*)/ |
32
|
|
|
|
|
|
|
); |
33
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks(logger => $logger, subclass => 'fcp', infos => $infos)) { |
37
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks(logger => $logger, subclass => 'fdar', infos => $infos)) { |
41
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks(logger => $logger, subclass => 'sas', infos => $infos)) { |
45
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
foreach my $disk (_getDisks(logger => $logger, subclass => 'vscsi', infos => $infos)) { |
49
|
|
|
|
|
|
|
$disk->{DISKSIZE} = _getVirtualCapacity( |
50
|
|
|
|
|
|
|
name => $disk->{NAME}, |
51
|
|
|
|
|
|
|
logger => $params{logger} |
52
|
0
|
|
|
|
|
0
|
); |
53
|
0
|
|
|
|
|
0
|
$disk->{MANUFACTURER} = "VIO Disk"; |
54
|
0
|
|
|
|
|
0
|
$disk->{MODEL} = "Virtual Disk"; |
55
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $disk); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
foreach my $cdrom (_getCdroms(logger => $logger, infos => $infos)) { |
59
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $cdrom); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
foreach my $tape (_getTapes(logger => $logger, infos => $infos)) { |
63
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $tape); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
0
|
foreach my $floppy (_getFloppies(logger => $logger, infos => $infos)) { |
67
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'STORAGES', entry => $floppy); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _getIndexedLsvpdInfos { |
72
|
|
|
|
|
|
|
my %infos = |
73
|
49
|
|
|
|
|
66
|
map { $_->{AX} => $_ } |
74
|
2
|
|
|
2
|
|
479
|
grep { $_->{AX} } |
|
95
|
|
|
|
|
86
|
|
75
|
|
|
|
|
|
|
getLsvpdInfos(@_); |
76
|
|
|
|
|
|
|
|
77
|
2
|
|
|
|
|
9
|
return \%infos; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _getDisks { |
81
|
2
|
|
|
2
|
|
9
|
my (%params) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $command = $params{subclass} ? |
84
|
2
|
50
|
|
|
|
7
|
"lsdev -Cc disk -s $params{subclass} -F 'name:description'" : undef; |
85
|
|
|
|
|
|
|
|
86
|
2
|
|
|
|
|
10
|
my @disks = _parseLsdev( |
87
|
|
|
|
|
|
|
command => $command, |
88
|
|
|
|
|
|
|
pattern => qr/^(.+):(.+)/, |
89
|
|
|
|
|
|
|
@_ |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
2
|
|
|
|
|
5
|
foreach my $disk (@disks) { |
93
|
23
|
|
|
|
|
18
|
$disk->{TYPE} = 'disk'; |
94
|
|
|
|
|
|
|
|
95
|
23
|
|
|
|
|
26
|
my $info = $params{infos}->{$disk->{NAME}}; |
96
|
23
|
100
|
|
|
|
28
|
next unless $info; |
97
|
21
|
|
|
|
|
18
|
$disk->{MANUFACTURER} = _getManufacturer($info); |
98
|
21
|
|
|
|
|
21
|
$disk->{MODEL} = _getModel($info); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
8
|
return @disks; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub _getCdroms { |
105
|
0
|
|
|
0
|
|
0
|
my (%params) = @_; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
my @cdroms = _parseLsdev( |
108
|
|
|
|
|
|
|
command => "lsdev -Cc cdrom -s scsi -F 'name:description:status'", |
109
|
|
|
|
|
|
|
pattern => qr/^(.+):(.+):.+Available.+/, |
110
|
|
|
|
|
|
|
@_ |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
foreach my $cdrom (@cdroms) { |
114
|
0
|
|
|
|
|
0
|
$cdrom->{TYPE} = 'cd'; |
115
|
0
|
|
|
|
|
0
|
$cdrom->{DISKSIZE} = _getCapacity($cdrom->{NAME}, $params{logger}); |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
0
|
my $info = $params{infos}->{$cdrom->{NAME}}; |
118
|
0
|
0
|
|
|
|
0
|
next unless $info; |
119
|
0
|
|
|
|
|
0
|
$cdrom->{MANUFACTURER} = _getManufacturer($info); |
120
|
0
|
|
|
|
|
0
|
$cdrom->{MODEL} = _getModel($info); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
return @cdroms; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub _getTapes { |
127
|
0
|
|
|
0
|
|
0
|
my (%params) = @_; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
my @tapes = _parseLsdev( |
130
|
|
|
|
|
|
|
command => "lsdev -Cc tape -s scsi -F 'name:description:status'", |
131
|
|
|
|
|
|
|
pattern => qr/^(.+):(.+):.+Available.+/, |
132
|
|
|
|
|
|
|
@_ |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
0
|
foreach my $tape (@tapes) { |
136
|
0
|
|
|
|
|
0
|
$tape->{TYPE} = 'tape'; |
137
|
0
|
|
|
|
|
0
|
$tape->{DISKSIZE} = _getCapacity($tape->{NAME}, $params{logger}); |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
my $info = $params{infos}->{$tape->{NAME}}; |
140
|
0
|
0
|
|
|
|
0
|
next unless $info; |
141
|
0
|
|
|
|
|
0
|
$tape->{MANUFACTURER} = _getManufacturer($info); |
142
|
0
|
|
|
|
|
0
|
$tape->{MODEL} = _getModel($info); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
0
|
return @tapes; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub _getFloppies { |
149
|
0
|
|
|
0
|
|
0
|
my (%params) = @_; |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
0
|
my @floppies = _parseLsdev( |
152
|
|
|
|
|
|
|
command => "lsdev -Cc diskette -F 'name:description:status'", |
153
|
|
|
|
|
|
|
pattern => qr/^(.+):(.+):.+Available.+/, |
154
|
|
|
|
|
|
|
@_ |
155
|
|
|
|
|
|
|
); |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
0
|
foreach my $floppy (@floppies) { |
158
|
0
|
|
|
|
|
0
|
$floppy->{TYPE} = 'floppy'; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
0
|
return @floppies; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _parseLsdev { |
165
|
10
|
|
|
10
|
|
1437
|
my (%params) = @_; |
166
|
|
|
|
|
|
|
|
167
|
10
|
|
|
|
|
30
|
my $handle = getFileHandle(@_); |
168
|
10
|
50
|
|
|
|
21
|
return unless $handle; |
169
|
|
|
|
|
|
|
|
170
|
10
|
|
|
|
|
9
|
my @devices; |
171
|
|
|
|
|
|
|
|
172
|
10
|
|
|
|
|
144
|
while (my $line = <$handle>) { |
173
|
66
|
|
|
|
|
45
|
chomp $line; |
174
|
66
|
50
|
|
|
|
268
|
next unless $line =~ $params{pattern}; |
175
|
|
|
|
|
|
|
|
176
|
66
|
|
|
|
|
276
|
push @devices, { |
177
|
|
|
|
|
|
|
NAME => $1, |
178
|
|
|
|
|
|
|
DESCRIPTION => $2 |
179
|
|
|
|
|
|
|
}; |
180
|
|
|
|
|
|
|
} |
181
|
10
|
|
|
|
|
61
|
close $handle; |
182
|
|
|
|
|
|
|
|
183
|
10
|
|
|
|
|
53
|
return @devices; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub _getCapacity { |
187
|
0
|
|
|
0
|
|
0
|
my ($device, $logger) = @_; |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
0
|
return getLastLine( |
190
|
|
|
|
|
|
|
command => "lsattr -EOl $device -a 'size_in_mb'", |
191
|
|
|
|
|
|
|
logger => $logger |
192
|
|
|
|
|
|
|
); |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub _getVirtualCapacity { |
196
|
4
|
|
|
4
|
|
957
|
my (%params) = @_; |
197
|
|
|
|
|
|
|
|
198
|
4
|
50
|
|
|
|
10
|
my $command = $params{name} ? "lspv $params{name}" : undef; |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
my $capacity = getFirstMatch( |
201
|
|
|
|
|
|
|
command => $command, |
202
|
|
|
|
|
|
|
file => $params{file}, |
203
|
|
|
|
|
|
|
pattern => qr/TOTAL PPs: +\d+ \((\d+) megabytes\)/, |
204
|
|
|
|
|
|
|
logger => $params{logger} |
205
|
4
|
|
|
|
|
24
|
); |
206
|
|
|
|
|
|
|
|
207
|
4
|
|
|
|
|
12
|
return $capacity; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
sub _getManufacturer { |
211
|
21
|
|
|
21
|
|
18
|
my ($device) = @_; |
212
|
|
|
|
|
|
|
|
213
|
21
|
50
|
|
|
|
23
|
return unless $device; |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
return $device->{FN} ? |
216
|
21
|
50
|
|
|
|
36
|
"$device->{MF},FRU number :$device->{FN}" : |
217
|
|
|
|
|
|
|
"$device->{MF}" ; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub _getModel { |
221
|
21
|
|
|
21
|
|
14
|
my ($device) = @_; |
222
|
|
|
|
|
|
|
|
223
|
21
|
50
|
|
|
|
24
|
return unless $device; |
224
|
|
|
|
|
|
|
|
225
|
21
|
|
|
|
|
29
|
return $device->{TM}; |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
1; |