diff --git a/check_cpu b/check_cpu index ae97bcff24a3afb980d3b5bae57164e4e9df3a79..581d1e52fefde924dc11cf4bc16ff126a7045518 100755 --- a/check_cpu +++ b/check_cpu @@ -13,6 +13,7 @@ # 2020-07-08 v1.2 <axel.hahn@iml.unibe.ch> FIX: set "ph." instead "ps." # 2020-07-17 v1.3 <axel.hahn@iml.unibe.ch> use ph.require to check binaries # 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 # ====================================================================== @@ -27,7 +28,7 @@ function showHelp(){ cat <<EOF ______________________________________________________________________ -CHECK_CPU check cpu usage and cpu wait v1.4 +CHECK_CPU check cpu usage and cpu wait v1.5 (c) Institute for Medical Education - Univerity of Bern Licence: GNU GPL 3 @@ -90,7 +91,9 @@ typeset -i iCriticalWait=` ph.getValueWithParam 50 i "$@"` # hi : time spent servicing hardware interrupts # si : time spent servicing software interrupts # st : time stolen from this vm by the hypervisor -top -b -n 1 | head -5 | grep "^\%Cpu" >$tmpfile +# top -b -n 1 | head -5 | grep "^\%Cpu" >$tmpfile +# FIX read cpu from 2nd output of top +top -b -n 2 -d 0.1 | grep -i "^\%Cpu" | tail -1 >$tmpfile cpuUser=` awk '{ print $2 }' $tmpfile` cpuSystem=` awk '{ print $4 }' $tmpfile`