Skip to content
Snippets Groups Projects
Commit e75eb71b authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

show consuming cpu processes with top and ps

parent 243997dd
No related branches found
No related tags found
1 merge request!16show consuming cpu processes with top and ps
......@@ -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 "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment