Monitoring web server is essential to see what’s happening on your website. Lately, I was looking for some sort of solution and came across ngxtop which helps you to monitor various metrics including following.

In this article, I’ll explain how to install and use ngxtop for Linux and Ubuntu OS.

Previously, I have used GoAccess Log Analyzer and found ngxtop is a lightweight and good choice for Nginx web server metrics monitoring.

This assumes you have Nginx installed and running. If not then you can refer my installation guide.

Little introduction about ngxtop

ngxtop is a python based program, which you can install on top of Python. Once installed, you can execute ngxtop and you will notice it looks like typical top output on Linux but with Nginx related information.

To Install ngxtop on Linux (tested on CentOS 7-64bit)

First, you need to install PIP (Python Package Management System). To do so…

  • Login to your server with root credential
  • Enable EPEL repository by installing below package
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpm
rpm -ivh epel-release-7-6.noarch.rpm

Now, install pip with below command

yum install python-pip

And finally use below to install ngxtop

pip install ngxtop

To Install ngxtop on Ubuntu

Use below command to install PIP

apt-get install python-pip

And now use following to install ngxtop

pip install ngxtop

Installation is easy. Isn’t it? Let’s see some of the real-time metrics.

Nginx Activity Summary

Use ngxtop command to view the summary of request count, requested URI, the number of request by status code.

ngxtop

Tip: you can use to find broken link by looking at a request, which has a status code as 404.

Check top client’s IP

It’s very handy to see who is making a large number of requests to your Nginx server.

ngxtop top remote_addr

ngxtop-remote-addr

How about displaying request only, which has 404 status code?

ngxtop -i 'status >= 404'

It’s not just real-time but also you can analyze it offline by parsing access log.

To analyze access.log, you can use:

ngxtop –l /path/access.log

Another example would be to parse the offline access.log from Apache

ngxtop –f common –l /path/access.log

There is multiple combinations you can use to filter out access.log for meaningful data. You can always refer the official GitHub project of ngxtop for more information.