Spying on Apache and PHP with Strace
Video Statistics and Information
Channel: spudlyo
Views: 22,855
Rating: undefined out of 5
Keywords: linux, apache, php, strace
Id: eF-p--AH37E
Channel Id: undefined
Length: 15min 0sec (900 seconds)
Published: Tue Mar 15 2011
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
I do the same thing with a slight twist: ~> strace /usr/bin/php5 filename.php | less -S
This allows me to check on a per file basis where the delay's are happening.
Thanks for this, very nice video. There were a few things you did that I don't know how to do.
How did you get the dialog of screens to select from to show up?
How were you searching your bash history?
How were you searching in man?
How did you delete everything after the cursor?
Thanks!
I had a quick go at this, but apache doesn't wait long enough for me to type commands in, get the pid, set up strace and finish the page request. Does anyone know where the wait is defined in apache? I set my timeout to 30 seconds and keepalive to 20 to see if that helped but it made no difference.
I think this video is great, but wouldn't it be better to use something like xdebug and kcachegrind to debug problems like that? It will give you a much better breakdown of slow running scripts.
TIL about the
pidof
command! That will save me some ridiculousps | grep |cut
garbage.Strace helped me debug a php/apache segmentation fault recently, showed the SQL leading to the seg fault. It's a useful tool.
I know this was posted to /r/linux, but you might also look at dtrace, ktrace or truss depending on what you are running on.
Strace is very useful. Last week we had a system that was hacked, and a few backdoors were thrown into place. While the attackers did backdoor a number of local binaries (mainly just sshd, and apache), they forgot about strace. A lot of useful information about how how sshd was backdoored was gleamed from stracing the sshd process, and setting up strace to track the subprocesses as well.. Pretty bizarre, ended up finding that whenever anyone logged in to ssh successfully, the login information for the account was passed off to a remote server in russia. Recovery of sshd was as easy as
yum reinstall openssh-server; /etc/init.d/sshd restart
.