[pve-devel] [PATCH manager] add graphite tcp support
Martin Verges
martin.verges at croit.io
Mon Nov 4 16:48:04 CET 2019
This change allows sending statistics to graphite over TCP.
So far only UDP is possible, which is not available in some environments, like behind a loadbalancer.
Configuration example:
~ $ cat /etc/pve/status.cfg
graphite:
server 10.20.30.40
port 2003
path proxmox
proto tcp
Signed-off-by: Martin Verges <martin.verges at croit.io>
---
PVE/Status/Graphite.pm | 5 ++++-
PVE/Status/Plugin.pm | 6 ++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/PVE/Status/Graphite.pm b/PVE/Status/Graphite.pm
index d0e1563d..1180a774 100644
--- a/PVE/Status/Graphite.pm
+++ b/PVE/Status/Graphite.pm
@@ -9,6 +9,7 @@ use PVE::Status::Plugin;
#graphite:
# server test
# port 2003
+# proto udp
# path proxmox.mycluster
# disable 0
#
@@ -32,6 +33,7 @@ sub options {
return {
server => {},
port => { optional => 1 },
+ proto => { optional => 1 },
path => { optional => 1 },
disable => { optional => 1 },
};
@@ -76,11 +78,12 @@ sub write_graphite_hash {
my $host = $plugin_config->{server};
my $port = $plugin_config->{port} ? $plugin_config->{port} : 2003;
my $path = $plugin_config->{path} ? $plugin_config->{path} : 'proxmox';
+ my $proto = $plugin_config->{proto} ? $plugin_config->{proto} : 'udp';
my $carbon_socket = IO::Socket::IP->new(
PeerAddr => $host,
PeerPort => $port,
- Proto => 'udp',
+ Proto => $proto,
) || die "couldn't create carbon socket [$host]:$port - $@\n";
write_graphite($carbon_socket, $d, $ctime, $path.".$object");
diff --git a/PVE/Status/Plugin.pm b/PVE/Status/Plugin.pm
index 482142c0..3012def4 100644
--- a/PVE/Status/Plugin.pm
+++ b/PVE/Status/Plugin.pm
@@ -32,6 +32,12 @@ my $defaultData = {
type => 'integer',
description => "server network port",
},
+ proto => {
+ type => 'string',
+ enum => ['udp', 'tcp'],
+ description => "send graphite data using tcp or udp (default)",
+ optional => 1,
+ },
},
};
--
2.20.1
More information about the pve-devel
mailing list