From 496371b82150e1062b3a18c9840601b60b5b6787 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Fri, 9 Jun 2023 09:24:54 +0200
Subject: [PATCH] limit activity output

---
 check_psqlserver | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/check_psqlserver b/check_psqlserver
index aa01d1f..026654b 100755
--- a/check_psqlserver
+++ b/check_psqlserver
@@ -232,7 +232,11 @@ case "${sMode}" in
         typeset -i iQOther;    iQOther=$iQTotal-$iQActive-$iQIdle-$iQFastpath
 
         descr="Running total: $iQTotal ... active: $iQActive idle: $iQIdle fastpath: $iQFastpath other: $iQOther"
-        out=$( grep "^.[a-z]" <<< "${_out}" | cut -c 1-150 | tr '|' ':' )
+        typeset -i iMax; iMax=20
+        out=$( grep "^.[a-z]" <<< "${_out}" | cut -c 1-150 | tr '|' ':' | head -${iMax} )
+        if [ ${iQTotal} -gt ${iMax} ]; then
+            out+="${NL}(showing ${iMax} of ${iQTotal} lines)${NL}"
+        fi
         ph.perfadd "running-total"     "${iQTotal}"
         ph.perfadd "running-active"    "${iQActive}"
         ph.perfadd "running-idle"      "${iQIdle}"
-- 
GitLab