Sunday, January 27, 2019

linux - Apache uses 100% CPU. Can "ps" command tell me what it is doing?



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?


Answer



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.
#

SetHandler server-status
Order deny,allow
Deny from all
Allow from .example.com
Allow from 127. 192.168.1.




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. a grid of what each process is doing


  5. 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



No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...