From 40e2a0b179cbaa3f3d36f2e6c2b314a8c179aa08 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Tue, 6 Sep 2022 11:05:56 +0200 Subject: [PATCH] fix: replace pipe --- check_cpu | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/check_cpu b/check_cpu index c5db3e7..0f34408 100755 --- a/check_cpu +++ b/check_cpu @@ -20,13 +20,14 @@ # 2022-03-22 v1.9 <axel.hahn@iml.unibe.ch> fix syntax error on 100% idle # 2022-04-14 v1.10 <axel.hahn@iml.unibe.ch> show consuming cpu processes with top and ps # 2022-08-29 v1.11 <axel.hahn@iml.unibe.ch> replace pipe to prevent start of metrics section +# 2022-08-29 v1.12 <axel.hahn@iml.unibe.ch> fix: replace pipe # ====================================================================== . $(dirname $0)/inc_pluginfunctions self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.11 +self_APPVERSION=1.12 # ---------------------------------------------------------------------- # functions @@ -153,10 +154,10 @@ ph.status "CPU-USAGE [%] ${cpuNonIdle} ... user: ${cpuUser} - system: ${cpuSyste plist=$( ps aux | awk '$8 ~ /(D|STAT)/ { print $0 }' ) # replace pipe to prevent start of metrics section -echo "$plist" | tr '|' ':' | grep "[0-9]" >/dev/null \ +echo "$plist" | grep "[0-9]" >/dev/null \ && echo \ && echo "For analysis of cpu waits - processes with status D:" \ - && echo "$plist" + && echo "$plist" | tr '|' ':' # v1.7: show most consuming processes if usage is > nn % typeset -i iUsed=$( echo $cpuNonIdle | cut -f 1 -d '.' ) @@ -170,7 +171,7 @@ if [ $iUsed -gt $iMinCpuUsageToShowProcesses ]; then echo "$topout" | sed -n "${iStart},${iEnd}p" | tr '|' ':' echo echo "output of ps:" - ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5 + ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5 | tr '|' ':' echo fi -- GitLab