[pve-devel] [PATCH manager 2/3] add broadcast for new rrd format

Tobias Böhm tb at robhost.de
Mon Jun 19 12:10:20 CEST 2017


---
 PVE/Service/pvestatd.pm | 57 ++++++++++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 2c8454d6..17707e8b 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -190,19 +190,32 @@ sub update_qemu_status {
     foreach my $vmid (keys %$vmstatus) {
 	my $d = $vmstatus->{$vmid};
 	my $data;
+	my $data50;
 	my $status = $d->{qmpstatus} || $d->{status} || 'stopped';
 	my $template = $d->{template} ? $d->{template} : "0";
 	if ($d->{pid}) { # running
-	    $data = $generate_rrd_string->(
-		[$d->{uptime}, $d->{name}, $status, $template, $ctime, $d->{cpus}, $d->{cpu},
-		 $d->{maxmem}, $d->{mem}, $d->{maxdisk}, $d->{disk},
-		 $d->{netin}, $d->{netout}, $d->{diskread}, $d->{diskwrite}]);
+	    my $data_list = [$d->{uptime}, $d->{name}, $status, $template,
+			     $ctime, $d->{cpus}, $d->{cpu},
+			     $d->{maxmem}, $d->{mem},
+			     $d->{maxdisk}, $d->{disk},
+			     $d->{netin}, $d->{netout},
+			     $d->{diskread}, $d->{diskwrite}];
+	    $data = $generate_rrd_string->($data_list);
+	    push @$data_list, ($d->{ioread}, $d->{iowrite});
+	    $data50 = $generate_rrd_string->($data_list);
 	} else {
-	    $data = $generate_rrd_string->(
-		[0, $d->{name}, $status, $template, $ctime, $d->{cpus}, undef,
-		 $d->{maxmem}, undef, $d->{maxdisk}, $d->{disk}, undef, undef, undef, undef]);
+	    my $data_list = [0, $d->{name}, $status, $template,
+			     $ctime, $d->{cpus}, undef,
+			     $d->{maxmem}, undef,
+			     $d->{maxdisk}, $d->{disk},
+			     undef, undef,
+			     undef, undef];
+	    $data = $generate_rrd_string->($data_list);
+	    push @$data_list, (undef, undef);
+	    $data50 = $generate_rrd_string->($data_list);
 	}
 	PVE::Cluster::broadcast_rrd("pve2.3-vm/$vmid", $data);
+	PVE::Cluster::broadcast_rrd("pve5.0-vm/$vmid", $data50);
 
 	foreach my $id (keys %{$status_cfg->{ids}}) {
 	    my $plugin_config = $status_cfg->{ids}->{$id};
@@ -389,20 +402,30 @@ sub update_lxc_status {
 	my $d = $vmstatus->{$vmid};
 	my $template = $d->{template} ? $d->{template} : "0";
 	my $data;
+	my $data50;
 	if ($d->{status} eq 'running') { # running
-	    $data = $generate_rrd_string->(
-		[$d->{uptime}, $d->{name}, $d->{status}, $template,
-		 $ctime, $d->{cpus}, $d->{cpu},
-		 $d->{maxmem}, $d->{mem},
-		 $d->{maxdisk}, $d->{disk},
-		 $d->{netin}, $d->{netout},
-		 $d->{diskread}, $d->{diskwrite}]);
+	    my $data_list = [$d->{uptime}, $d->{name}, $d->{status}, $template,
+			     $ctime, $d->{cpus}, $d->{cpu},
+			     $d->{maxmem}, $d->{mem},
+			     $d->{maxdisk}, $d->{disk},
+			     $d->{netin}, $d->{netout},
+			     $d->{diskread}, $d->{diskwrite}];
+	    $data = $generate_rrd_string->($data_list);
+	    push @$data_list, ($d->{ioread}, $d->{iowrite});
+	    $data50 = $generate_rrd_string->($data_list);
 	} else {
-	    $data = $generate_rrd_string->(
-		[0, $d->{name}, $d->{status}, $template, $ctime, $d->{cpus}, undef,
-		 $d->{maxmem}, undef, $d->{maxdisk}, $d->{disk}, undef, undef, undef, undef]);
+	    my $data_list = [0, $d->{name}, $d->{status}, $template,
+			     $ctime, $d->{cpus}, undef,
+			     $d->{maxmem}, undef,
+			     $d->{maxdisk}, $d->{disk},
+			     undef, undef,
+			     undef, undef];
+	    $data = $generate_rrd_string->($data_list);
+	    push @$data_list, (undef, undef);
+	    $data50 = $generate_rrd_string->($data_list);
 	}
 	PVE::Cluster::broadcast_rrd("pve2.3-vm/$vmid", $data);
+	PVE::Cluster::broadcast_rrd("pve5.0-vm/$vmid", $data50);
 
 	foreach my $id (keys %{$status_cfg->{ids}}) {
 	    my $plugin_config = $status_cfg->{ids}->{$id};
-- 
2.11.0




More information about the pve-devel mailing list