[pve-devel] [PATCH manager 2/5] metrics: influx: send along auth token on connection test too

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Mar 15 09:14:54 CET 2021


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/Status/InfluxDB.pm | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm
index e5dfca39..712a30ff 100644
--- a/PVE/Status/InfluxDB.pm
+++ b/PVE/Status/InfluxDB.pm
@@ -207,6 +207,11 @@ sub test_connection {
 	my $url = "${proto}://${host}:${port}/health";
 	my $ua = LWP::UserAgent->new();
 	$ua->timeout($cfg->{timeout} // 1);
+	# in the initial add connection test, the token may still be in $cfg
+	my $token = $cfg->{token} // get_credentials($id);
+	if (defined($token)) {
+	    $ua->default_header("Authorization" => "Token $token");
+	}
 	my $response = $ua->get($url);
 
 	if (!$response->is_success) {
-- 
2.29.2






More information about the pve-devel mailing list