Apachetop is a very useful program that displays the stats for Apache in real time. Apachetop can show you how many requests per second are coming in, what files have been accessed and how many times. It can also show you who is hitting the sites and where they are coming from.
1. Installing apachetop
To install apachetop in CentOS, Fedora:
# yum install apachetop
Make sure you have DAG repository enabled.
To install apachetop in Debian, Ubuntu:
# sudo apt-get install apachetop
To install apachetop in FreeBSD:
# cd /usr/ports/sysutils/apachetop/
# make install clean
2. Using apachetop
apachetop essentially just watches the log files and constantly computes the stats. It can be set to show stats for the last set amount of time, or for the last set number of hosts.
It defaults to monitoring the defaults apache log file, but if you have virtual hosts, you will need to tell it to watch these also with the -f flag.
# apachetop -f /var/log/httpd/site1-access_log -f /var/log/httpd/site2-access_log
If your web server gets a low number of hits you can use the -N flag so that it shows you more information instead of clearing hits after 30 seconds. The -N flag sets the number of hits apachetop remembers. You can also use -T to change the length of time it remembers the hits.
This command will show stats for hits in the last 5 minutes.
# apachetop -N 300 -f /var/log/httpd/access_log
This command will have apachetop remember the last 100 hits and show the statistics for them.
# apachetop -T 100 -f /var/log/httpd/access_log
Once in apachetop the program will begin displaying and calculating the stats as they come in, so at first it will be blank. To switch between showing what files are getting hit, what hosts are accessing the web server, and where they are coming from press "d".
For the help menu press "h".Print This Post