From e9484e02146518902d0a57eaeb99dc568b0eca35 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Fri, 24 Sep 2021 09:47:48 +0200
Subject: [PATCH] update php-fpm check

---
 check_php-fpm-status | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/check_php-fpm-status b/check_php-fpm-status
index 1eafd3b..c3ade0f 100755
--- a/check_php-fpm-status
+++ b/check_php-fpm-status
@@ -124,8 +124,8 @@ fi
 # ----------------------------------------------------------------------
 
 # --- handled requests per sec
-typeset -i iConn=$(  _getvalue "accepted conn")
-typeset -i iSpeed=$( ph.perfdeltaspeed "fpm-accepted" $iConn )
+typeset -i iConn=$(      _getvalue "accepted conn")
+typeset -i iSpeed=$(     ph.perfdeltaspeed "fpm-accepted" $iConn )
 
 # --- count slots
 typeset -i iActive=$(    _getvalue "active processes" )
@@ -140,41 +140,53 @@ typeset -i iSlow=$(      ph.perfdeltaspeed "fpm-slow" $iSlowTotal )
 typeset -i iMaxChilds=$( _getvalue "max children reached")
 
 
+# ----------------------------------------------------------------------
+# set status
+# ----------------------------------------------------------------------
 # damn, count of slots is in the config only - not in status output
 # iUsage=$iActive*100/$iSlots
 # ph.setStatusByLimit $iUsage $iWarnLimit $iCriticalLimit
-if [ $iQueue -gt 0 -o $iSlow -gt 0 -o $iIdle -eq 0 ]; then
-        ph.setStatus warning
+if [ $iQueue -gt 0 -o $iSlow -gt 0 ]; then
+    ph.setStatus warning
 fi
 if [ $iMaxChilds -gt 0 ]; then
-        # ph.setStatus critical
-        ph.setStatus warning
+    # ph.setStatus critical
+    ph.setStatus warning
+fi
+if [ $iIdle -eq 0 ]; then
+    ph.setStatus critical
 fi
 
 
-# --- output
+# ----------------------------------------------------------------------
+# output
+# ----------------------------------------------------------------------
 ph.status "PHP-FPM: active: $iActive (max: $iMaxActive) .. idle workers: $iIdle .. queue: $iQueue (max: $iMaxQueue) .. speed: $iSpeed req per sec ... slow: $iSlow req per sec (total: $iSlowTotal)"
-
-hint="HINT: the non-OK status is still erxperimmental. A warning can be a false positive.\n"
+echo
+hint="!! IMPORTSNT !! Any non-OK status is still experimmental."
 if [ $iIdle -eq 0 ]; then
     echo $hint
     echo "WARNING: $iIdle idle workers available."
     echo "         Maybe there is a current peak only."
     echo "         Or count of allowed workers (pm.max_children) or spare servers (pm.XXX_spare_servers) is too low."
+    echo
+fi
+if [ $iMaxChilds -gt 0 ]; then
+    echo $hint
+    echo "WARNING: Max. count of children was reached: $iMaxChilds. Maximum of active workers was $iMaxActive - maybe count of allowed workers (pm.max_children) is too low."
+    echo
 fi
 if [ $iQueue -gt 0 ]; then
     echo $hint
     echo "WARNING: $iQueue queued requests were found. Maximum of queued items is $iMaxQueue."
+    echo
 fi
 if [ $iSlow -gt 0 ]; then
     echo $hint
     echo "WARNING: $iSlow slow requests were found... $iSlowTotal since restart of fpm service."
+    echo
 fi
-if [ $iMaxChilds -gt 0 ]; then
-    echo $hint
-    echo "WARNING: max. children was reached $iMaxChilds. Maximum of active workers was $iMaxActive - maybe count of allowed workers (pm.max_children) is too low."
-fi
-echo
+
 cat $tmpfile
 echo
 
-- 
GitLab