How-To Geek

Monitor Your Website in Real-Time with Apachetop

As a webmaster, I’ve often wanted to be able to see real-time hits as they arrive. Sure, Google Analytics is a wonderful package for looking at trends over time, but there’s a delay of a few hours there, and you really can’t see data like requests per second or total bytes.

This is where the apachetop utility comes in. It’s a very simple command line utility that you can use to monitor traffic real-time. It accomplishes this by parsing the apache logfiles and displaying meaningful output to the screen.

Using Apachetop

Once you’ve installed the utility (instructions below), you can launch it by simply running apachetop from the command line. Since apachetop sometimes defaults to the wrong directory for the logfiles, you can pass in the -f parameter to specify the location of the logfile. This is also helpful when you have many virtual hosts on the same box.

apachetop -f /var/www/vhosts/

This is what you’ll see after a few requests have come in:


Monitoring Timeframe

The first thing to note is that the default time range for data shown is 30 seconds, so don’t expect the total counts to continue to climb forever. You can change this by passing in a few different arguments.

apachetop -H hits  (Will display stats on the last x number of hits)

apachetop -T secs  (Will display stats on the last x number of seconds)

I’ve been using a range of 5-10 minutes in my testing, and it really shows some useful feedback. There’s other options you can try out as well.



The next thing to note is that you can filter what gets shown in the view. To access the filters, use the f key, and you should see a small line pop up.

Hit the a key to add a filter and the line should switch. Now you can choose to filter by URL, referrer, or host.

I’m going to choose URL by hitting the u key. The filter dialog will show up near the bottom:

Since all of my articles are under the subdirectory /howto/, I’m going to enter that. Now apachetop will only show the hits relevant to hits to the articles, instead of every hit for every image.


Viewing Request Details

If you use the up/down keys, you’ll notice the cursor move up and down to allow you to select a request. (notice the * char)

If you hit the Right arrow key, you’ll be taken to the details page for that request. From here you can see the actual hosts hitting your site, as well as the referrers. I’m not going to show the hosts, since I don’t want to give out user’s IP address, but you can see the referrer here:

To go back to the list, just use the Left arrow key.


Switch Between Hosts, Referrers and URLs

If you use the d key, you can easily switch between the different views.

For instance, here I can see what traffic StumbleUpon is sending me, and then I can use the details view(right arrow) to see the exact articles that are getting hit from stumbleupon.



At any point you can hit the ? or the h keys to take you to the help screen, which will give you a quick view of all the options.

I find the sort by very useful.


Installing on Ubuntu

sudo apt-get install apachetop


Installing from Source on CentOS


yum install readline-devel

yum install ncurses-devel

tar xvzf apachetop-0.12.6.tar.gz

cd apachetop-0.12.6



The binary can be found in src/apachetop, and you can copy it anywhere you’d like.


Installing from Source on Ubuntu


sudo apt-get install ncurses-dev

sudo apt-get install libreadline5-dev

tar xvzf apachetop-0.12.6.tar.gz

cd apachetop-0.12.6



 The binary can be found in src/apachetop, and you can copy it anywhere you’d like.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 04/3/07

Comments (15)

  1. Buy cheap viagra

    Hello, my name is Alfred, i’m a newbie here. I really do like your forum and really interested in things you discuss here, also would like to enter your community, hope it is possible:-) Cya around, best regards, Alfred!

  2. nacho

    Awesome, man!!!!

    I was looking EXACTLY for this!!! You rock!

    Keep up the good work…

    And off course, excuse my poor english!


  3. W.

    Is there a way to only get the text without the escape sequences ? (I’d like to log teh output to a file to parse it later after something interesting has happened)

  4. Spiderman Freak

    You can stop memory leaks using the freeware tool called FAST DEFRAG by AMS. Google it sometime. It is worth running and uses only kilobytes of mem to run.

  5. Sean S

    You can also download RPM’s from RPMforge:

    My RHEL boxes also needed ADNS:

  6. glasnost

    Well Done! I Like it!

  7. Danman

    It does not work, of course always with me. I have centOs i installed everything perfectly but the command apachetop in de /src dir DOES NOT WORK, command not found.

    Waste of time..

  8. jan

    It runs perfectlly.

    Try with correct syntax: ./apachetop (inside apachetop-0.12.6/src, of course)

    I guess frist you should “waste” your time learning linux first.

  9. william

    works great!

  10. william

    should note – even works with lighttpd access logs as typically their the same

  11. Mike

    Is there a parameter or capability to have apachetop look at multiple logs, ie error access and other access logs from 3 Other vhosts

    I like to keep an access log and error log for each to keep things clean. Thanks!

  12. Shawn

    @Jan: LOL! Well said… I was going to say something similar… CentOS is a “waste of time” but really it is great for those who know how to use it.

    I NEED something 99% like apachetop but with the option to be able to KILL the process!

    With htop you have the option to kill the listed processes and I also have a similar program to apachetop and htop called iptop and it is a GREAT little program with a lot of useful information but just missing that 1 little option I need, to KILL the listed process’ like htop.

    Of course I have been Googling my head off (imo, you don’t have the right to ask if you haven’t tried google, kinda like complaining about politics without voting :P ) which is what lead me here but I still haven’t found what I am looking for so if you have any suggestions I will be GREATLY appreciative! Which means nothing to you I know but if I had lots of money, I would give you some. Does that help? :P

    Thanx for your time. :D

  13. Cristiano

    My name is Chris,
    I use Ubuntu,
    I can not run, alias, apachetop was installed correctly, when you open it, carries no information, what’s going on?
    I wait for help, thank you.

  14. PJ Brunet

    I’m wondering if the URL view can be easily hacked to show the domain names.

  15. LF Vazquez

    algien puede decirme como verificar que el apachetop este corriendo si ya lo instale unos pequeños pasos de uso se los agradecere :(

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!