Ki jan yo enstale epi sèvi ak ngxtop sou Ubuntu 20.04

Gid sa a pral moutre w kouman pou w enstale ak itilize ngxtop. Lojisyèl sa a se yon zouti siveyans gratis, sous ouvè, fleksib ak an tan reyèl pou sèvè wèb Nginx la. Ki jan li fonksyone se pwogram nan analize mòso bwa aksè Nginx yo epi enprime enfòmasyon sou kantite demann, URI ak kòd estati yo nan mitan karakteristik prensipal yo. Sa a se yon pi renmen pou sysadmin oswa itilizatè pouvwa ki vle yon zouti ki lejè pou kontwole demann nan sèvè entènèt Nginx yo.

Kondisyon

  • Ubuntu sèvè 20.04 oswa ivè.
  • Nginx aktyalizasyon sèvè jiska dat ki estab oswa liy prensipal.
  • Aksè rasin oswa yon kont ak privilèj sudo.
  • Mizajou nan sistèm dat.
  • Python 3 ak PIP 3 enstale.
sudo apt update && sudo apt upgrade -y \
sudo apt install python3 python3-pip

reklam


Enstalasyon ngxtop

Avèk python ak pip enstale, nou ka kounye a kontinye enstale ngxtop. Antre kòmandman sa a.

pip3 install ngxtop

Yon fwa enstale, konfime vèsyon an.

ngxtop --version

Egzanp pwodiksyon:

xstat 0.1

Ki jan yo sèvi ak ngxtop

Koulye a, kouri kòmand ngxtop la san okenn agiman pral montre rezime kantite demann, URI yo mande a, kantite demann pa kòd estati a.

ngxtop

Egzanp pwodiksyon:

running for 411 seconds, 64332 records processed: 156.60 req/sec
 Summary:
 |   count |   avg_bytes_sent |   2xx |   3xx |   4xx |   5xx |
 |---------+------------------+-------+-------+-------+-------|
 |   64332 |         2775.251 | 61262 |  2994 |    71 |     5 |
 Detailed:
 | request_path                             |   count |   avg_bytes_sent |   2xx |   3xx |   4xx |   5xx |
 |------------------------------------------+---------+------------------+-------+-------+-------+-------|
 | /abc/xyz/xxxx                            |   20946 |          434.693 | 20935 |     0 |    11 |     0 |
 | /xxxxx.json                              |    5633 |         1483.723 |  5633 |     0 |     0 |     0 |
 | /xxxxx/xxx/xxxxxxxxxxxxx                 |    3629 |         6835.499 |  3626 |     0 |     3 |     0 |
 | /xxxxx/xxx/xxxxxxxx                      |    3627 |        15971.885 |  3623 |     0 |     4 |     0 |
 | /xxxxx/xxx/xxxxxxx                       |    3624 |         7830.236 |  3621 |     0 |     3 |     0 |
 | /static/js/minified/utils.min.js         |    3031 |         1781.155 |  2104 |   927 |     0 |     0 |
 | /static/js/minified/xxxxxxx.min.v1.js    |    2889 |         2210.235 |  2068 |   821 |     0 |     0 |
 | /static/tracking/js/xxxxxxxx.js          |    2594 |         1325.681 |  1927 |   667 |     0 |     0 |
 | /xxxxx/xxx.html                          |    2521 |          573.597 |  2520 |     0 |     1 |     0 |
 | /xxxxx/xxxx.json                         |    1840 |          800.542 |  1839 |     0 |     1 |     0 |

Apre sa, si ou vle wè yon lis pi gwo koneksyon aleka ak sèvè Nginx ou a, tape sa ki annapre yo.

ngxtop top remote_addr

Egzanp pwodiksyon:

running for 20 seconds, 3215 records processed: 159.62 req/sec
 top remote_addr
 | remote_addr     |   count |
 |-----------------+---------|
 | 118.173.177.161 |      20 |
 | 110.78.145.3    |      16 |
 | 171.7.153.7     |      16 |
 | 180.183.67.155  |      16 |
 | 183.89.65.9     |      16 |
 | 202.28.182.5    |      16 |
 | 1.47.170.12     |      15 |
 | 119.46.184.2    |      15 |
 | 125.26.135.219  |      15 |
 | 125.26.213.203  |      15 |

Si ou ta renmen wè repons 4xx oswa 5xx ak referans HTTP tache, ou ka antre lòd sa a:

ngxtop -i 'status >= 400' print request status http_referer

Egzanp pwodiksyon:

running for 2 seconds, 28 records processed: 13.95 req/sec
 request, status, http_referer:
 | request   |   status | http_referer   |
 |-----------+----------+----------------|
 | -         |      400 | -              |

Sa yo se jis kèk egzanp. Ou ka jwenn yon lis konplè nan konbinezon pi ba a.

eUsage:
  ngxtop [options]
  ngxtop options 
  ngxtop info
 Options:
  -l , --access-log   access log file to parse.
  -f , --log-format   log format as specify in log_format directive.
  --no-follow  ngxtop default behavior is to ignore current lines in log
       and only watch for new lines as they are written to the access log.
       Use this flag to tell ngxtop to process the current content of the access log instead.
  -t , --interval   report interval when running in follow mode [default: 2.0]
 -g , --group-by   group by variable [default: request_path]
  -w , --having   having clause [default: 1]
  -o , --order-by   order of output for default query [default: count]
  -n , --limit   limit the number of records included in report for top command [default: 10]
  -a  …, --a  …  add exp (must be aggregation exp: sum, avg, min, max, etc.) into output
 -v, --verbose  more verbose output
  -d, --debug  print every line and parsed record
  -h, --help  print this help message.
  --version  print version information.
 Advanced / experimental options:
  -c , --config   allow ngxtop to parse nginx config file for log format and location.
  -i , --filter   filter in, records satisfied given expression are processed.
  -p , --pre-filter  in-filter expression to check in pre-parsing phase.

reklam


Kòmantè ak konklizyon

Ou te aprann ki jan yo enstale ngxtop pou sèvè Nginx ou sou Ubuntu, yon sistèm opere. Remake byen, sa a se pou siveyans esansyèl ki lejè, rapid ak pwòp pou chèche estatistik espesifik nan mòso bwa ou yo. Si w ap chèche pou yon bagay ki pi avanse ak yon WebUI, yon pake analiz bon ap bezwen enstale.

Ban-m pran abònman
Notifye nan
0 kòmantè
Aliye komantè
Wè tout kòmantè
0
Ta renmen panse ou, tanpri fè kòmantè.x