Use Apachetop To Monitor Web Server Traffic In Real Time

Updated on January 25, 2016
Use Apachetop To Monitor Web Server Traffic In Real Time header image

In this tutorial, we will be covering the process of instilling and using apachetop, a command line-based piece of software that allows real-time traffic monitoring for Apache, Nginx web servers. It it also expected to work with other web servers such as Litespeed and Lighttpd.

Using apachetop allows a server administrator to view visitors, their IP Addresses, accessed URLs, referrers etc… — all in real time.

Installing apachetop

The apachetop package is available under the EPEL Yum Repository:

sudo yum -y install epel-release
sudo yum clean all
sudo yum -y update
sudo yum -y install apachetop

Running apachetop

sudo apachetop

The above command will launch apachetop and will will try to find the access log of an Apache server in its location: /var/log/httpd/access_log.

If you customized your vhost to use a custom log path, you will need to specify the custom path using the -f parameter as follows:

sudo apachetop -f /var/log/nginx/wordpress_http_access.log

By default, apachetop will display the statistics for the visits from the last 30 seconds. You can modify that using the -H and -T parameters as follows:

sudo apachetop -f /var/log/nginx/wordpress_http_access.log -H 1000

The command above will display stats on the last 1000 hits.

sudo apachetop -f /var/log/nginx/wordpress_http_access.log -T 600

The command above will display stats on the last 600 seconds.

The apachetop Interface

On the top of the screen, you will find a short summary for visits, stats etc…

last hit: 13:59:43         atop runtime:  0 days, 00:42:31             14:02:14
All:           19 reqs (   0.0/sec)        111.3K (  151.8B/sec)    6001.0B/req
2xx:      12 (63.2%) 3xx:       7 (36.8%) 4xx:     0 ( 0.0%) 5xx:     0 ( 0.0%)
R ( 30s):       0 reqs (   0.0/sec)          0.0B (    0.0B/sec)       0.0B/req
2xx:       0 ( 0.0%) 3xx:       0 ( 0.0%) 4xx:     0 ( 0.0%) 5xx:     0 ( 0.0%)

The first line consists of:

  • last hit: the time of the last hit
  • atop runtime: apachtop running time, and
  • the current time of the server.

The second and the third lines provide statistics on all visits since the apachetop program gets started. 2xx, 3xx, 4xx, and 5xx represent corresponding web server response codes.

The fourth and the fifth lines provide the same statistics as the two lines above, except that they focus on visits in a specified scope which is 30 seconds by default.

Below the summary is a list of all visits and requests:

	1  0.10   9.8  1.0/
	1  0.14  13.6  1.9*/2016/01/25/hello-world/
	2  0.18  18.2  1.7 /category/uncategorized/
	1  0.07   9.9  0.7 /2016/01/

The asterisk represents a Selected Line.

Additional, apachetop contains built-in shortcuts:

  • Up/Down arrow keys: switch to another request.
  • Right arrow key: see the details of the request you have chosen, including the visitor's IP address and the referrer, etc.
  • Left arrow key: return to the list.
  • p: pause the display.
  • q: quit the program.
  • h: display help info.

This concludes our tutorial. Thank you for reading.