Loading...
Real Time Concepts

strace apache child serving your request

Overview

First of all we will identify the PID of apache child process serving our request and we will then strace that specific PID while it is serving our HTTP request.

LIMITATION: You have to have telnet installed and there is no guarantee that the apache child process
you are attached to is/was not serving any other requests.

Note: Telnet disconnection time is dependent on the Connection Timeout Value within httpd.conf

Usage

First of all we will telnet to port 80 locally on the sever.

[root@web-server3 ~]# telnet 0 80
Trying 0.0.0.0…
Connected to 0.
Escape character is ‘^]’.
GET /HTTP/ 1.1 Host:abc.com

Note: To get a response you will have to hit enter twice, Do Not do that at this stage as we need to start the trace first so that we can analyze apache behavior to our request.

Find the PID serving your request, we can do this just by looking at telnet process connected to apache on port 80.

[root@web-server3 ~]# netstat -plnta | grep telnet
tcp 0 0 127.0.0.1:50157 127.0.0.1:80 ESTABLISHED 27995/telnet
[root@web-server3 ~]# netstat -plnta | grep 50157
tcp 0 0 127.0.0.1:50157 127.0.0.1:80 ESTABLISHED 27995/telnet
tcp 0 0 ::ffff:127.0.0.1:80 ::ffff:127.0.0.1:50157 ESTABLISHED 16426/httpd

Now we can easily strace the very apache child process serving our request.

[root@web-server3 ~]# strace -o /home/rack/apache.strace -r -s4096 -p 16426
Process 16426 attached – interrupt to quit

Now you hit enter (the second time) within your telnet session and your strace file will start getting populated

Leave a Reply

Your email address will not be published. Required fields are marked *