[pve-devel] [manager] A minor enhancement for external metrics to Influxdb and Graphite. So far with the data sent was impossible to know the node that host each lxc/qemu. This small modification allow this. It's very helpful to be able to group lxc/qemu by their host nodes when visualizing data for example with Grafana.

Daniel1108 danielgallegosanchez at gmail.com
Fri Feb 3 12:44:32 CET 2017


Regards

Signed-off-by: Daniel1108 <danielgallegosanchez at gmail.com>
---
 PVE/Service/pvestatd.pm | 4 ++--
 PVE/Status/Graphite.pm  | 6 +++---
 PVE/Status/InfluxDB.pm  | 8 ++++----
 PVE/Status/Plugin.pm    | 4 ++--
 4 files changed, 11 insertions(+), 11 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..f46cb2b 100644
--- a/PVE/Status/Graphite.pm
+++ b/PVE/Status/Graphite.pm
@@ -46,13 +46,13 @@ sub update_node_status {
 
 sub update_qemu_status {
     my ($class, $plugin_config, $vmid, $data, $ctime) = @_;
-    write_graphite_hash($plugin_config, $data, $ctime, "qemu.$vmid");
+    write_graphite_hash($plugin_config, $data, $ctime, "qemu.$vmid.$nodename");
 }
 
 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");
+    write_graphite_hash($plugin_config, $data, $ctime, "lxc.$vmid.$nodename");
 }
 
 sub update_storage_status {
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.7.4




More information about the pve-devel mailing list