Public domain
#!/bin/bash
# Gathering Info
PS=$(ps aux)
FREE=$(free -m)
# Show cpu sorted usage
echo %CPU COMMAND :
printf "%s" "$PS" | grep -v 'CPU' | sort -rk 3 | head | awk '{print $3" "$11}'
echo
# Show memory sorted usage
echo %MEM COMMAND :
printf "%s" "$PS" | grep -v 'CPU' | sort -rk 4 | head | awk '{print $4" "$11}'
echo
# Show memory total usage
printf "%s" "$FREE"
echo
BY: Pejman Moghadam
TAG: bash, bash-script
DATE: 2009-04-25 00:15:59