Apache High CPU Usage Enable Mod_Status Guide Solution - Find Cause of High CPU Usage Script/Domain

mod_status is a great way to track down the source of high CPU usage and to find what vhost/script is the cause of it.

It gives you a live view of bandwith usage, CPU usage, and memory usage broken down by domain/vhost and script/URI.

Enable mod_status

vi /etc/httpd/conf/httpd.conf

ExtendedStatus On


SetHandler server-status

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

Add your IP after 127.0.0.1. Ibelieve you could also require an htaccess pasword if you want.

After that reload Apache and browse to your webserver to http://yourhost.com/server-status and you'll see something like below:


Apache Server Status for localhost

Server Version: Apache/2.2.3 (CentOS)
Server Built: Aug 30 2010 12:32:08

Current Time: Saturday, 30-Apr-2011 15:55:46 PDT

Restart Time: Thursday, 28-Apr-2011 23:03:58 PDT
Parent Server Generation: 3
Server uptime: 1 day 16 hours 51 minutes 48 seconds
Total accesses: 243995 - Total Traffic: 1.7 GB
CPU Usage: u18.36 s1.75 cu2.88 cs0 - .0156% CPU load
1.66 requests/sec - 12.1 kB/second - 7.3 kB/request
1 requests currently being processed, 3 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-3 22481 0/29/36628 W 0.42 0 0 0.0 0.04 307.98 9 testdomain.com GET /server-status?refresh=10 HTTP/1.1
1-3 18115 0/271/37239 _ 6.33 4 236 0.0 1.20 255.47 forums.testdomain.com POST /mgc_cb_evo_ajax.php HTTP/1.1
2-3 - 0/0/35305 . 0.61 54 0 0.0 0.00 235.80 forums.testdomain.com GET /forumdisplay.php?s=e5pr
3-3 - 0/0/34526 . 9.19 69 0 0.0 0.00 235.66 ::1 00-defaultsite.com OPTIONS * HTTP/1.0
4-3 22258 0/49/28952 _ 1.12 4 0 0.0 0.21 194.55 forums.testdomain.com GET /cpstyles/kartel/kartel/misc/down9x9.gif HTTP/1.1
5-3 19843 0/232/27942 _ 3.10 1 137 0.0 0.77 181.58 unitetest.com GET //index.php?action=profile;u=174 HTTP/1.1
6-3 - 0/0/19301 . 2.31 569 0 0.0 0.00 130.28 ::1 00-defaultsite.com OPTIONS * HTTP/1.0
7-3 - 0/0/16325 . 0.26 2102 0 0.0 0.00 141.16 ::1 00-defaultsite.com OPTIONS * HTTP/1.0
8-3 - 0/0/5534 . 0.01 2103 0 0.0 0.00 36.51 ::1 00-defaultsite.com OPTIONS * HTTP/1.0
9-3 - 0/0/2243 . 0.09 2100 0 0.0 0.00 15.39 ::1 00-defaultsite.com OPTIONS * HTTP/1.0


Srv Child Server number - generation
PID OS process ID
Acc Number of accesses this connection / this child / this slot
M Mode of operation
CPU CPU usage, number of seconds
SS Seconds since beginning of most recent request
Req Milliseconds required to process most recent request
Conn Kilobytes transferred this connection
Child Megabytes transferred this child
Slot Total megabytes transferred this slot

SSL/TLS Session Cache Status:
cache type: SHMCB, shared memory: 512000 bytes, current sessions: 3
sub-caches: 32, indexes per sub-cache: 133
time left on oldest entries' SSL sessions: avg: 6 seconds, (range: 6...7)
index usage: 0%, cache usage: 0%
total sessions stored since starting: 571
total sessions expired since starting: 568
total (pre-expiry) sessions scrolled out of the cache: 0
total retrieves since starting: 15093 hit, 512 miss
total removes since starting: 0 hit, 0 miss

Tags:

apache, cpu, usage, enable, mod_status, domainmod_status, vhost, bandwith, domain, uri, vi, etc, httpd, conf, extendedstatus, server, sethandler, ip, htaccess, pasword, reload, browse, webserver, http, yourhost, ll, localhost, centos, aug, apr, pdt, restart, pdtparent, uptime, secondstotal, accesses, gbcpu, cu, cs, requests, kb, currently, processed, idle, workers, w_, __, scoreboard, quot, _, reply, keepalive, dns, lookup, logging, gracefully, finishing, cleanup, slot, srv, pid, acc, ss, req, conn, testdomain, refresh, forums, mgc_cb_evo_ajax, php, forumdisplay, pr, defaultsite, cpstyles, kartel, misc, gif, unitetest, index, os, mode, milliseconds, kilobytes, megabytes, ssl, tls, cache, shmcb, bytes, sessions, caches, indexes, entries, avg, stored, expired, expiry, scrolled, retrieves, removes,

Latest Articles

  • Ubuntu Debian Linux Cannot Install Wine Solution - wine1.6 : Depends: wine1.6-i386 (= 1:1.6.2-0ubuntu14.2) but it is not installable wine1.4 : Depends: wine1.6 but it is not going to be installed
  • How To Install python 3.4 3.5 and up on Linux with wine - Working Solution
  • using Xvfb on virtual remote ssh server to have X graphical programs work
  • ssh Received disconnect from port 22:2: Too many authentication failures
  • named bind errors - DNSKEY: unable to find a DNSKEY which verifies the DNSKEY RRset and also matches a trusted key for '.'
  • OpenVZ vs LXC DIR mode poor security in LXC
  • httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load modules/libphp5.so into server: /lib64/libresolv.so.2: symbol __h_errno, version GLIBC_PRIVATE not defined in file libc.s
  • Radeon R3 GPU on Debian Crashing
  • MySQL 5.7 on Debian and Ubuntu - How To Reset Root Password
  • SSH and sshfs timeout settings keepalive
  • Linux How To Add User To Additional Group
  • Howto Set Static IP on boot in initramfs for dropbear or other purposes NFS, Linux, Debian, Ubuntu, CentOS
  • Convert and install to LUKS Encrypted Drive Ubuntu 18.04 19.10 Linux Mint and Debian Based Linux
  • Debian and Netplan
  • CentOS 8 how to restart the network!
  • CentOS 8 how to convert to a bootable mdadm RAID software array
  • ADATA USB Thumb Drive Issues
  • KMODE EXCEPTION NOT HANDLED - QEMU/KVM Won't Boot Windows 2016 or 10 Image or Physical Machine
  • Linux Mint / Ubuntu / Debian Mate Disable Guest Session and Hide Usernames on Lightdm Login screen GUI
  • SSH How To Create Public/Private Key Pair and with a Larger Keysize than 2048 bits