line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Jails; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
45111142
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
68
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
356
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
579
|
|
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
|
|
10
|
my (%params) = ( |
27
|
|
|
|
|
|
|
command => 'jls -n', |
28
|
|
|
|
|
|
|
@_ |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
my $handle = getFileHandle(%params); |
32
|
|
|
|
|
|
|
|
33
|
1
|
50
|
|
|
|
2
|
return unless $handle; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
1
|
my @machines; |
36
|
1
|
|
|
|
|
9
|
while (my $line = <$handle>) { |
37
|
4
|
|
|
|
|
4
|
my $info; |
38
|
4
|
|
|
|
|
19
|
foreach my $item (split(' ', $line)) { |
39
|
116
|
100
|
|
|
|
188
|
next unless $item =~ /(\S+)=(\S+)/; |
40
|
68
|
|
|
|
|
92
|
$info->{$1} = $2; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $machine = { |
44
|
|
|
|
|
|
|
VMTYPE => 'jail', |
45
|
4
|
|
|
|
|
13
|
NAME => $info->{'host.hostname'}, |
46
|
|
|
|
|
|
|
STATUS => 'running' |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
19
|
push @machines, $machine; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
} |
52
|
1
|
|
|
|
|
5
|
close $handle; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
5
|
return @machines; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |