[pve-devel] [PATCH manager] InfluxDB plugins: send nodename when updating CT/VM status

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Feb 23 09:32:30 CET 2017


This allows filtering by node in InfluxDB queries, so the statistics
of all virtual guests on a specific nodes can be queried.

While for InfluxDB this is only a tag which does changes where the
data is stored, Graphite - our other status plugin - has no such
mechanics available. If we would add it to the object hierarchy,
e.g.: "qemu.$vmid.$nodename" a migration of a VM would result in two
different datasets.
So avoid breaking setups and omit it for Graphite for now.

Suggested-by: Daniel1108 <danielgallegosanchez at gmail.com>
CC: Daniel1108 <danielgallegosanchez at gmail.com>

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/Service/pvestatd.pm | 4 ++--
 PVE/Status/Graphite.pm  | 4 ++--
 PVE/Status/InfluxDB.pm  | 8 ++++----
 PVE/Status/Plugin.pm    | 4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index f6aaa30..28e497c 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -203,7 +203,7 @@ sub update_qemu_status {
 	    my $plugin_config = $status_cfg->{ids}->{$id};
 	    next if $plugin_config->{disable};
 	    my $plugin = PVE::Status::Plugin->lookup($plugin_config->{type});
-	    $plugin->update_qemu_status($plugin_config, $vmid, $d, $ctime);
+	    $plugin->update_qemu_status($plugin_config, $vmid, $d, $ctime, $nodename);
 	}
     }
 }
@@ -403,7 +403,7 @@ sub update_lxc_status {
 	    my $plugin_config = $status_cfg->{ids}->{$id};
 	    next if $plugin_config->{disable};
 	    my $plugin = PVE::Status::Plugin->lookup($plugin_config->{type});
-	    $plugin->update_lxc_status($plugin_config, $vmid, $d, $ctime);
+	    $plugin->update_lxc_status($plugin_config, $vmid, $d, $ctime, $nodename);
 	}
     }
 }
diff --git a/PVE/Status/Graphite.pm b/PVE/Status/Graphite.pm
index f8d95d1..849930f 100644
--- a/PVE/Status/Graphite.pm
+++ b/PVE/Status/Graphite.pm
@@ -45,12 +45,12 @@ sub update_node_status {
 }
 
 sub update_qemu_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
     write_graphite_hash($plugin_config, $data, $ctime, "qemu.$vmid");
 }
 
 sub update_lxc_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
 
     write_graphite_hash($plugin_config, $data, $ctime, "lxc.$vmid");
 }
diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm
index 0cce42b..7364e57 100644
--- a/PVE/Status/InfluxDB.pm
+++ b/PVE/Status/InfluxDB.pm
@@ -38,11 +38,11 @@ sub update_node_status {
 }
 
 sub update_qemu_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
 
     $ctime *= 1000000000;
 
-    my $object = "object=qemu,vmid=$vmid";
+    my $object = "object=qemu,vmid=$vmid,nodename=$nodename";
     if($data->{name} && $data->{name} ne '') {
 	$object .= ",host=$data->{name}";
     }
@@ -51,11 +51,11 @@ sub update_qemu_status {
 }
 
 sub update_lxc_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
 
     $ctime *= 1000000000;
 
-    my $object = "object=lxc,vmid=$vmid";
+    my $object = "object=lxc,vmid=$vmid,nodename=$nodename";
     if($data->{name} && $data->{name} ne '') {
 	$object .= ",host=$data->{name}";
     }
diff --git a/PVE/Status/Plugin.pm b/PVE/Status/Plugin.pm
index 070467c..ff7af89 100644
--- a/PVE/Status/Plugin.pm
+++ b/PVE/Status/Plugin.pm
@@ -62,13 +62,13 @@ sub update_node_status {
 }
 
 sub update_qemu_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
 
     die "please implement inside plugin";
 }
 
 sub update_lxc_status {
-    my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
+    my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
 
     die "please implement inside plugin";
 }
-- 
2.1.4





More information about the pve-devel mailing list