Skip to content
Snippets Groups Projects

use wget default params; shell fixes

Merged Hahn Axel (hahn) requested to merge add-wget-timeout into master
4 files
+ 53
34
Compare changes
  • Side-by-side
  • Inline

Files

+ 11
6
@@ -10,14 +10,19 @@
@@ -10,14 +10,19 @@
# 2020-05-04 v1.1 <axel.hahn@iml.unibe.ch> show message if monitor-uri was not set
# 2020-05-04 v1.1 <axel.hahn@iml.unibe.ch> show message if monitor-uri was not set
# 2020-12-03 v1.2 <axel.hahn@iml.unibe.ch> loop over multiple frontend status urls
# 2020-12-03 v1.2 <axel.hahn@iml.unibe.ch> loop over multiple frontend status urls
# 2021-12-14 v1.3 <axel.hahn@iml.unibe.ch> use updated haproxy paser in sourced file
# 2021-12-14 v1.3 <axel.hahn@iml.unibe.ch> use updated haproxy paser in sourced file
 
# 2022-04-01 v1.4 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# ======================================================================
# ======================================================================
. `dirname $0`/inc_pluginfunctions
. $(dirname $0)/inc_pluginfunctions
. `dirname $0`/inc_haproxy_cfg.sh
. $(dirname $0)/inc_haproxy_cfg.sh
cfgfile=/etc/haproxy/haproxy.cfg
cfgfile=/etc/haproxy/haproxy.cfg
tmpfile=/tmp/check_haproxy_healthcheck_$$
tmpfile=/tmp/check_haproxy_healthcheck_$$
 
paramsWget="-T 5 -t 1 --no-check-certificate"
 
# ^ ^
 
# | tries = 1
 
# timeout in seconds
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
@@ -27,7 +32,7 @@ ph.require wget
@@ -27,7 +32,7 @@ ph.require wget
cat $cfgfile >/dev/null
cat $cfgfile >/dev/null
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
ph.abort "UNKNOWN: unable to read ha proxy config $cfgfile ... `ls -l $cfgfile`"
ph.abort "UNKNOWN: unable to read ha proxy config $cfgfile ... $(ls -l $cfgfile)"
fi
fi
cat $cfgfile | grep "\ mode\ .*http" >/dev/null
cat $cfgfile | grep "\ mode\ .*http" >/dev/null
@@ -47,16 +52,16 @@ fi
@@ -47,16 +52,16 @@ fi
safeurl=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
safeurl=$( echo $url | sed "s#\(://\)\(.*@\)#\1#g" )
# --- get status page
# --- get status page
wget --no-check-certificate -O $tmpfile $url 2>/dev/null
wget $paramsWget -O $tmpfile $url 2>/dev/null
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
rm -f $tmpfile
rm -f $tmpfile
ph.abort "UNKNOWN: url $safeurl did not respond. `wget --no-check-certificate -O - -S $url`"
ph.abort "UNKNOWN: url $safeurl did not respond. $(wget wget $paramsWget -O - -S $url)"
fi
fi
grep "200 OK" $tmpfile >/dev/null
grep "200 OK" $tmpfile >/dev/null
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
ph.setStatus "error"
ph.setStatus "error"
ph.status "url $safeurl did not contain 200 OK. `wget --no-check-certificate -O - -S $url`"
ph.status "url $safeurl did not contain 200 OK. $(wget wget $paramsWget -O - -S $url)"
else
else
ph.status "HA Proxy $safeurl is up and running."
ph.status "HA Proxy $safeurl is up and running."
fi
fi
Loading