From 34e3e59fdc172dad836c531909adba04babe3555 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 14 Sep 2023 09:53:35 +0200
Subject: [PATCH] sort: write failed: 'standard output': Broken pipe

---
 check_memory                   | 9 +++++++--
 docs/20_Checks/check_memory.md | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/check_memory b/check_memory
index f231a64..358b685 100755
--- a/check_memory
+++ b/check_memory
@@ -26,12 +26,13 @@
 # 2022-03-10  v1.7  <axel.hahn@iml.unibe.ch> add cli param -p; update help
 # 2023-02-13  v1.8  <axel.hahn@unibe.ch>     shell fixes
 # 2023-07-28  v1.9  <axel.hahn@unibe.ch>     update help page
+# 2023-09-14  v1.10 <axel.hahn@unibe.ch>     fix sort: write failed: 'standard output': Broken pipe
 # ======================================================================
 
 
 . "$(dirname $0)/inc_pluginfunctions"
 
-self_APPVERSION=1.9
+self_APPVERSION=1.10
 
 # ----------------------------------------------------------------------
 # FUNCTIONS
@@ -152,7 +153,11 @@ grep -E     "^(Mem|Cache|Buffers|Swap|Slab|SReclaimable)" "/proc/meminfo"
 if [ $ramUsage -gt $iMinRamUsageToShowProcesses ]; then
   echo
   echo "RAM usage is higher $iMinRamUsageToShowProcesses percent ... showing most consuming processes:"
-  ps aux | head -1; ps aux | sort -nrk 4 | head -n 5
+  ps aux | head -1
+  
+  # sort: write failed: 'standard output': Broken pipe
+  # ps aux | sort -nrk 4 | head -n 5
+  ps aux | sort -nrk 4 | sed -n "1,5p"
 fi 
 
 # --- performance data
diff --git a/docs/20_Checks/check_memory.md b/docs/20_Checks/check_memory.md
index c0fbc95..56ffa3b 100644
--- a/docs/20_Checks/check_memory.md
+++ b/docs/20_Checks/check_memory.md
@@ -29,7 +29,7 @@ This plugin sends all values as performance data.
 ______________________________________________________________________
 
 CHECK_MEMORY
-v1.9
+v1.10
 
 (c) Institute for Medical Education - University of Bern
 Licence: GNU GPL 3
-- 
GitLab