line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::Vserver; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
42390072
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
75
|
|
4
|
1
|
|
|
1
|
|
13
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
423
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
683
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub isEnabled { |
9
|
0
|
|
|
0
|
0
|
|
return canRun('vserver'); |
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 (_getMachines( |
19
|
|
|
|
|
|
|
command => 'vserver-info', logger => $logger |
20
|
|
|
|
|
|
|
)) { |
21
|
0
|
|
|
|
|
|
$inventory->addEntry(section => 'VIRTUALMACHINES', entry => $machine); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _getMachines { |
26
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $handle = getFileHandle(%params); |
29
|
0
|
0
|
|
|
|
|
return unless $handle; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my $utilVserver; |
32
|
|
|
|
|
|
|
my $cfgDir; |
33
|
0
|
|
|
|
|
|
while (my $line = <$handle>) { |
34
|
0
|
0
|
|
|
|
|
$cfgDir = $1 if $line =~ /^\s+cfg-Directory:\s+(.*)$/; |
35
|
0
|
0
|
|
|
|
|
$utilVserver = $1 if $line =~ /^\s+util-vserver:\s+(.*)$/; |
36
|
|
|
|
|
|
|
} |
37
|
0
|
|
|
|
|
|
close $handle; |
38
|
|
|
|
|
|
|
|
39
|
0
|
0
|
|
|
|
|
return unless -d $cfgDir; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$handle = getDirectoryHandle(directory => $cfgDir, logger => $params{logger}); |
42
|
0
|
0
|
|
|
|
|
return unless $handle; |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my @machines; |
45
|
0
|
|
|
|
|
|
while (my $name = readdir($handle)) { |
46
|
0
|
0
|
|
|
|
|
next if $name =~ /^\./; |
47
|
0
|
0
|
|
|
|
|
next unless $name =~ /\S/; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $line = getFirstLine(command => "vserver $name status"); |
50
|
0
|
0
|
|
|
|
|
my $status = |
|
|
0
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$line =~ /is stopped/ ? 'off' : |
52
|
|
|
|
|
|
|
$line =~ /is running/ ? 'running' : |
53
|
|
|
|
|
|
|
undef ; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $machine = { |
56
|
|
|
|
|
|
|
NAME => $name, |
57
|
|
|
|
|
|
|
STATUS => $status, |
58
|
|
|
|
|
|
|
SUBSYSTEM => $utilVserver, |
59
|
|
|
|
|
|
|
VMTYPE => "vserver", |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
push @machines, $machine; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
|
close $handle; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return @machines; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |