From 48968326f27845417e4a8b1b97155c09b199ad76 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Fri, 28 Jul 2023 11:08:55 +0200
Subject: [PATCH] update checks to haproxy.cfg

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

diff --git a/check_haproxy_health b/check_haproxy_health
index 50db6bb..1d3d349 100755
--- a/check_haproxy_health
+++ b/check_haproxy_health
@@ -73,13 +73,15 @@ esac
 
 ph.require wget
 
-cat $HAPROXYcfgfile >/dev/null
-if [ $? -ne 0 ]; then
+if [ ! -f $HAPROXYcfgfile ]; then
+  ph.abort "UNKNOWN: config file does not exist: $HAPROXYcfgfile"
+fi
+
+if ! cat $HAPROXYcfgfile >/dev/null 2>&1; then
   ph.abort "UNKNOWN: unable to read ha proxy config $HAPROXYcfgfile ... $(ls -l $HAPROXYcfgfile)"
 fi
 
-cat $HAPROXYcfgfile | grep " mode .*http" >/dev/null
-if [ $? -ne 0 ]; then
+if ! cat $HAPROXYcfgfile | grep " mode .*http" >/dev/null; then
   ph.abort "UNKNOWN: haproxy is not in http mode"
 fi
 
-- 
GitLab