line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Linux::LVM; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
49219304
|
use strict; |
|
2
|
|
|
|
|
27
|
|
|
2
|
|
|
|
|
118
|
|
4
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
165
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
24
|
use English qw(-no_match_vars); |
|
2
|
|
|
|
|
120
|
|
|
2
|
|
|
|
|
39
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
3187
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1582
|
|
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('lvs'); |
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 (_getLogicalVolumes(logger => $logger)) { |
23
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'LOGICAL_VOLUMES', entry => $volume); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
0
|
foreach my $volume (_getPhysicalVolumes(logger => $logger)) { |
27
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'PHYSICAL_VOLUMES', entry => $volume); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
foreach my $group (_getVolumeGroups(logger => $logger)) { |
31
|
0
|
|
|
|
|
0
|
$inventory->addEntry(section => 'VOLUME_GROUPS', entry => $group); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _getLogicalVolumes { |
36
|
1
|
|
|
1
|
|
324
|
my (%params) = ( |
37
|
|
|
|
|
|
|
command => 'lvs -a --noheading --nosuffix --units M -o lv_name,vg_uuid,lv_attr,lv_size,lv_uuid,seg_count', |
38
|
|
|
|
|
|
|
@_ |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
6
|
my $handle = getFileHandle(%params); |
42
|
1
|
50
|
|
|
|
5
|
return unless $handle; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
1
|
my @volumes; |
45
|
1
|
|
|
|
|
14
|
while (my $line = <$handle>) { |
46
|
8
|
|
|
|
|
46
|
my @infos = split(/\s+/, $line); |
47
|
|
|
|
|
|
|
|
48
|
8
|
|
50
|
|
|
78
|
push @volumes, { |
49
|
|
|
|
|
|
|
LV_NAME => $infos[1], |
50
|
|
|
|
|
|
|
VG_UUID => $infos[2], |
51
|
|
|
|
|
|
|
ATTR => $infos[3], |
52
|
|
|
|
|
|
|
SIZE => int($infos[4]||0), |
53
|
|
|
|
|
|
|
LV_UUID => $infos[5], |
54
|
|
|
|
|
|
|
SEG_COUNT => $infos[6], |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
|
|
9
|
close $handle; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
8
|
return @volumes; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _getPhysicalVolumes { |
64
|
3
|
|
|
3
|
|
589
|
my (%params) = ( |
65
|
|
|
|
|
|
|
command => 'pvs --noheading --nosuffix --units M -o pv_name,pv_fmt,pv_attr,pv_size,pv_free,pv_uuid,pv_pe_count,vg_uuid', |
66
|
|
|
|
|
|
|
@_ |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
15
|
my $handle = getFileHandle(%params); |
70
|
3
|
50
|
|
|
|
9
|
return unless $handle; |
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
5
|
my @volumes; |
73
|
3
|
|
|
|
|
36
|
while (my $line = <$handle>) { |
74
|
9
|
|
|
|
|
67
|
my @infos = split(/\s+/, $line); |
75
|
|
|
|
|
|
|
|
76
|
9
|
|
|
|
|
11
|
my $pe_size; |
77
|
9
|
50
|
33
|
|
|
49
|
if ($infos[7] && $infos[7]>0) { |
78
|
9
|
|
|
|
|
26
|
$pe_size = int($infos[4] / $infos[7]); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
9
|
|
50
|
|
|
122
|
push @volumes, { |
|
|
|
100
|
|
|
|
|
82
|
|
|
|
|
|
|
DEVICE => $infos[1], |
83
|
|
|
|
|
|
|
FORMAT => $infos[2], |
84
|
|
|
|
|
|
|
ATTR => $infos[3], |
85
|
|
|
|
|
|
|
SIZE => int($infos[4]||0), |
86
|
|
|
|
|
|
|
FREE => int($infos[5]||0), |
87
|
|
|
|
|
|
|
PV_UUID => $infos[6], |
88
|
|
|
|
|
|
|
PV_PE_COUNT => $infos[7], |
89
|
|
|
|
|
|
|
PE_SIZE => $pe_size, |
90
|
|
|
|
|
|
|
VG_UUID => $infos[8] |
91
|
|
|
|
|
|
|
}; |
92
|
|
|
|
|
|
|
} |
93
|
3
|
|
|
|
|
23
|
close $handle; |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
19
|
return @volumes; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _getVolumeGroups { |
99
|
3
|
|
|
3
|
|
856
|
my (%params) = ( |
100
|
|
|
|
|
|
|
command => 'vgs --noheading --nosuffix --units M -o vg_name,pv_count,lv_count,vg_attr,vg_size,vg_free,vg_uuid,vg_extent_size', |
101
|
|
|
|
|
|
|
@_ |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
3
|
|
|
|
|
13
|
my $handle = getFileHandle(%params); |
105
|
3
|
50
|
|
|
|
11
|
return unless $handle; |
106
|
|
|
|
|
|
|
|
107
|
3
|
|
|
|
|
4
|
my @groups; |
108
|
3
|
|
|
|
|
37
|
while (my $line = <$handle>) { |
109
|
5
|
|
|
|
|
42
|
my @infos = split(/\s+/, $line); |
110
|
|
|
|
|
|
|
|
111
|
5
|
|
50
|
|
|
83
|
push @groups, { |
|
|
|
100
|
|
|
|
|
112
|
|
|
|
|
|
|
VG_NAME => $infos[1], |
113
|
|
|
|
|
|
|
PV_COUNT => $infos[2], |
114
|
|
|
|
|
|
|
LV_COUNT => $infos[3], |
115
|
|
|
|
|
|
|
ATTR => $infos[4], |
116
|
|
|
|
|
|
|
SIZE => int($infos[5]||0), |
117
|
|
|
|
|
|
|
FREE => int($infos[6]||0), |
118
|
|
|
|
|
|
|
VG_UUID => $infos[7], |
119
|
|
|
|
|
|
|
VG_EXTENT_SIZE => $infos[8], |
120
|
|
|
|
|
|
|
}; |
121
|
|
|
|
|
|
|
} |
122
|
3
|
|
|
|
|
57
|
close $handle; |
123
|
|
|
|
|
|
|
|
124
|
3
|
|
|
|
|
18
|
return @groups; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; |