From 8d86c0b7a828aa9f6b713984fc495172a27e516f Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Thu, 24 Jun 2021 15:49:39 +0200
Subject: [PATCH] mysql: check if query cache is enabled as a shared function

---
 check_mysqlserver | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/check_mysqlserver b/check_mysqlserver
index a6d58b2..704916b 100755
--- a/check_mysqlserver
+++ b/check_mysqlserver
@@ -189,15 +189,14 @@ function _mysqlrenderdelta() {
 # helper function for caching checks
 # The function aborts the check ending with OK.
 function _verify_cache(){
-    local bCacheEnabled=
     _mysqlgetvar "have_query_cache" | grep "YES" >/dev/null
     if [ $? -ne 0 ]; then
-        _mysqlgetvar "query_cache_type" | grep "OFF" >/dev/null
-        if [ $? -eq 0 ]; then
-            echo "INFO: Query cache (have_query_cache) is active but query_cache_type is OFF."
-        else
-            echo "INFO: Query cache (have_query_cache) is not active."
-        fi
+        echo "INFO: Query cache (have_query_cache) is not active."
+        ph.exit
+    fi
+    _mysqlgetvar "query_cache_type" | grep "OFF" >/dev/null
+    if [ $? -eq 0 ]; then
+        echo "INFO: Query cache (have_query_cache) is active but query_cache_type is OFF."
         ph.exit
     fi
 }
-- 
GitLab