model => 'unknown',
mhz => 0,
cpus => 1,
+ sockets => 1,
};
my $fh = IO::File->new ($fn, "r");
return $res if !$fh;
+ my $idhash = {};
my $count = 0;
while (defined(my $line = <$fh>)) {
if ($line =~ m/^processor\s*:\s*\d+\s*$/i) {
$res->{mhz} = $1 if !$res->{mhz};
} elsif ($line =~ m/^flags\s*:.*(vmx|svm)/) {
$res->{hvm} = 1; # Hardware Virtual Machine (Intel VT / AMD-V)
+ } elsif ($line =~ m/^physical id\s*:\s*(\d+)\s*$/i) {
+ $idhash->{$1} = 1;
}
}
+ $res->{sockets} = scalar(keys %$idhash) || 1;
+
$res->{cpus} = $count;
$fh->close;
my $info = read_proc_pid_stat($pid);
- return $info && ($info->{starttime} eq $pstart) && ($info->{status} ne 'Z') ? $info : undef;
+ return $info && (!$pstart || ($info->{starttime} eq $pstart)) && ($info->{status} ne 'Z') ? $info : undef;
}
sub read_proc_starttime {
memtotal => 0,
memfree => 0,
memused => 0,
+ memshared => 0,
swaptotal => 0,
swapfree => 0,
swapused => 0,
$res->{swapfree} = $d->{swapfree};
$res->{swapused} = $res->{swaptotal} - $res->{swapfree};
+ my $spages = PVE::Tools::file_read_firstline("/sys/kernel/mm/ksm/pages_sharing");
+ $res->{memshared} = int($spages) * 4096;
+
return $res;
}
my $line = PVE::Tools::file_read_firstline("/proc/$$/statm");
- if ($line =~ m/^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+/) {
+ if ($line =~ m/^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*/) {
$res->{size} = $1*$ps;
$res->{resident} = $2*$ps;
$res->{shared} = $3*$ps;