/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/Virtualization/SolarisZones.pm is in fusioninventory-agent 1:2.3.10.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | package FusionInventory::Agent::Task::Inventory::Virtualization::SolarisZones;
use strict;
use warnings;
use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Solaris;
sub isEnabled {
return
canRun('zoneadm') &&
getZone() eq 'global' &&
_check_solaris_valid_release('/etc/release');
}
sub doInventory {
my (%params) = @_;
my $inventory = $params{inventory};
my $logger = $params{logger};
my @zones =
getAllLines(command => '/usr/sbin/zoneadm list -p', logger => $logger);
foreach my $zone (@zones) {
my ($zoneid, $zonename, $zonestatus, undef, $uuid) = split(/:/, $zone);
next if $zonename eq 'global';
# Memory considerations depends on rcapd or project definitions
# Little hack, I go directly in /etc/zones reading mcap physcap for each zone.
my $zonefile = "/etc/zones/$zonename.xml";
my $line = getFirstMatch(
file => $zonefile,
pattern => qr/(.*mcap.*)/
);
my $memory;
if ($line) {
my $memcap = $line;
$memcap =~ s/[^\d]+//g;
$memory = $memcap / 1024 / 1024;
}
my $vcpu = getFirstLine(command => '/usr/sbin/psrinfo -p');
$inventory->addEntry(
section => 'VIRTUALMACHINES',
entry => {
MEMORY => $memory,
NAME => $zonename,
UUID => $uuid,
STATUS => $zonestatus,
SUBSYSTEM => "Solaris Zones",
VMTYPE => "Solaris Zones",
VMID => $zoneid,
VCPU => $vcpu,
}
);
}
}
# check if Solaris 10 release is higher than 08/07
sub _check_solaris_valid_release{
my ($releaseFile) = @_;
my $release = getFirstMatch(
file => $releaseFile,
pattern => qr/((?:Open)?Solaris .*)/
);
my ($version, $year);
if ($release =~ m/Solaris 10 (\d+)\/(\d+)/) {
$version = $1;
$year = $2;
} elsif ($release =~ /OpenSolaris 20(\d+)\.(\d+)\s/) {
$version = $1;
$year = $2;
} else {
return 0;
}
if ($year <= 7 and $version < 8) {
return 0;
}
return 1;
}
1;
|