From a990964ccb8019e92c9054dd256ef5eb4e2862ca Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Tue, 14 Dec 2021 15:48:12 +0100
Subject: [PATCH] haproxy health: remove password for showing url in output

---
 check_haproxy_health | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/check_haproxy_health b/check_haproxy_health
index d10a02b..ae648b0 100755
--- a/check_haproxy_health
+++ b/check_haproxy_health
@@ -38,22 +38,24 @@ fi
 
 # ----------------------------------------------------------------------
 
-
 url=$( getHealthUri )
 
+# remove password for showing url in output
+safeurl=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
+
 # --- get status page
 wget --no-check-certificate -O $tmpfile $url 2>/dev/null
 if [ $? -ne 0 ]; then
   rm -f $tmpfile
-  ph.abort "UNKNOWN: url $url did not respond. `wget --no-check-certificate -O - -S $url`"
+  ph.abort "UNKNOWN: url $safeurl did not respond. `wget --no-check-certificate -O - -S $url`"
 fi
 
 grep "200 OK" $tmpfile >/dev/null
 if [ $? -ne 0 ]; then
   ph.setStatus "error"
-  ph.status "url $url did not contain 200 OK. `wget --no-check-certificate -O - -S $url`"
+  ph.status "url $safeurl did not contain 200 OK. `wget --no-check-certificate -O - -S $url`"
 else
-  ph.status "HA Proxy $url is up and running."
+  ph.status "HA Proxy $safeurl is up and running."
 fi
 
 rm -f $tmpfile
-- 
GitLab