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.

httpd processes and server load

Discussion in 'General Discussion' started by babakb, Mar 25, 2007.

  1. babakb

    babakb Well-Known Member

    Joined:
    Jan 20, 2007
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    Hi,
    Occasionally I see some resource intensive httpd processes which spike up the server load for a while. However it's hard to know which web site they belong to because they register under user 'nobody'. Anyone have any tips on finding out which site triggered the httpd process(es)?

    Thanks.
     
  2. xerophyte

    xerophyte Well-Known Member

    Joined:
    Mar 16, 2003
    Messages:
    216
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Canada
    here is a way to find out :)

    Take the process id from top then
    Code:
    grep $(lsof -p PID | grep cwd | awk '{print $9}' | awk -F '/' '{ print $3 }') /etc/userdomains
    on the above code replace the PID with process id, it will give domain name

    hope that helps
     
  3. Kailash1

    Kailash1 Well-Known Member

    Joined:
    Nov 27, 2006
    Messages:
    252
    Likes Received:
    2
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Thanks,

    It worked for me.

    Kailash
     
  4. babakb

    babakb Well-Known Member

    Joined:
    Jan 20, 2007
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    xerophyte,
    WOW! That was the single most useful line of script I've ever encountered. Works amazing. I was just getting my feet wet with lsof and taking it from there. Yours takes me from A to Z in one line, genius!
     
  5. SpringChicken

    SpringChicken Member

    Joined:
    Dec 16, 2003
    Messages:
    18
    Likes Received:
    0
    Trophy Points:
    1
    Compliments to xerophyte

    I would like to post my compliments to xerophyte also. Really amazingly helpful. I've been able to pinpoint and correct a number of faulty scripts on sites.

    I am curious about the possibility of creating a log from this info for all processes running above 5 %CPU ? Would someone know how to do this ?

    thanks again for sharing xerophyte :)
     
  6. babakb

    babakb Well-Known Member

    Joined:
    Jan 20, 2007
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    Good idea. You could write a small script (PHP would do) that extracts the output of the CPU & PID columns from a 'ps' and logs the user for those httpd processes which CPU >5%. Then set it up to run as a cron every few minutes. If I find the time I'll try to write up such script, shouldn't be too hard.
     
  7. babakb

    babakb Well-Known Member

    Joined:
    Jan 20, 2007
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    I'm thinking it would be better to show the file being accessed by the httpd process. That way we know which script is eating up the resources. Any ideas on which parameters to modify on xerophytes line of script?
     
  8. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    1) I would upgrade to phpSuExec or SuPHP so that scripts no longer run as "nobody"

    2) When you note higher loads, it's a good idea to go ahead and login to WHM and
    check your "Apache Status" which will show you what files are currently being accessed
    on your web server and give you a clue where to look.

    3) In SSH, you can follow up and go to /etc/httpd/domlogs and review the access logs
    for those sites you noted as the most active in WHM's "Apache Status"

    4) If you run "top" in SSH, you can see which processes are the most active and type
    "m" to sort by memory usage or "p" to sort by cpu usage. The process ID shown
    in "ps" or in "top" can be matched up to the process ID in your apache status too.
     
  9. babakb

    babakb Well-Known Member

    Joined:
    Jan 20, 2007
    Messages:
    47
    Likes Received:
    0
    Trophy Points:
    6
    Spiral, thank you, those are great tips :)
     
  10. useradmin

    useradmin Well-Known Member

    Joined:
    Oct 8, 2004
    Messages:
    107
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    INDIA
    apache load

    HI,


    Apache is taking load more then 600 cpu but apache status or proc show like tihs.

    rwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /
    lrwxrwxrwx 1 root root 0 May 1 06:18 cwd -> /

    how to trace such load?
     
Loading...

Share This Page