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.

Apache trace root of problem

Discussion in 'EasyApache' started by katmai, Nov 28, 2006.

  1. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    526
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brno, Czech Republic
    Hi, i found this tutorial on some other forum.


    #for i in $(ps -C httpd --no-headers | awk '{ print $1 }'); do PIDS="$PIDS -p $i"; done
    #strace -vvFf -o /root/strace.httpd $PIDS

    Run above commands about a minute or so during a peak time of the resource usage. After letting this run for a bit, you will need to break out of it ( control + c ). You'll now have a file /root/strace.httpd that contains all the system calls made by httpd.

    Since the strace output is undoubtedly going to be lengthy and intimidating, it would be best to grep through it for site usage. You could do this with the following regular expression:


    actual question is how does the command below apply to cpanel ? sorry i am too sleepy to think.

    egrep -i '/home/httpd/vhosts/[-_a-z0-9/]+\.[a-z0-9]+' /root/strace.httpd | awk '{ print $2 }' FS="\"" > /root/httpd.usage


    This should make things a bit easier to distinguish, and allow you to easily isolate the culprit

    Thanks,
     
  2. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    This looks usefull, i'm going to try this.
     
  3. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    526
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brno, Czech Republic
    and solution to my problem ?

    egrep -i '/home/httpd/vhosts/[-_a-z0-9/]+\.[a-z0-9]+' /root/strace.httpd | awk '{ print $2 }' FS="\"" > /root/httpd.usage


    i did not get it i mean my apache config is different ... and the vhosts are taken from the httpd.conf
     
  4. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    From what I understood here, what this does is extract all the domains from strace.httpd file and it gets the domains from /home/httpd/vhosts, which i'm sure it doesn't exist on cpanel servers. Try changing to this:

    egrep -i '/etc/valiases/[-_a-z0-9/]+\.[a-z0-9]+' /root/strace.httpd | awk '{ print $2 }' FS="\"" > /root/httpd.usage

    from what I know /etc/valiases has a list of all the domains on the server, I think this will do the job, try it out and let me know.
     
  5. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    526
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brno, Czech Republic
    did not show pretty well. you can try and test it yourself as well. let me know of the results. i might need to let it grep more though , or log more.
     
  6. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    I'll try it soon, i'll let you know the results.
     
  7. katmai

    katmai Well-Known Member

    Joined:
    Mar 13, 2006
    Messages:
    526
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brno, Czech Republic
    been busy with some other stuff. did u manage to test it out?
     
  8. Rafaelfpviana

    Rafaelfpviana Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    142
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Brazil
    Ok, I tested.

    try it with this:

    Code:
    root@server [/]# for i in $(ps -C httpd --no-headers | awk '{ print $1 }'); do PIDS="$PIDS -p $i"; done
    root@server [/]# strace -vvFf -o /root/strace.httpd $PIDS
    
    Code:
    root@server [/]# egrep -i '/home/[-_a-z0-9/]+' /root/strace.httpd | awk '{ print $2 }' FS="\"" > /root/httpd.usage
    
    the problem with the other code was that we were looking for the domain but what we need to look for was the user's directory, or the directory of the users httpd files which in cpanel are located in /home/username

    Try it out.
     
    #8 Rafaelfpviana, Dec 12, 2006
    Last edited: Dec 12, 2006
Loading...

Share This Page