line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::AIX::LVM; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
88946248
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
282
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
29
|
|
6
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
7
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
12
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{lvm}; |
13
|
0
|
|
|
|
|
0
|
return canRun('lspv'); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
foreach my $volume (_getPhysicalVolumes($logger)) { |
23
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'PHYSICAL_VOLUMES', entry => $volume); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
foreach my $group (_getVolumeGroups($logger)) { |
27
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'VOLUME_GROUPS', entry => $group); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
foreach my $volume (_getLogicalVolumes($logger, $group->{VG_NAME})) { |
30
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'LOGICAL_VOLUMES', entry => $volume); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _getLogicalVolumes { |
36
|
0
|
|
|
0
|
|
0
|
my ($logger, $group) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $handle = getFileHandle( |
39
|
|
|
|
|
|
|
command => "lsvg -l $group", |
40
|
|
|
|
|
|
|
logger => $logger |
41
|
|
|
|
|
|
|
); |
42
|
0
|
0
|
|
|
|
0
|
return unless $handle; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# skip headers |
45
|
0
|
|
|
|
|
0
|
my $line; |
46
|
0
|
|
|
|
|
0
|
$line = <$handle>; |
47
|
0
|
|
|
|
|
0
|
$line = <$handle>; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# no logical volume if there is only one line of output |
50
|
0
|
0
|
|
|
|
0
|
return unless $line; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
my @volumes; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
0
|
while (my $line = <$handle>) { |
55
|
0
|
|
|
|
|
0
|
chomp $line; |
56
|
0
|
|
|
|
|
0
|
my ($name) = split(/\s+/, $line); |
57
|
0
|
|
|
|
|
0
|
push @volumes, _getLogicalVolume(logger => $logger, name => $name); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
close $handle; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
return @volumes; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _getLogicalVolume { |
66
|
17
|
|
|
17
|
|
4640
|
my (%params) = @_; |
67
|
|
|
|
|
|
|
|
68
|
17
|
50
|
|
|
|
41
|
my $command = $params{name} ? "lslv $params{name}" : undef; |
69
|
17
|
|
|
|
|
49
|
my $handle = getFileHandle(command => $command, %params); |
70
|
17
|
50
|
|
|
|
29
|
return unless $handle; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $volume = { |
73
|
|
|
|
|
|
|
LV_NAME => $params{name} |
74
|
17
|
|
|
|
|
31
|
}; |
75
|
|
|
|
|
|
|
|
76
|
17
|
|
|
|
|
16
|
my $size; |
77
|
17
|
|
|
|
|
147
|
while (my $line = <$handle>) { |
78
|
238
|
100
|
|
|
|
320
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
79
|
17
|
|
|
|
|
20
|
$size = $1; |
80
|
|
|
|
|
|
|
} |
81
|
238
|
100
|
|
|
|
289
|
if ($line =~ /^LV IDENTIFIER:\s+(\S+)/) { |
82
|
17
|
|
|
|
|
38
|
$volume->{LV_UUID} = $1; |
83
|
|
|
|
|
|
|
} |
84
|
238
|
100
|
|
|
|
261
|
if ($line =~ /^LPs:\s+(\S+)/) { |
85
|
17
|
|
|
|
|
25
|
$volume->{SEG_COUNT} = $1; |
86
|
|
|
|
|
|
|
} |
87
|
238
|
100
|
|
|
|
489
|
if ($line =~ /^TYPE:\s+(\S+)/) { |
88
|
17
|
|
|
|
|
52
|
$volume->{ATTR} = "Type $1", |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
17
|
|
|
|
|
86
|
close $handle; |
92
|
|
|
|
|
|
|
|
93
|
17
|
|
|
|
|
32
|
$volume->{SIZE} = $volume->{SEG_COUNT} * $size; |
94
|
|
|
|
|
|
|
|
95
|
17
|
|
|
|
|
56
|
return $volume; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _getPhysicalVolumes { |
99
|
0
|
|
|
0
|
|
0
|
my ($logger) = @_; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
0
|
my $handle = getFileHandle( |
102
|
|
|
|
|
|
|
command => 'lspv', |
103
|
|
|
|
|
|
|
logger => $logger |
104
|
|
|
|
|
|
|
); |
105
|
0
|
0
|
|
|
|
0
|
return unless $handle; |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
my @volumes; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
0
|
while (my $line = <$handle>) { |
110
|
0
|
|
|
|
|
0
|
chomp $line; |
111
|
0
|
|
|
|
|
0
|
my ($name) = split(/\s+/, $line); |
112
|
0
|
|
|
|
|
0
|
push @volumes, _getPhysicalVolume(logger => $logger, name => $name); |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
0
|
close $handle; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
0
|
return @volumes; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _getPhysicalVolume { |
120
|
4
|
|
|
4
|
|
839
|
my (%params) = @_; |
121
|
|
|
|
|
|
|
|
122
|
4
|
50
|
|
|
|
11
|
my $command = $params{name} ? "lspv $params{name}" : undef; |
123
|
4
|
|
|
|
|
10
|
my $handle = getFileHandle(command => $command, %params); |
124
|
4
|
50
|
|
|
|
8
|
return unless $handle; |
125
|
|
|
|
|
|
|
|
126
|
4
|
|
|
|
|
10
|
my $volume = { |
127
|
|
|
|
|
|
|
DEVICE => "/dev/$params{name}" |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
3
|
my ($free, $total); |
131
|
4
|
|
|
|
|
38
|
while (my $line = <$handle>) { |
132
|
45
|
|
|
|
|
36
|
chomp $line; |
133
|
|
|
|
|
|
|
|
134
|
45
|
100
|
|
|
|
66
|
if ($line =~ /PHYSICAL VOLUME:\s+(\S+)/) { |
135
|
4
|
|
|
|
|
7
|
$volume->{FORMAT} = "AIX PV"; |
136
|
|
|
|
|
|
|
} |
137
|
45
|
100
|
|
|
|
56
|
if ($line =~ /FREE PPs:\s+(\d+)/) { |
138
|
3
|
|
|
|
|
3
|
$free = $1; |
139
|
|
|
|
|
|
|
} |
140
|
45
|
100
|
|
|
|
60
|
if ($line =~ /TOTAL PPs:\s+(\d+)/) { |
141
|
3
|
|
|
|
|
4
|
$total = $1; |
142
|
|
|
|
|
|
|
} |
143
|
45
|
100
|
|
|
|
61
|
if ($line =~ /VOLUME GROUP:\s+(\S+)/) { |
144
|
4
|
|
|
|
|
11
|
$volume->{ATTR} = "VG $1"; |
145
|
|
|
|
|
|
|
} |
146
|
45
|
100
|
|
|
|
58
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
147
|
3
|
|
|
|
|
5
|
$volume->{PE_SIZE} = $1; |
148
|
|
|
|
|
|
|
} |
149
|
45
|
100
|
|
|
|
109
|
if ($line =~ /PV IDENTIFIER:\s+(\S+)/) { |
150
|
4
|
|
|
|
|
12
|
$volume->{PV_UUID} = $1; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
4
|
|
|
|
|
20
|
close $handle; |
154
|
|
|
|
|
|
|
|
155
|
4
|
100
|
|
|
|
9
|
if (defined $volume->{PE_SIZE}) { |
156
|
3
|
50
|
|
|
|
8
|
$volume->{SIZE} = $total * $volume->{PE_SIZE} if defined $total; |
157
|
3
|
50
|
|
|
|
7
|
$volume->{FREE} = $free * $volume->{PE_SIZE} if defined $free; |
158
|
|
|
|
|
|
|
} |
159
|
4
|
100
|
|
|
|
8
|
$volume->{PV_PE_COUNT} = $total if defined $total; |
160
|
|
|
|
|
|
|
|
161
|
4
|
|
|
|
|
17
|
return $volume; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _getVolumeGroups { |
165
|
0
|
|
|
0
|
|
0
|
my ($logger) = @_; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
0
|
my $handle = getFileHandle( |
168
|
|
|
|
|
|
|
command => 'lsvg', |
169
|
|
|
|
|
|
|
logger => $logger |
170
|
|
|
|
|
|
|
); |
171
|
0
|
0
|
|
|
|
0
|
return unless $handle; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
my @groups; |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
while (my $line = <$handle>) { |
176
|
0
|
|
|
|
|
0
|
chomp $line; |
177
|
0
|
|
|
|
|
0
|
push @groups, _getVolumeGroup(logger => $logger, name => $line); |
178
|
|
|
|
|
|
|
} |
179
|
0
|
|
|
|
|
0
|
close $handle; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
0
|
return @groups; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub _getVolumeGroup { |
185
|
1
|
|
|
1
|
|
271
|
my (%params) = @_; |
186
|
|
|
|
|
|
|
|
187
|
1
|
50
|
|
|
|
4
|
my $command = $params{name} ? "lsvg $params{name}" : undef; |
188
|
1
|
|
|
|
|
4
|
my $handle = getFileHandle(command => $command, %params); |
189
|
1
|
50
|
|
|
|
3
|
return unless $handle; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $group = { |
192
|
|
|
|
|
|
|
VG_NAME => $params{name} |
193
|
1
|
|
|
|
|
3
|
}; |
194
|
|
|
|
|
|
|
|
195
|
1
|
|
|
|
|
10
|
while (my $line = <$handle>) { |
196
|
13
|
|
|
|
|
8
|
chomp $line; |
197
|
|
|
|
|
|
|
|
198
|
13
|
100
|
|
|
|
17
|
if ($line =~ /TOTAL PPs:\s+(\d+)/) { |
199
|
1
|
|
|
|
|
2
|
$group->{SIZE} = $1; |
200
|
|
|
|
|
|
|
} |
201
|
13
|
100
|
|
|
|
19
|
if ($line =~ /FREE PPs:\s+(\d+)/) { |
202
|
1
|
|
|
|
|
1
|
$group->{FREE} = $1; |
203
|
|
|
|
|
|
|
} |
204
|
13
|
100
|
|
|
|
19
|
if ($line =~ /VG IDENTIFIER:\s+(\S+)/) { |
205
|
1
|
|
|
|
|
3
|
$group->{VG_UUID} = $1; |
206
|
|
|
|
|
|
|
} |
207
|
13
|
100
|
|
|
|
21
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
208
|
1
|
|
|
|
|
2
|
$group->{VG_EXTENT_SIZE} = $1; |
209
|
|
|
|
|
|
|
} |
210
|
13
|
100
|
|
|
|
17
|
if ($line =~ /LVs:\s+(\d+)/) { |
211
|
3
|
|
|
|
|
3
|
$group->{LV_COUNT} = $1; |
212
|
|
|
|
|
|
|
} |
213
|
13
|
100
|
|
|
|
34
|
if ($line =~/ACTIVE PVs:\s+(\d+)/) { |
214
|
1
|
|
|
|
|
2
|
$group->{PV_COUNT} = $1; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
} |
218
|
1
|
|
|
|
|
5
|
close $handle; |
219
|
|
|
|
|
|
|
|
220
|
1
|
|
|
|
|
4
|
return $group; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; |