You may have come across a time where there's higher than usual resource usage, and you're trying to pinpoint the cause. Sometimes that can be tricky, though, with the below command, you can quickly and easily build up a list of the top 5 users that are consuming your CPU, Memory and MySQL resources. This command does not make any changes to your server. The expected output of the command can also be seen below.
OUT=$(/usr/local/cpanel/bin/dcpumonview | grep -v Top | sed -e 's#<[^>]*># #g' | while read i ; do NF=`echo $i | awk {'print NF'}` ; if [[ "$NF" == "5" ]] ; then USER=`echo $i | awk {'print $1'}`; OWNER=`grep -e "^OWNER=" /var/cpanel/users/$USER | cut -d= -f2` ; echo "$OWNER $i"; fi ; done) ; (echo "USER CPU" ; echo "$OUT" | sort -nrk4 | awk '{printf "%s %s%\n",$2,$4}' | head -5) | column -t ;echo;(echo -e "USER MEMORY" ; echo "$OUT" | sort -nrk5 | awk '{printf "%s %s%\n",$2,$5}' | head -5) | column -t ;echo;(echo -e "USER MYSQL" ; echo "$OUT" | sort -nrk6 | awk '{printf "%s %s%\n",$2,$6}' | head -5) | column -t ;
USER CPU
user1 2.51%
user2 1.48%
user3 1.04%
user4 0.77%
user5 0.61%
USER MEMORY
user1 5.67%
user2 0.38%
user3 0.38%
user4 0.13%
user5 0.12%
USER MYSQL
user1 0.3%
user2 0.0%
user3 0.0%
user4 0.0%
user5 0.0%