From a9e639180a7aa216911797adf9b5c980911a9bc3 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Fri, 28 Jul 2023 09:39:57 +0200
Subject: [PATCH] check_haproxy_health - add help page

---
 check_haproxy_health | 42 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/check_haproxy_health b/check_haproxy_health
index fc91dc8..3b7640d 100755
--- a/check_haproxy_health
+++ b/check_haproxy_health
@@ -12,17 +12,57 @@
 # 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-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
+
+export self_APPVERSION=1.6
+
 . $(dirname $0)/inc_haproxy_cfg.sh
 
 cfgfile=/etc/haproxy/haproxy.cfg
 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 $cfgfile to detect required status url. 
+
+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
 
 cat $cfgfile >/dev/null
-- 
GitLab