line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Jails; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
51942673
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
93
|
|
4
|
2
|
|
|
2
|
|
16
|
use warnings; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
153
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
674
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
953
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
0
|
return canRun('jls'); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub doInventory { |
13
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
16
|
0
|
|
|
|
|
0
|
my $logger = $params{logger}; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
0
|
foreach my $machine (_getVirtualMachines(logger => $logger)) { |
19
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
20
|
|
|
|
|
|
|
section => 'VIRTUALMACHINES', entry => $machine |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _getVirtualMachines { |
26
|
1
|
|
|
1
|
|
13
|
my (%params) = ( |
27
|
|
|
|
|
|
|
command => 'jls -n', |
28
|
|
|
|
|
|
|
@_ |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
7
|
my $handle = getFileHandle(%params); |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
4
|
return unless $handle; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
2
|
my @machines; |
36
|
1
|
|
|
|
|
14
|
while (my $line = <$handle>) { |
37
|
4
|
|
|
|
|
6
|
my $info; |
38
|
4
|
|
|
|
|
32
|
foreach my $item (split(' ', $line)) { |
39
|
116
|
100
|
|
|
|
345
|
next unless $item =~ /(\S+)=(\S+)/; |
40
|
68
|
|
|
|
|
193
|
$info->{$1} = $2; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $machine = { |
44
|
|
|
|
|
|
|
VMTYPE => 'jail', |
45
|
4
|
|
|
|
|
21
|
NAME => $info->{'host.hostname'}, |
46
|
|
|
|
|
|
|
STATUS => 'running' |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
34
|
push @machines, $machine; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
1
|
|
|
|
|
7
|
close $handle; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
7
|
return @machines; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |