Contents

Finding the highest CPU, Memory, and MySQL usage for cPanel accounts

Find highest CPU, Memory & MySQL Usage for cPanel accounts
Find highest CPU, Memory & MySQL Usage for cPanel accounts

Debugging cPanel resources over usage:

When your cPanel server has a very high load, it is possible to login via SSH and paste in a simple code to easily view which user consumes how many resources. Some users might be attacked by hackers that wish to bring the site down either by denying the apache + mysql service  or by brute-forcing the password of the website’s CMS. The user may also be running a campaign on their website that is overloading the server.

Copy and paste the code 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 ;

Example.

USER   CPU
user1   10.51%
user2   6.48%
user3   3.04%
user4   2.17%
user5   1.21%

USER   MEMORY
user1   7.97%
user2   4.58%
user3   2.40%
user4   1.15%
user5   0.10%

USER   MYSQL
user1   0.1%
user2   0.0%
user3   0.0%
user4   0.0%
user5   0.0%
Updated on 10 Jul 2017
Tagged:
0 Comments
Add a comment
Login for Comment