ngxtop实时监控nginx

1. 安装ngxtop

yum install python python-pip -y

yum install ngxtop  -y

2 配置 nginx 日志

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                         '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
    
    access_log  logs/access.log  main;
 

ngxtop实时监控nginx

3监控

1 [[email protected] logs]# ngxtop -c /usr/local/nginx/conf/nginx.conf 
Error: access log file "logs/access.log" does not exist
有问题 没有找到  "logs/access.log"

2 ngxtop -c /usr/local/nginx/conf/nginx.conf  -l /usr/local/nginx/logs/access.log 

起动成功

结果:

ngxtop实时监控nginx

访问量前十的IP

ngxtop -c /usr/local/nginx/conf/nginx.conf top remote_addr -l /usr/local/nginx/logs/access.log 

注意 :空格

结果:

ngxtop实时监控nginx