android bsd linux unix & open-source world


How To monitor Apache traffic in real-time with apachetop

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed or subscribe via E-mail for updates on this topic.

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 Print This Post
Comments (3) Trackbacks (0)
  1. Thanks for this great post wow…

  2. Great post, very thorough discussion of the topic.
    Does anybody know where can find additional info on this subject?
    Thanks for any input.

  3. Chriss, check this out:
    It’s the official site of apachetop project.

Leave a comment


No trackbacks yet.