The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CPU usage by site (i.e. by account)

Discussion in 'General Discussion' started by jmerhar, Jun 13, 2008.

  1. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Hi,

    Is there a way in WHM to find out which sites are using the most CPU time? A breakdown showing each site with a percentage would be best. Is this possible to obtain in WHM?

    So far, I have found "CPU/Memory/MySQL Usage" under "Server Status", but am unable to decipher the output. Is this the script I'm looking for? If so, how do I find the most problematic sites from it's output?

    Thanks,
    Jure Merhar
     
  2. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    You will see the %CPU, %MEM, %MySQL usage for each username/domain in "CPU/Memory/MySQL Usage" under "Server Status". You need to see for the user having higher percentage of CPU/memory/MySQL usage.

    Also, there is an option of Show MySQL Processes in WHM to check for the MySQL processes running.
     
  3. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    The following are the only highlighted (red) rows in there:
    Code:
    User      Domain    %CPU    %MEM  MySQL Processes
    mysql              53.25  334.86  0.0
    nobody            257.29   42.03  0.0
    All the rows that actually display a domain name, have the CPU percentage below 2%. How can I determine the problematic sites from this info?
     
  4. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    I have now noticed the following line at the top of the script:
    I'm afraid that installing suexec is not an option for this server. How can I see the CPU usage by site without suexec?
     
  5. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    Login to SSH as root and type below command:

    top -c

    You will get detailed information about each process running on your server.
     
  6. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for your suggestion, but the 'top' command only shows apache and mysql consuming most of the cpu, with no way of knowing which sites are responsible. Am I missing something here?
     
  7. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Is there no way to see CPU usage per account without suexec?
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Without running SuExec and SuPHP, all scripts are run as user nobody making it extremely difficult to track this to an individual user. If you are concerned about security and resource utilization, using SuExec and SuPHP is considered good practice.
     
  9. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hope the below command will help you. Replace PID with process ID:

    grep $(lsof -p PID | grep cwd | awk '{print $9}' | awk -F '/' '{ print $3 }') /etc/userdomains

    Kailash
     
  10. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    Thanks for trying, but the command you provided does not output anything. Running only `lsof -p 2628 | grep cwd` produces the following output:
    Code:
    httpd   2628 root  cwd    DIR        58,0      4096       2 /
    2628 is the PID of httpd.
     
  11. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    You will receive blank result if there is no user involved running this process. It seems that the process owns by nobody.
     
  12. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    You got no output because it may possible that the process was ended when you had given the command or it may possible that the process was not running under any user. If the process is not running by any user, you will need to check your /tmp for possible executable files in your tmp partition.

    Additional you can check running process owned nobody using below command:

    ps auxf | grep nobody

    You can temporary stop httpd so that you can omit httpd process.

    Kailash
     
  13. jmerhar

    jmerhar Member

    Joined:
    Feb 7, 2005
    Messages:
    21
    Likes Received:
    0
    Trophy Points:
    1
    I don't understand this. Which process is not running under any user?

    The /tmp directory contains no executable files.

    This is the output of the command above (excluding httpd):
    Code:
    root     23176  0.0  0.0  3692  668 pts/0    S    14:43   0:00          \_ grep nobody
    nobody   31598  0.0  0.0  4460 2352 ?        SL   Jun05   0:45 proftpd: (accepting connections)
    nobody   20006  0.0  0.0  4724 2684 ?        SL   14:39   0:00  \_ proftpd: connected: 127.0.0.1 (127.0.0.1:42512)
    nobody   15697  0.0  0.0  3804 2340 ?        S    Jun27   0:00 entropychat
    
     
Loading...

Share This Page