Skip to content

Instantly share code, notes, and snippets.

@aminamid
Last active August 29, 2015 14:18
Show Gist options
  • Select an option

  • Save aminamid/6061c596761b6c6b6c5f to your computer and use it in GitHub Desktop.

Select an option

Save aminamid/6061c596761b6c6b6c5f to your computer and use it in GitHub Desktop.
which process use each cpu onliner
while true ; do echo -e "\033[H\033[J"; ps -A -L -o pid,tid,psr,pcpu,comm= | grep -v PSR | awk '{sum[$3" "$1" "$5]+=$4};END { for (key in sum) {print key,sum[key]}}' | sort -nk1 | column -t | grep -v " 0$" ; sleep 1 ; done
while true; do NOW=$(date "+%Y-%m-%dT%H:%M:%S"); ps -A -L -o pid,tid,psr,pcpu,comm= | grep -v PSR | awk '{sum[$3" "$1" "$5]+=$4};END { for (key in sum) {print key,sum[key]}}' | sort -nk1 | column -t | grep -v " 0$" | awk '{ print "'${NOW}'", $0; fflush() }' ; sleep 2 ; echo ; done
pidstat -I -u -t -d -p ALL 3 65535 | grep -v -e " 0.00 0.00 0.00 " -e " 0.00 0.00 0.00 0.00 "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment