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