From 1185453a062ef43e90bba137ea49319420eb4c87 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 28 Jan 2022 11:06:25 +0100 Subject: [PATCH] metrics: influx: preprare value: rename $quote to $force_quote to avoid implying that it's *only* quoted if that parameter is truthy. Also, check the boolean before looks_like_number call, as that is more expensive to do. Signed-off-by: Thomas Lamprecht (cherry picked from commit b8608c53e773fad60d0008b0f1937e0cc5dd1c34) Signed-off-by: Thomas Lamprecht --- PVE/Status/InfluxDB.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm index 0c6c88f3..c7d6819f 100644 --- a/PVE/Status/InfluxDB.pm +++ b/PVE/Status/InfluxDB.pm @@ -252,6 +252,7 @@ sub build_influxdb_payload { # 'abc' and '123' are both valid hostnames, that confuses influx's type detection my $to_quote = { name => 1 }; + my @values = (); foreach my $key (sort keys %$data) { @@ -307,10 +308,10 @@ sub get_recursive_values { } sub prepare_value { - my ($value, $quote) = @_; + my ($value, $force_quote) = @_; # don't treat value like a number if quote is 1 - if (looks_like_number($value) && !$quote) { + if (!$force_quote && looks_like_number($value)) { if (isnan($value) || isinf($value)) { # we cannot send influxdb NaN or Inf return undef; -- 2.39.2