Skip to content

Instantly share code, notes, and snippets.

@jamesstout
Created August 7, 2013 14:46
Show Gist options
  • Save jamesstout/6174698 to your computer and use it in GitHub Desktop.
Save jamesstout/6174698 to your computer and use it in GitHub Desktop.
test
function cpuuu (){
declare pids=($(ps aux | grep -E *(ImageOp|ImageAl) | grep -v grep | awk '{print $3}'))
pidCount=${#pids[@]}
while [ "$pidCount" -gt 0 ]
do
let timeSpent=0
for index in ${!pids[*]}
do
tmp=${pids[$index]}
tmp=${tmp/\.*}
let timeSpent+=$tmp
done
echo "CPU Utilisation: $timeSpent%"
sleep 3
pids=($(ps aux | grep -E *(ImageOp|ImageAl) | grep -v grep | awk '{print $3}'))
pidCount=${#pids[@]}
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment