line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Virtualization::SolarisZones; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
49892168
|
use strict; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
60
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
687
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
204
|
|
7
|
1
|
|
|
1
|
|
731
|
use FusionInventory::Agent::Tools::Solaris; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
431
|
|
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
|
|
|
|
|
|
|
VCPU => $vcpu, |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# check if Solaris 10 release is higher than 08/07 |
65
|
|
|
|
|
|
|
sub _check_solaris_valid_release{ |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
0
|
|
|
my $info = getReleaseInfo(); |
68
|
|
|
|
|
|
|
return |
69
|
|
|
|
|
|
|
$info->{version} > 10 |
70
|
|
|
|
|
|
|
|| |
71
|
|
|
|
|
|
|
$info->{version} == 10 && |
72
|
|
|
|
|
|
|
$info->{subversion} && |
73
|
0
|
|
0
|
|
|
|
substr($info->{subversion}, 1) >= 4; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |