From d464081501ecc6d686d818799ac3148d87e1174d Mon Sep 17 00:00:00 2001 From: tatref Date: Wed, 12 Jul 2023 09:29:14 +0200 Subject: [PATCH] fix URL not found If URL is invalid or if authentication is not working, the script outputs ``` Use of uninitialized value $haproxy in split at ./check_haproxy_stats.pl line 231. Unable to retrieve haproxy stats at ./check_haproxy_stats.pl line 233. ``` Now with the fix: ``` Unable to retrieve haproxy stats at ./check_haproxy_stats.pl line 227. ``` --- check_haproxy_stats.pl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/check_haproxy_stats.pl b/check_haproxy_stats.pl index 3b6dabf..47eef1e 100755 --- a/check_haproxy_stats.pl +++ b/check_haproxy_stats.pl @@ -197,14 +197,9 @@ sub usage { $geturl .= ';csv'; $haproxy = get($geturl); } elsif ($url) { - my $haproxyio; my $getcmd = "curl --insecure -s --fail " . "--user '$user:$pass' '".$url.";csv'"; - open $haproxyio, "-|", $getcmd; - while (<$haproxyio>) { - $haproxy .= $_; - } - close($haproxyio); + $haproxy = `$getcmd`; } else { # Connect to haproxy socket and get stats my $haproxyio = new IO::Socket::UNIX (