Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to monitor Nginx server in real time

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to monitor the Nginx server in real time". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to monitor Nginx server in real time.

The primary responsibility of the Linux operation and maintenance engineer is to ensure the stable operation of the business 7 x 24 hours a day. Monitoring the Web server is very important to see what is happening on the website. The biggest concern is log changes. Your first reaction to viewing real-time log file changes should be the 'tail-f / path/to/log' command, but it would be quite crashing if every website's access logs are viewed in this way. Today, I would like to share with you a powerful Nginx log monitoring tool.

Ngxtop is a python-based program that can be installed on Python. Ngxtop parses the nginx access log in real time and outputs the result (a useful indicator of the nginx server) to the terminal.

Main function

Current valid request

Summary of total request count

Total number of requests provided by status code (2xxrem 3xxrem 4xxrem 5xx)

Send average bytes

Top-level remote address

It can not only monitor the access of Nginx logs in real time, but also sort out the previous logs.

Install ngxtop on Linux

The following actions are tested on CentOS 7-64bit

First, you need to install PIP (Python package Management system).

Log in to your server with root credentials

Enable the EPEL repository by installing the following package

Wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-6.noarch.rpmrpm-ivh epel-release-7-6.noarch.rpm then execute the following command to install pipyum install python-pip

Ngxtop download connection: https://download.csdn.net/download/KH_FC/12026826

Finally, use the following installation ngxtoppip install ngxtopngxtop for detailed instructions

Usage:

Ngxtop [options] ngxtop [options] (print | top | avg | sum) ngxtop info

Options:

Ngxtop practice

1. Use the ngxtop command to view the request count summary, the URI requested, and the number of status code requests. **

$ngxtop

two。 Check the IP** of the top-level client

Find out who made a large number of requests to your Nginx server.

Ngxtop top remote_addr

3. Only 404 HTTP requests show * *

Ngxtop-i'status > = 404'

4. Analyze access.log**

Ngxtop-l / path/access.log

5. Parsing the offline access.log** of Apache

Ngxtop-f common-l / path/access.log

In addition, you can use a variety of combinations to filter access.log to get useful data

At this point, I believe you have a deeper understanding of "how to monitor the Nginx server in real time". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report