diff --git a/check_cpu b/check_cpu index a91949c8883b7e2de46aa2d99efa23de31e6d589..9e6687b5a70af690541b46dacb95d39116903cfb 100755 --- a/check_cpu +++ b/check_cpu @@ -15,12 +15,15 @@ # 2021-02-10 v1.4 <axel.hahn@iml.unibe.ch> added critical io wait # 2021-10-28 v1.5 <axel.hahn@iml.unibe.ch> Use 2nd update of top # 2021-12-10 v1.6 <axel.hahn@iml.unibe.ch> show processes with status D to find cpu waits +# 2022-03-09 v1.7 <axel.hahn@iml.unibe.ch> show most cpu intensive processes # ====================================================================== . `dirname $0`/inc_pluginfunctions tmpfile=/tmp/check_cpu_$$ +iMinCpuUsageToShowProcesses=30 + # ---------------------------------------------------------------------- # functions # ---------------------------------------------------------------------- @@ -29,7 +32,7 @@ function showHelp(){ cat <<EOF ______________________________________________________________________ -CHECK_CPU check cpu usage and cpu wait v1.6 +CHECK_CPU check cpu usage and cpu wait v1.7 (c) Institute for Medical Education - Univerity of Bern Licence: GNU GPL 3 @@ -135,6 +138,14 @@ echo "$plist" | grep "[0-9]" >/dev/null \ && echo "For analysis of cpu waits - processes with status D:" \ && echo "$plist" +# v1.7: show most consuming processes if usage is > nn % +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:" + ps aux | head -1; ps aux | sort -nrk 3,3 | head -n 5 +fi + echo " Limits: usage warn at ${iWarnLimit} .. critical at ${iCriticalLimit} .. io wait limit ${iCriticalWait} $sInfo