Skip to content
Snippets Groups Projects

6468-docs-and-harmonize

Merged Hahn Axel (hahn) requested to merge 6468-docs-and-harmonize into master

Files

+ 53
5
@@ -12,25 +12,73 @@
@@ -12,25 +12,73 @@
# 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
# 2022-04-01 v1.4 <axel.hahn@iml.unibe.ch> use wget default params; shell fixes
# 2022-10-21 v1.5 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
# 2022-10-21 v1.5 <axel.hahn@unibe.ch> remove grep: warning: stray \ before white space
 
# 2023-07-28 v1.6 <axel.hahn@unibe.ch> add help page
# ======================================================================
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
. $(dirname $0)/inc_pluginfunctions
 
 
export self_APPVERSION=1.6
 
. $(dirname $0)/inc_haproxy_cfg.sh
. $(dirname $0)/inc_haproxy_cfg.sh
cfgfile=/etc/haproxy/haproxy.cfg
tmpfile=/tmp/check_haproxy_healthcheck_$$
tmpfile=/tmp/check_haproxy_healthcheck_$$
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# pre checks
# functions
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
 
 
function showHelp(){
 
local _self; _self=$(basename $0)
 
cat <<EOF
 
$( ph.showImlHelpHeader )
 
 
Check HA Proxy health.
 
The plugin reads $HAPROXYcfgfile to detect required status url.
 
It requires wget to handle the http request.
 
 
Non OK values occur:
 
UNKNOWN - if $HAPROXYcfgfile cannot be read
 
- haproxy is not in http mode
 
- the detected status url doesn't send a response
 
ERROR - the detected status url did not respond with Http status
 
code 200
 
 
SYNTAX:
 
$_self [-h]
 
 
OPTIONS:
 
 
-h or --help show this help.
 
 
EXAMPLE:
 
 
$_self
 
 
EOF
 
}
 
 
# ----------------------------------------------------------------------
 
# MAIN
 
# ----------------------------------------------------------------------
 
 
# --- check param -h
 
case "$1" in
 
"--help"|"-h")
 
showHelp
 
exit 0
 
;;
 
*)
 
esac
 
ph.require wget
ph.require wget
cat $cfgfile >/dev/null
cat $HAPROXYcfgfile >/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 $HAPROXYcfgfile ... $(ls -l $HAPROXYcfgfile)"
fi
fi
cat $cfgfile | grep " mode .*http" >/dev/null
cat $HAPROXYcfgfile | grep " mode .*http" >/dev/null
if [ $? -ne 0 ]; then
if [ $? -ne 0 ]; then
ph.abort "UNKNOWN: haproxy is not in http mode"
ph.abort "UNKNOWN: haproxy is not in http mode"
fi
fi
Loading