ngxctl - Real-time Metrics for Nginx Server
Project Overview
- Rebuilt based on the ngxtop project and adapted for actual usage scenarios.
- The core principle remains the same: parsing log contents and storing them in SQLite, displaying top statistics in real-time using GROUP BY. As such, it is not suitable for long-term operation.
Installation
# Install from PyPI
pip install ngxctl
# Install from Tencent Cloud source
pip install ngxctl --index-url https://mirrors.cloud.tencent.com/pypi/simple --trusted-host mirrors.cloud.tencent.com
Usage
Display Configured Log Files
# cmd
ngxctl files
# output example
| server_name | file_name | log_path |
|---------------------+-------------------------------------------------+-------------------------------------------|
| www.test1.net... | /etc/nginx/sites-enabled/www.test1.net.conf | /var/log/nginx/www.test1.net-extended.log |
Display Variables Used in Access Logs
# cmd
ngxctl vars
# output
| Variables |
|-----------------|
| http_referer |
| status |
| http_user_agent |
| body_bytes_sent |
| request |
| time_local |
| remote_addr |
| remote_user |
| request_id |
Display Top Statistics
Basic Command
# cmd (output omitted)
running for 7 seconds, 0 records processed
ServerName Top Stat
| server_name | count | 2xx | 3xx | 4xx | 5xx | avg_bytes_sent | sum_bytes_sent | start_time | end_time | req/s |
|---------------+---------+-------+-------+-------+-------+------------------+------------------+--------------+------------+---------|
| Detailed content is omitted here |
Supported Parameters
Usage: ngxctl top [OPTIONS]
Analyze and display top Nginx log statistics.
Examples:
ngxctl top
ngxctl top --conf /etc/nginx/nginx.conf
ngxctl top --group-by remote_addr,http_user_agent
ngxctl top -w 'status==404' --no-follow
Options:
-g, --group-by TEXT Group the results by the specified fields, e.g.,
server_name,remote_addr, etc.
-o, --order-by TEXT Order the results by a specified criteria, e.g.,
avg(bytes_sent) * count.
--where TEXT Apply a filter to the raw log data before stat,
e.g., status==404.
--having TEXT Apply a filter to stat result, e.g.,
remote_addr==1.2.3.4.
-n, --limit INTEGER Limit to top lines.
--follow / --no-follow Read the entire log file at once instead of
following new lines.
-h, --help Show this message and exit.
Running from source
python -m ngxctl.cli
Metadata
Release files for ngxctl 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ngxctl-0.1.5.tar.gz | 17.6 kB | Without provenance | Details for ngxctl-0.1.5.tar.gz |
Release files / ngxctl-0.1.5.tar.gz
| Download URL | ngxctl-0.1.5.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d39ebffb90e9698b7c4167c53a7711d21f496ca2a1c48e6fafb2b2e1d29eaca
|
|
BLAKE2b-256 checksum How to use checksums |
7bae8d587b67d3d0d4edd2295f21a9603bc028cb6aed7a67172542d0365e93ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.8.19
|
Security for ngxctl 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.