Apache trace root of problem

katmai

Well-Known Member
Mar 13, 2006
564
3
168
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,
 

katmai

Well-Known Member
Mar 13, 2006
564
3
168
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
 

Rafaelfpviana

Well-Known Member
Mar 12, 2004
141
0
166
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.
 

katmai

Well-Known Member
Mar 13, 2006
564
3
168
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.
 

katmai

Well-Known Member
Mar 13, 2006
564
3
168
Brno, Czech Republic
been busy with some other stuff. did u manage to test it out?
 

Rafaelfpviana

Well-Known Member
Mar 12, 2004
141
0
166
Brazil
Ok, I tested.

try it with this:

Code:
[email protected] [/]# for i in $(ps -C httpd --no-headers | awk '{ print $1 }'); do PIDS="$PIDS -p $i"; done
[email protected] [/]# strace -vvFf -o /root/strace.httpd $PIDS
Code:
[email protected] [/]# 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.
 
Last edited: