From fed0091181152cedb2ea0960dd890754796876ca Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Fri, 1 Apr 2022 16:01:32 +0200
Subject: [PATCH] use params directly - not a variable

---
 check_haproxy_health | 12 +++---------
 check_haproxy_status |  9 ++-------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/check_haproxy_health b/check_haproxy_health
index 52360e4..663243e 100755
--- a/check_haproxy_health
+++ b/check_haproxy_health
@@ -19,12 +19,6 @@
 cfgfile=/etc/haproxy/haproxy.cfg
 tmpfile=/tmp/check_haproxy_healthcheck_$$
 
-paramsWget="-T 5 -t 1 --no-check-certificate"
-#            ^    ^
-#            |    tries = 1
-#            timeout in seconds
-
-
 # ----------------------------------------------------------------------
 # pre checks
 # ----------------------------------------------------------------------
@@ -52,16 +46,16 @@ fi
 safeurl=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
 
 # --- get status page
-wget $paramsWget -O $tmpfile $url 2>/dev/null
+wget -T 5 -t 1 --no-check-certificate -O $tmpfile $url 2>/dev/null
 if [ $? -ne 0 ]; then
   rm -f $tmpfile
-  ph.abort "UNKNOWN: url $safeurl did not respond. $(wget $paramsWget  -O - -S $url)"
+  ph.abort "UNKNOWN: url $safeurl did not respond. $(wget -T 5 -t 1 --no-check-certificate -O - -S $url)"
 fi
 
 grep "200 OK" $tmpfile >/dev/null
 if [ $? -ne 0 ]; then
   ph.setStatus "error"
-  ph.status "url $safeurl did not contain 200 OK. $(wget $paramsWget  -O - -S $url)"
+  ph.status "url $safeurl did not contain 200 OK. $(wget -T 5 -t 1 --no-check-certificate -O - -S $url)"
 else
   ph.status "HA Proxy $safeurl is up and running."
 fi
diff --git a/check_haproxy_status b/check_haproxy_status
index d191353..42a1f4a 100755
--- a/check_haproxy_status
+++ b/check_haproxy_status
@@ -27,11 +27,6 @@ tmpfile=/tmp/check_haproxy_status_$$
 tmpfile2=/tmp/check_haproxy_status2_$$
 tmpfileping=/tmp/check_haproxy_status3_$$
 
-paramsWget="-T 5 -t 1 --no-check-certificate"
-#            ^    ^
-#            |    tries = 1
-#            timeout in seconds
-
 # ----------------------------------------------------------------------
 # pre checks
 # ----------------------------------------------------------------------
@@ -108,10 +103,10 @@ urlmasked=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
 
 
 # --- get status page
-wget $paramsWget -O $tmpfile $url 2>/dev/null
+wget -T 5 -t 1 --no-check-certificate -O $tmpfile $url 2>/dev/null
 if [ $? -ne 0 ]; then
   rm -f $tmpfile
-  ph.abort "UNKNOWN: url $urlmasked did not respond. $(wget --no-check-certificate -O - -S $url)"
+  ph.abort "UNKNOWN: url $urlmasked did not respond. $(wget -T 5 -t 1 --no-check-certificate -O - -S $url)"
 fi
 
 
-- 
GitLab