From bb35a833d15bae7d01c3052e80c18f9258f66d02 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 15 Mar 2021 09:14:54 +0100 Subject: [PATCH] metrics: influx: send along auth token on connection test too Signed-off-by: Thomas Lamprecht --- 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) {