line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::SolarisZones; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
37830499
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
97
|
|
4
|
1
|
|
|
1
|
|
11
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
701
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
155
|
|
7
|
1
|
|
|
1
|
|
627
|
use FusionInventory::Agent::Tools::Solaris; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
373
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub isEnabled { |
10
|
|
|
|
|
|
|
return |
11
|
0
|
|
0
|
0
|
0
|
|
canRun('zoneadm') && |
12
|
|
|
|
|
|
|
getZone() eq 'global' && |
13
|
|
|
|
|
|
|
_check_solaris_valid_release(); |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my @zones = |
23
|
|
|
|
|
|
|
getAllLines(command => '/usr/sbin/zoneadm list -p', logger => $logger); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach my $zone (@zones) { |
26
|
0
|
|
|
|
|
|
my ($zoneid, $zonename, $zonestatus, undef, $uuid) = split(/:/, $zone); |
27
|
0
|
0
|
|
|
|
|
next if $zonename eq 'global'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Memory considerations depends on rcapd or project definitions |
30
|
|
|
|
|
|
|
# Little hack, I go directly in /etc/zones reading mcap physcap for each zone. |
31
|
0
|
|
|
|
|
|
my $zonefile = "/etc/zones/$zonename.xml"; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $line = getFirstMatch( |
34
|
|
|
|
|
|
|
file => $zonefile, |
35
|
|
|
|
|
|
|
pattern => qr/(.*mcap.*)/ |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $memory; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ($line) { |
41
|
0
|
|
|
|
|
|
my $memcap = $line; |
42
|
0
|
|
|
|
|
|
$memcap =~ s/[^\d]+//g; |
43
|
0
|
|
|
|
|
|
$memory = $memcap / 1024 / 1024; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $vcpu = getFirstLine(command => '/usr/sbin/psrinfo -p'); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$inventory->addEntry( |
50
|
|
|
|
|
|
|
section => 'VIRTUALMACHINES', |
51
|
|
|
|
|
|
|
entry => { |
52
|
|
|
|
|
|
|
MEMORY => $memory, |
53
|
|
|
|
|
|
|
NAME => $zonename, |
54
|
|
|
|
|
|
|
UUID => $uuid, |
55
|
|
|
|
|
|
|
STATUS => $zonestatus, |
56
|
|
|
|
|
|
|
SUBSYSTEM => "Solaris Zones", |
57
|
|
|
|
|
|
|
VMTYPE => "Solaris Zones", |
58
|
|
|
|
|
|
|
VMID => $zoneid, |
59
|
|
|
|
|
|
|
VCPU => $vcpu, |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# check if Solaris 10 release is higher than 08/07 |
66
|
|
|
|
|
|
|
sub _check_solaris_valid_release{ |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
|
|
my $info = getReleaseInfo(); |
69
|
|
|
|
|
|
|
return |
70
|
0
|
|
0
|
|
|
|
$info->{version} > 10 |
71
|
|
|
|
|
|
|
|| |
72
|
|
|
|
|
|
|
$info->{version} == 10 && |
73
|
|
|
|
|
|
|
$info->{subversion} && |
74
|
|
|
|
|
|
|
substr($info->{subversion}, 1) >= 4; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |