| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::AIX::LVM; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
106723031
|
use FusionInventory::Agent::Tools; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
391
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
39
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
53
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use English qw(-no_match_vars); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
17
|
|
|
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
|
|
7054
|
my (%params) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
17
|
50
|
|
|
|
60
|
my $command = $params{name} ? "lslv $params{name}" : undef; |
|
69
|
17
|
|
|
|
|
68
|
my $handle = getFileHandle(command => $command, %params); |
|
70
|
17
|
50
|
|
|
|
43
|
return unless $handle; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
my $volume = { |
|
73
|
|
|
|
|
|
|
LV_NAME => $params{name} |
|
74
|
17
|
|
|
|
|
52
|
}; |
|
75
|
|
|
|
|
|
|
|
|
76
|
17
|
|
|
|
|
25
|
my $size; |
|
77
|
17
|
|
|
|
|
226
|
while (my $line = <$handle>) { |
|
78
|
238
|
100
|
|
|
|
511
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
|
79
|
17
|
|
|
|
|
33
|
$size = $1; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
238
|
100
|
|
|
|
498
|
if ($line =~ /^LV IDENTIFIER:\s+(\S+)/) { |
|
82
|
17
|
|
|
|
|
57
|
$volume->{LV_UUID} = $1; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
238
|
100
|
|
|
|
498
|
if ($line =~ /^LPs:\s+(\S+)/) { |
|
85
|
17
|
|
|
|
|
46
|
$volume->{SEG_COUNT} = $1; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
238
|
100
|
|
|
|
918
|
if ($line =~ /^TYPE:\s+(\S+)/) { |
|
88
|
17
|
|
|
|
|
84
|
$volume->{ATTR} = "Type $1", |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
17
|
|
|
|
|
189
|
close $handle; |
|
92
|
|
|
|
|
|
|
|
|
93
|
17
|
|
|
|
|
47
|
$volume->{SIZE} = $volume->{SEG_COUNT} * $size; |
|
94
|
|
|
|
|
|
|
|
|
95
|
17
|
|
|
|
|
80
|
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
|
|
1265
|
my (%params) = @_; |
|
121
|
|
|
|
|
|
|
|
|
122
|
4
|
50
|
|
|
|
15
|
my $command = $params{name} ? "lspv $params{name}" : undef; |
|
123
|
4
|
|
|
|
|
19
|
my $handle = getFileHandle(command => $command, %params); |
|
124
|
4
|
50
|
|
|
|
12
|
return unless $handle; |
|
125
|
|
|
|
|
|
|
|
|
126
|
4
|
|
|
|
|
16
|
my $volume = { |
|
127
|
|
|
|
|
|
|
DEVICE => "/dev/$params{name}" |
|
128
|
|
|
|
|
|
|
}; |
|
129
|
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
7
|
my ($free, $total); |
|
131
|
4
|
|
|
|
|
61
|
while (my $line = <$handle>) { |
|
132
|
45
|
|
|
|
|
56
|
chomp $line; |
|
133
|
|
|
|
|
|
|
|
|
134
|
45
|
100
|
|
|
|
104
|
if ($line =~ /PHYSICAL VOLUME:\s+(\S+)/) { |
|
135
|
4
|
|
|
|
|
10
|
$volume->{FORMAT} = "AIX PV"; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
45
|
100
|
|
|
|
97
|
if ($line =~ /FREE PPs:\s+(\d+)/) { |
|
138
|
3
|
|
|
|
|
7
|
$free = $1; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
45
|
100
|
|
|
|
89
|
if ($line =~ /TOTAL PPs:\s+(\d+)/) { |
|
141
|
3
|
|
|
|
|
7
|
$total = $1; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
45
|
100
|
|
|
|
99
|
if ($line =~ /VOLUME GROUP:\s+(\S+)/) { |
|
144
|
4
|
|
|
|
|
14
|
$volume->{ATTR} = "VG $1"; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
45
|
100
|
|
|
|
97
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
|
147
|
3
|
|
|
|
|
8
|
$volume->{PE_SIZE} = $1; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
45
|
100
|
|
|
|
183
|
if ($line =~ /PV IDENTIFIER:\s+(\S+)/) { |
|
150
|
4
|
|
|
|
|
20
|
$volume->{PV_UUID} = $1; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
} |
|
153
|
4
|
|
|
|
|
29
|
close $handle; |
|
154
|
|
|
|
|
|
|
|
|
155
|
4
|
100
|
|
|
|
15
|
if (defined $volume->{PE_SIZE}) { |
|
156
|
3
|
50
|
|
|
|
13
|
$volume->{SIZE} = $total * $volume->{PE_SIZE} if defined $total; |
|
157
|
3
|
50
|
|
|
|
10
|
$volume->{FREE} = $free * $volume->{PE_SIZE} if defined $free; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
4
|
100
|
|
|
|
12
|
$volume->{PV_PE_COUNT} = $total if defined $total; |
|
160
|
|
|
|
|
|
|
|
|
161
|
4
|
|
|
|
|
21
|
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
|
|
481
|
my (%params) = @_; |
|
186
|
|
|
|
|
|
|
|
|
187
|
1
|
50
|
|
|
|
8
|
my $command = $params{name} ? "lsvg $params{name}" : undef; |
|
188
|
1
|
|
|
|
|
6
|
my $handle = getFileHandle(command => $command, %params); |
|
189
|
1
|
50
|
|
|
|
6
|
return unless $handle; |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $group = { |
|
192
|
|
|
|
|
|
|
VG_NAME => $params{name} |
|
193
|
1
|
|
|
|
|
4
|
}; |
|
194
|
|
|
|
|
|
|
|
|
195
|
1
|
|
|
|
|
22
|
while (my $line = <$handle>) { |
|
196
|
13
|
|
|
|
|
17
|
chomp $line; |
|
197
|
|
|
|
|
|
|
|
|
198
|
13
|
100
|
|
|
|
32
|
if ($line =~ /TOTAL PPs:\s+(\d+)/) { |
|
199
|
1
|
|
|
|
|
4
|
$group->{SIZE} = $1; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
13
|
100
|
|
|
|
32
|
if ($line =~ /FREE PPs:\s+(\d+)/) { |
|
202
|
1
|
|
|
|
|
3
|
$group->{FREE} = $1; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
13
|
100
|
|
|
|
29
|
if ($line =~ /VG IDENTIFIER:\s+(\S+)/) { |
|
205
|
1
|
|
|
|
|
5
|
$group->{VG_UUID} = $1; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
13
|
100
|
|
|
|
30
|
if ($line =~ /PP SIZE:\s+(\d+)/) { |
|
208
|
1
|
|
|
|
|
4
|
$group->{VG_EXTENT_SIZE} = $1; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
13
|
100
|
|
|
|
32
|
if ($line =~ /LVs:\s+(\d+)/) { |
|
211
|
3
|
|
|
|
|
7
|
$group->{LV_COUNT} = $1; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
13
|
100
|
|
|
|
57
|
if ($line =~/ACTIVE PVs:\s+(\d+)/) { |
|
214
|
1
|
|
|
|
|
5
|
$group->{PV_COUNT} = $1; |
|
215
|
|
|
|
|
|
|
} |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
} |
|
218
|
1
|
|
|
|
|
8
|
close $handle; |
|
219
|
|
|
|
|
|
|
|
|
220
|
1
|
|
|
|
|
6
|
return $group; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; |