[pve-devel] [PATCH container 10/20] use CGroup::get_memory_stat
w.bumiller at proxmox.com
w.bumiller at proxmox.com
Fri Apr 3 16:37:30 CEST 2020
From: Wolfgang Bumiller <w.bumiller at proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
src/PVE/LXC.pm | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 30e7713..6c4980b 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -261,12 +261,9 @@ sub vmstatus {
my $cgroups = PVE::LXC::CGroup->new($vmid);
- if (-d '/sys/fs/cgroup/memory') {
- my $memory_stat = read_cgroup_list('memory', $vmid, $unpriv, 'memory.stat');
- my $mem_usage_in_bytes = read_cgroup_value('memory', $vmid, $unpriv, 'memory.usage_in_bytes');
-
- $d->{mem} = $mem_usage_in_bytes - $memory_stat->{total_cache};
- $d->{swap} = read_cgroup_value('memory', $vmid, $unpriv, 'memory.memsw.usage_in_bytes') - $mem_usage_in_bytes;
+ if (defined(my $mem = $cgroups->get_memory_stat())) {
+ $d->{mem} = $mem->{mem};
+ $d->{swap} = $mem->{swap};
} else {
$d->{mem} = 0;
$d->{swap} = 0;
--
2.20.1
More information about the pve-devel
mailing list