[pve-devel] [PATCH pve-manager 2/3] pvestatd: qemu: broadcast rrd hostcpu && hostmem metrics

Alexandre Derumier aderumier at odiso.com
Wed May 25 08:52:18 CEST 2022


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Service/pvestatd.pm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 832d9dc5..7ed12504 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -236,6 +236,9 @@ sub update_qemu_status {
 	}
 	PVE::Cluster::broadcast_rrd("pve2.3-vm/$vmid", $data);
 
+	my $single_metrics = ['hostcpu', 'hostmem'];
+	broadcast_rrd_metrics($ctime, $d, $single_metrics, "pve2-metrics/vms/$vmid");
+
 	broadcast_rrd_pressure($ctime, $d, "pve2-metrics/vms/$vmid");
 
 	PVE::ExtMetric::update_all($transactions, 'qemu', $vmid, $d, $ctime, $nodename);
@@ -271,6 +274,17 @@ sub broadcast_rrd_pressure {
     delete $d->{pressure};
 }
 
+sub broadcast_rrd_metrics {
+    my ($ctime, $d, $single_metrics, $path) = @_;
+
+    foreach my $metric (@$single_metrics) {
+	my $value = $d->{$metric};
+	next if !defined($value);
+	my $data = $generate_rrd_string->([$ctime, $value]);
+	PVE::Cluster::broadcast_rrd("$path/$metric", $data);
+    }
+}
+
 sub remove_stale_lxc_consoles {
 
     my $vmstatus = PVE::LXC::vmstatus();
-- 
2.30.2





More information about the pve-devel mailing list