Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a SLES 10 Linux server, and some times it is maxed out by Apache to 100% CPU.

With ps ax can I see, that Apache have spawned ~50 Apache processes.

Can e.g. the ps command tell me what each of these Apache processes are doing?

Or perhaps some other method so I can see what web pages that triggers the problem?

share|improve this question
add comment

5 Answers

up vote 12 down vote accepted

My /etc/httpd/conf/httpd.conf file has this section:

# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Change the ".example.com" to match your domain to enable.
#
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from .example.com
    Allow from 127. 192.168.1.
</Location>

Thus if I go to http://192.168.1.1/server-status, I get a page that tells me:

  1. server version
  2. httpd uptime
  3. current CPU usage
  4. # of requests being processed and # of idle workers
  5. a grid of what each process is doing
  6. recent requests

    Apache Server Status for 192.168.3.1

    Server Version: Apache/2.2.3 (Red Hat)
    Server Built: Jul 14 2009 06:04:04

    Current Time: Saturday, 17-Jul-2010 10:20:31 CDT
    Restart Time: Saturday, 17-Jul-2010 10:13:12 CDT
    Parent Server Generation: 0
    Server uptime: 7 minutes 19 seconds
    Total accesses: 51 - Total Traffic: 156 kB
    CPU Usage: u0 s0 cu0 cs0
    .116 requests/sec - 363 B/second - 3132 B/request
    1 requests currently being processed, 7 idle workers

    W___........................................................
    ................................................................
    ................................................................
    ................................................................

    Scoreboard Key:
    "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
    "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
    "C" Closing connection, "L" Logging, "G" Gracefully finishing,
    "I" Idle cleanup of worker, "." Open slot with no current process

    Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request
    0-0 20715 0/2/2 _ 0.00 418 0 0.0 0.01 0.01 192.168.3.97 dit GET /server-status HTTP/1.1
    1-0 20716 0/49/49 _ 0.00 128 0 0.0 0.15 0.15 192.168.3.97 dit GET /server-status HTTP/1.1
    2-0 20717 0/0/0 W 0.00 0 520222374 0.0 0.00 0.00 192.168.3.97 dit GET /server-status HTTP/1.1

share|improve this answer
    
You may need to set ExtendedStatus ON to see each request –  TonyUser Jul 18 '10 at 14:50
add comment

strace can tell you what a specific process is doing at the level of system calls, but it won't give you a "50-foot view" of what is happening. You will need to piece together the system calls it's using in order to figure that out.

share|improve this answer
add comment

If you have a website with a database backend then you could look in the DBMS what commands are currently running. Maybe this could help you to narrow down where in your code of the website the load is generated.

Else you could increase the log level of the httpd daemon. Then you have more information in the logs.

share|improve this answer
add comment

There is also ltrace, which works like strace but with library calls.

share|improve this answer
add comment

You might find top more informative than ps.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.