Find Long running request in Apache

request-time
mm
Written By:- Santosh Prasad

If Apache is going down you need to see Apache status and find out the long running request in Apache. You can use below command and kill the process if needed .

#links --dump 1 http://east.example.com/server-status|grep ^[0-9]|awk 'BEGIN {print "Seconds, PID, State, IP, Domain, TYPE, URL\n--"} $4 !~ /[GCRK_.]/ {print $6, $2, $4, $11, $12, $13 " " $14|"sort -n"}'

 Here :

Second : Apache process running request time

PID : Process ID

State : Request status

IP : Client IP which is making request

Domam :  Virtual Host

TYPE : Http

URL : Requested url

You can use it as a scripts instead of typing command every-time. If you see high load on your server you can run this script.

After running script you can see the below output :

Command Output:

Seconds, PID, State, IP, Domain, TYPE, URL

0 5495 W 127.0.0.1 east.example.com GET /server-status

0 5710 W 199.27.134.187 east.example.com GET

2 5495 W 162.158.34.131 east.example.com POST

32 5710 W 10.12.146.154 east.example.com GET /train/cour/?title=fo7-external-cour&c=1&p=2

37 5710 W 10.12.146.154 east.example.com POST

Note : You will need to enable server status page.

Enabling Apache Status Page

To enable status page you will need to edit httpd.conf file.

#vim /etc/httpd/conf/httpd.conf

ExtendedStatus on
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from east.example.com
</Location>

Save and exit.

After edited httpd.conf file you will need to restart Apache service.

#service httpd restart

Thanks:)

About Author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Other Post by Santosh Prasad

Visit All Post

Related Article

You may also Like

Leave a Comment

Shares