cPanel: Find accounts with highest CPU, Memory & MySQL Usage Print

  • 62

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%


Was this answer helpful?

« Back


Ethernet Servers Ltd
124 City Road
London
EC1V 2NX
United Kingdom


Registered Limited Company: #09114946

Telephone:
+44 330 043 1258

Email:
hello@ethernetservers.com

Copyright © 2014 - 2024 - Ethernet Servers Ltd - All Rights Reserved.

Proudly serving customers in 143 countries since July 2014!