Skip to content

Commit

Permalink
Merge branch '2.3.x-memconfectomy' into 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
guillomovitch committed Sep 5, 2012
2 parents 631c7e0 + e582074 commit 6e0058c
Show file tree
Hide file tree
Showing 15 changed files with 449 additions and 306 deletions.
249 changes: 92 additions & 157 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Solaris/CPU.pm
Expand Up @@ -9,7 +9,7 @@ use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Solaris;

sub isEnabled {
return canRun('memconf');
return 1;
}

sub doInventory {
Expand All @@ -18,193 +18,128 @@ sub doInventory {
my $inventory = $params{inventory};
my $logger = $params{logger};

my $class = getClass();

my ($count, $cpu) =
$class == SOLARIS_CONTAINER ?
_getCPUFromPrtcl(logger => $logger) :
_getCPUFromMemconf(logger => $logger);

# fallback on generic method
($count, $cpu) = _getCPUFromPsrinfo(logger => $logger) if !$count;
# get virtual cpus from psrinfo -v
my @vcpus = _getVirtualCPUs(logger => $logger);

# get physical cpus from psrinfo -vp
my @pcpus = _getPhysicalCPUs(logger => $logger);

# consider all cpus as identical
my $type = $pcpus[0]->{type} || $vcpus[0]->{type};
my $speed = $pcpus[0]->{speed} || $vcpus[0]->{speed};
my $manufacturer =
$type =~ /SPARC/ ? 'SPARC' :
$type =~ /Xeon/ ? 'Intel' :
undef ;
my $cpus = scalar @pcpus;

my ($cores, $threads) =
$type eq 'UltraSPARC-IV' ? (2, 1) : # US-IV & US-IV+
$type eq 'UltraSPARC-T1' ? (undef, 4) : # Niagara
$type eq 'UltraSPARC-T2' ? (undef, 8) : # Niagara-II
$type eq 'UltraSPARC-T2+' ? (undef, 8) : # Victoria Falls
$type eq 'SPARC-T3' ? (undef, 8) : # Rainbow Falls
$type eq 'SPARC64-VI' ? (2, 2) : # Olympus-C SPARC64-VI
$type eq 'SPARC64-VII' ? (4, 2) : # Jupiter SPARC64-VII
$type eq 'SPARC64-VII+' ? (4, 2) : # Jupiter+ SPARC64-VII+
$type eq 'SPARC64-VII++' ? (4, 2) : # Jupiter++ SPARC64-VII++
$type eq 'SPARC64-VIII' ? (8, 2) : # Venus SPARC64-VIII
(1, 1) ;

if ($type =~ /MB86907/) {
$type = "TurboSPARC-II $type";
} elsif ($type =~ /MB86904|390S10/) {
$type = ($speed > 70) ? "microSPARC-II $type" : "microSPARC $type";
} elsif ($type =~ /,RT62[56]/) {
$type = "hyperSPARC $type";
}

$cpu->{MANUFACTURER} = "SPARC";
# deduce core numbers from number of virtual cpus if needed
if (!$cores) {
# todo: solaris zone
$cores = (scalar @vcpus) / $threads / $cpus;
}

while ($count--) {
while ($cpus--) {
$inventory->addEntry(
section => 'CPUS',
entry => $cpu
entry => {
MANUFACTURER => $manufacturer,
NAME => $type,
SPEED => $speed,
CORE => $cores,
THREAD => $threads
}
);
}
}


# Sun Microsystems, Inc. Sun Fire 880 (4 X UltraSPARC-III 750MHz)
# Sun Microsystems, Inc. Sun Fire V490 (2 X dual-thread UltraSPARC-IV 1350MHz)
# Sun Microsystems, Inc. Sun Fire V240 (UltraSPARC-IIIi 1002MHz)
# Sun Microsystems, Inc. Sun-Fire-T200 (Sun Fire T2000) (8-core quad-thread UltraSPARC-T1 1000MHz)
# Sun Microsystems, Inc. Sun-Fire-T200 (Sun Fire T2000) (4-core quad-thread UltraSPARC-T1 1000MHz)
# Sun Microsystems, Inc. SPARC Enterprise T5120 (8-core 8-thread UltraSPARC-T2 1165MHz)
# Sun Microsystems, Inc. SPARC Enterprise T5120 (4-core 8-thread UltraSPARC-T2 1165MHz)
# Sun Microsystems, Inc. Sun SPARC Enterprise M5000 Server (6 X dual-core dual-thread SPARC64-VI 2150MHz)
# Fujitsu SPARC Enterprise M4000 Server (4 X dual-core dual-thread SPARC64-VI 2150MHz)
# Sun Microsystems, Inc. Sun Fire V20z (Solaris x86 machine) (2 X Dual Core AMD Opteron(tm) Processor 270 1993MHz)

sub _getCPUFromMemconf {
my $spec = getFirstMatch(
command => 'memconf',
pattern => qr/^((?:Sun|Fujitsu|Intel) .* \d+ [GM]Hz\))/x,
@_
);
return _parseSpec($spec);
}

sub _parseCoreString {
my ($v) = @_;

return
$v =~ /dual/i ? 2 :
$v =~ /quad/i ? 4 :
$v =~ /(\d+)-\w+/ ? $1 :
$v;
}

sub _parseSpec {
my ($spec) = @_;

my $manufacturer;
if ($spec =~ /(AMD|Fujitsu|Intel)\s/g) {
$manufacturer = $1;
} elsif ($spec =~ /Sun/) {
$manufacturer = 'Sun Microsystems';
}

# 4 X UltraSPARC-III 750MHz
if ($spec =~ /(\d+) \s X \s (\S+) \s (\d+ \s* .Hz)/x) {
return $1, {
MANUFACTURER => $manufacturer,
NAME => $2,
SPEED => getCanonicalSpeed($3),
CORE => 1,
};
}

# 2 X dual-thread UltraSPARC-IV 1350MHz
if ($spec =~ /(\d+) \s X \s (\S+) \s (\S+) \s (\d+) MHz/x) {
return $1, {
MANUFACTURER => $manufacturer,
NAME => $3 . " (" . $2 . ")",
SPEED => $4,
CORE => _parseCoreString($1),
THREAD => _parseCoreString($2)
};
}

# 8-core quad-thread UltraSPARC-T1 1000MHz
# 8-core 8-thread UltraSPARC-T2 1165MHz
# 16-Core 8-Thread SPARC-T3 1649MHz
if ($spec =~ /(\d+ -[cC]ore) \s (\S+) \s (\S+) \s (\d+) MHz/x) {
return 1, {
MANUFACTURER => $manufacturer,
NAME => $3 . " (" . $1 . " " . $2 . ")",
SPEED => $4,
CORE => _parseCoreString($1),
THREAD => _parseCoreString($2)
};
}

# 6 X dual-core dual-thread SPARC64-VI 2150MHz
if ($spec =~ /(\d+) \s X \s (\S+) \s (\S+) \s (\S+) \s (\d+) MHz/x) {
return $1, {
MANUFACTURER => $manufacturer,
NAME => $4 . " (" . $2 . " " . $3 . ")",
SPEED => $5,
CORE => _parseCoreString($2),
THREAD => _parseCoreString($3)
};
}

# 2 X Dual Core AMD Opteron(tm) Processor 270 1993MHz
if ($spec =~ /(\d+) \s X \s (\S+) \s Core \s AMD \s (Opteron\(tm\) \s Processor \s \S+) \s ([\.\d]+ \s* .Hz)/x) {
return $1, {
MANUFACTURER => $manufacturer,
NAME => $3,
SPEED => getCanonicalSpeed($4),
CORE => _parseCoreString($2),
};
}

# 2 X Quad-Core Intel(R) Xeon(R) E7320 @ 2.13GHz
if ($spec =~ /(\d+) \s X \s (\S+) \s Intel\(R\) \s (Xeon\(R\) \s E\d+) \s @ \s ([\d\.]+\s*.Hz)/x) {
return $1, {
MANUFACTURER => $manufacturer,
NAME => $3,
SPEED => getCanonicalSpeed($4),
CORE => _parseCoreString($2),
};
}

# UltraSPARC-IIi 270MHz
# UltraSPARC-III 750MHz
if ($spec =~ /([^()\s]\S+) \s (\d+ \s* .Hz)/x) {
return 1, {
MANUFACTURER => $manufacturer,
NAME => $1,
SPEED => getCanonicalSpeed($2),
CORE => 1,
};
}

}

sub _getCPUFromPsrinfo {
my (%params) = (
command => 'psrinfo -v',
sub _getVirtualCPUs {
my %params = (
command => '/usr/sbin/psrinfo -v',
@_
);

my $handle = getFileHandle(%params);
return unless $handle;

my $count = 0;
my $cpu;
my @cpus;
while (my $line = <$handle>) {
next unless $line =~
/^\s+The\s(\w+)\sprocessor\soperates\sat\s(\d+)\sMHz,/;

$cpu->{NAME} = $1;
$cpu->{SPEED} = $2;
$count++;
if ($line =~ /The (\S+) processor operates at (\d+) MHz/) {
push @cpus, {
type => $1,
speed => $2,
};
next;
}
}
close $handle;

return ($count, $cpu);
return @cpus;
}

sub _getCPUFromPrtcl {
my (%params) = (
command => "prctl -n zone.cpu-shares $PID",
sub _getPhysicalCPUs {
my %params = (
command => '/usr/sbin/psrinfo -vp',
@_
);

my $handle = getFileHandle(%params);
return unless $handle;

my ($count, $cpu);
my @cpus;
while (my $line = <$handle>) {
$cpu->{NAME} = $1 if $line =~ /^zone.(\S+)$/;
$cpu->{NAME} .= " " . $1 if $line =~ /^\s*privileged+\s*(\d+)/;
#$count = 1 if /^\s*privileged+\s*(\d+)/;
foreach (`memconf 2>&1`) {
if(/\s+\((\d+).*\s+(\d+)MHz/) {
$count = $1;
$cpu->{SPEED} = $2;
}

if ($line =~ /^The physical processor has (\d+) virtual/) {
push @cpus, {
count => $1
};
next;
}

if ($line =~ /^The (\S+) physical processor has (\d+) virtual/) {
push @cpus, {
type => $1,
count => $2
};
next;
}

if ($line =~ /(\S+) \(.* clock (\d+) MHz\)/) {
my $cpu = $cpus[-1];
$cpu->{type} = $1;
$cpu->{speed} = $2;
next;
}

if ($line =~ /Intel\(r\) Xeon\(r\) CPU +(\S+)/) {
my $cpu = $cpus[-1];
$cpu->{type} = "Xeon $1";
}
}
close $handle;

return ($count, $cpu);
return @cpus;
}

1;
64 changes: 64 additions & 0 deletions resources/solaris/psrinfo/giration-psrinfo_v
@@ -0,0 +1,64 @@
Status of virtual processor 0 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 1 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 2 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 3 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 4 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 5 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 6 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 7 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:01.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 16 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 17 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 18 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 19 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 20 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 21 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 22 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
Status of virtual processor 23 as of: 08/13/2012 19:19:39
on-line since 08/03/2012 16:48:05.
The sparcv9 processor operates at 1350 MHz,
and has a sparcv9 floating point processor.
16 changes: 16 additions & 0 deletions resources/solaris/psrinfo/giration-psrinfo_vp
@@ -0,0 +1,16 @@
The physical processor has 2 virtual processors (0 16)
UltraSPARC-IV (portid 0 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (1 17)
UltraSPARC-IV (portid 1 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (2 18)
UltraSPARC-IV (portid 2 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (3 19)
UltraSPARC-IV (portid 3 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (4 20)
UltraSPARC-IV (portid 4 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (5 21)
UltraSPARC-IV (portid 5 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (6 22)
UltraSPARC-IV (portid 6 impl 0x18 ver 0x31 clock 1350 MHz)
The physical processor has 2 virtual processors (7 23)
UltraSPARC-IV (portid 7 impl 0x18 ver 0x31 clock 1350 MHz)
File renamed without changes.

0 comments on commit 6e0058c

Please sign in to comment.