Ngxtop: Real-time monitoring of Nginx artifacts in the command line

Source: Internet
Author: User
Tags nginx server

The Nginx Web server needs to be monitored in real time when it is running in a production environment. In fact, the network monitoring software, such as Nagios, Zabbix, Munin, supports Nginx monitoring.

If you do not need the above software to provide comprehensive reporting or long-term data statistics function, just need a quick and easy way to monitor the Nginx server request, I suggest you adopt a command line tool called Ngxtop.

You'll soon find out that ngxtop from the interface and name all draw on the famous top command. Ngxtop is displayed in real time using an interface similar to the top command by analyzing Nginx or other log files. You can say that you know other high-end monitoring tools, but in the simplicity of this aspect ngxtop is undoubtedly the best. Simplicity means that there is no substitute.

In this guide, I'll show you how to use Ngxtop to monitor Nginx Web servers in real time.

Installing Ngxtop on Linux

First, install the dependent library PIP in the Linux system (Ngxtop is written in Python).

Then install ngxtop using the following command.

$ sudo pip install Ngxtop

Ngxtop use

The basic use method is as follows:

ngxtop [Options]

ngxtop [Options] (print|top|avg|sum) <var>

Ngxtop Info

Here are some common options.

    • -L: Specifies the full path to the log file (Nginx or Apache2)

    • -F: Log format

    • –no-follow: Processing the log file that is currently written, rather than processing the newly added log files to the log file in real time

    • -T: Update frequency

    • -N: Show line numbers

    • -O: Collation (default is Access count)

    • -A ...: Add an expression (typically an aggregate expression such as: Sum, Avg, MIN, max, etc.) to the output.

    • -V: Output details

    • -I: Only rules-compliant records are processed

Here are some built-in variables whose meanings are self-explanatory.

    • Bodybytessend

    • Http_referer

    • Httpuseragent

    • Remote_addr

    • Remote_user

    • Request

    • Status

    • Time_local

Using Ngxtop to monitor Nginx

Ngxtop will find the address of the Nginx log from its configuration file (/etc/nginx/nginx.conf) by default. So, to monitor Nginx, run the following command:

$ ngxtop

This will list 10 Nginx services, sorted by the number of requests.

Show the top 20 most frequent requests:

$ ngxtop-n 20

Get Nginx Basic information:

$ ngxtop Info

You can customize the variables that are displayed and simply list the variables that need to be displayed. Use the Print command to display a custom request.

$ ngxtop Print Request Http_user_agent REMOTE_ADDR

Display the most requested client IP address

$ ngxtop Top REMOTE_ADDR

The Display status code is 404 requests

$ Ngxtop-i ' status = = 404 ' Print request status

In addition to Nginx,ngtop can also handle other log files, such as Apache access files. Use the following command to monitor the Apache server:

$ tail-f/var/log/apache2/access.log | Ngxtop-f Common

Ngxtop: Real-time monitoring of Nginx artifacts in the command line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.