all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem
@ 2021-02-17 17:08 Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexandre Derumier @ 2021-02-17 17:08 UTC (permalink / raw)
  To: pve-devel

This add new cgroups value stats.

hostcpu/hostmem give the real cpu/mem usage of a vm, including vhost-net.


Changelog v2: 
 - rebase on last master
 - use new pressure code from pve-common


Alexandre Derumier (3):
  vmstatus: add hostcpu value
  vmstatus: add hostmem value
  vmstatus: add pressure stats

 PVE/QemuServer.pm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value
  2021-02-17 17:08 [pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
@ 2021-02-17 17:08 ` Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] SPAM: [PATCH v2 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2021-02-17 17:08 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/QemuServer.pm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f401baf..52db3d3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2657,8 +2657,11 @@ sub vmstatus {
 
 	my $pstat = PVE::ProcFSTools::read_proc_pid_stat($pid);
 	next if !$pstat; # not running
+	my $cgroups = PVE::QemuServer::CGroup->new($vmid);
+	my $hostcpustat = $cgroups->get_cpu_stat();
 
 	my $used = $pstat->{utime} + $pstat->{stime};
+	my $hostused = $hostcpustat->{utime} + $hostcpustat->{stime};
 
 	$d->{uptime} = int(($uptime - $pstat->{starttime})/$cpuinfo->{user_hz});
 
@@ -2672,6 +2675,9 @@ sub vmstatus {
 		time => $ctime,
 		used => $used,
 		cpu => 0,
+		hostused => $hostused,
+		hostcpu => 0,
+
 	    };
 	    next;
 	}
@@ -2680,15 +2686,20 @@ sub vmstatus {
 
 	if ($dtime > 1000) {
 	    my $dutime = $used -  $old->{used};
+	    my $dhostutime = $hostused -  $old->{hostused};
 
 	    $d->{cpu} = (($dutime/$dtime)* $cpucount) / $d->{cpus};
+	    $d->{hostcpu} = (($dhostutime/$dtime)* $cpucount) / $d->{cpus};
 	    $last_proc_pid_stat->{$pid} = {
 		time => $ctime,
 		used => $used,
 		cpu => $d->{cpu},
+		hostused => $hostused,
+		hostcpu => $d->{hostcpu},
 	    };
 	} else {
 	    $d->{cpu} = $old->{cpu};
+	    $d->{hostcpu} = $old->{hostcpu};
 	}
     }
 
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] [PATCH v2 qemu-server 2/3] vmstatus: add hostmem value
  2021-02-17 17:08 [pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
@ 2021-02-17 17:08 ` Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] SPAM: [PATCH v2 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2021-02-17 17:08 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/QemuServer.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 52db3d3..3a623c5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2668,6 +2668,11 @@ sub vmstatus {
 	if ($pstat->{vsize}) {
 	    $d->{mem} = int(($pstat->{rss}/$pstat->{vsize})*$d->{maxmem});
 	}
+	if (defined(my $hostmemstat = $cgroups->get_memory_stat())) {
+	    $d->{hostmem} = $hostmemstat->{mem};
+	} else {
+	    $d->{hostmem} = 0;
+	}
 
 	my $old = $last_proc_pid_stat->{$pid};
 	if (!$old) {
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

* [pve-devel] SPAM: [PATCH v2 qemu-server 3/3] vmstatus: add pressure stats
  2021-02-17 17:08 [pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
  2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
@ 2021-02-17 17:08 ` Alexandre Derumier
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Derumier @ 2021-02-17 17:08 UTC (permalink / raw)
  To: pve-devel

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
 PVE/QemuServer.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 3a623c5..f99f969 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2706,6 +2706,8 @@ sub vmstatus {
 	    $d->{cpu} = $old->{cpu};
 	    $d->{hostcpu} = $old->{hostcpu};
 	}
+
+	$d->{pressure} = $cgroups->get_pressure_stat();
     }
 
     return $res if !$full;
-- 
2.20.1




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-17 17:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-17 17:08 [pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem Alexandre Derumier
2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value Alexandre Derumier
2021-02-17 17:08 ` [pve-devel] [PATCH v2 qemu-server 2/3] vmstatus: add hostmem value Alexandre Derumier
2021-02-17 17:08 ` [pve-devel] SPAM: [PATCH v2 qemu-server 3/3] vmstatus: add pressure stats Alexandre Derumier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal