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