diff --git a/check_cpu b/check_cpu index 67a647929c010e4eb4fcbcc004372d7db553a949..bbea1f2686b22353d29cebc82318da82224a94c8 100755 --- a/check_cpu +++ b/check_cpu @@ -18,6 +18,7 @@ # 2022-03-09 v1.7 <axel.hahn@iml.unibe.ch> show most cpu intensive processes # 2022-03-10 v1.8 <axel.hahn@iml.unibe.ch> add cli param -p; update help # 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 # ====================================================================== @@ -155,8 +156,16 @@ echo "$plist" | grep "[0-9]" >/dev/null \ typeset -i iUsed=$( echo $cpuNonIdle | cut -f 1 -d '.' ) if [ $iUsed -gt $iMinCpuUsageToShowProcesses ]; then echo - echo "CPU usage is higher $iMinCpuUsageToShowProcesses percent ... showing most consuming processes:" + echo "CPU usage is higher $iMinCpuUsageToShowProcesses percent ... showing most consuming processes" + echo "output of top :" + topout=$( top -b -n 1 -d 0.1 ) + typeset -i iStart=$( echo "$topout" | grep -n "PID.*USER" | cut -f 1 -d ':' ) + typeset -i iEnd=$iStart+5 + echo "$topout" | sed -n "${iStart},${iEnd}p" + echo + echo "output of ps:" ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5 + echo fi echo "