• Nginx编译安装+监控模块vts


    目录

    一、准备安装包并解压

    二、安装依赖的编译软件

    三、编译安装nginx和模块

    四、优化管理

    五、修改配置文件

    六、验证

    七、监控模块各字段信


     

    nginx中的vts模块是非常好用的一款监控模块,能让我们清晰的观测到服务器当下状态

    一、准备安装包并解压

    首先我们准备好nginx和vts的安装包

    41525d782d9d499489bb75f650f9f5f3.png

     然后对其进行解压

    tar -zxvf nginx-1.22.0.tar.gz

    unzip nginx-module-vts-master.zip

    mv nginx-module-vts-master /usr/local

    f0b188ebb2e54a159ec305fe231ded6e.png 二、安装依赖的编译软件

    yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel make

    89e67e0919474efbb637228a50b5c74e.png

    这里我是已经全部安装过了

    三、编译安装nginx和模块

    useradd -M -s /sbin/nologin nginx

    #创建用户是为了让nginx更灵活,赋予更多的权限

    ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --add-module=/opt/nginx-module-vts-master/   

    5eafed276fd04a918a39b8a38de7d74a.png

     make && make install

    44db5b543a544a1e9b30fcd55df64108.png

    5e807ae6fb61458483ba9bfce2b87e41.png

     这样就安装完成了

    四、优化管理

    ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

    625fd1b903d5418aae03bd672ce9c2b3.png

     nginx -V #查看nginx安装信息

    02f9bda3451c45258b6175975a4727ee.png

    这里vts模块也加载上了

    nginx -t   #测试一下

    dd38ed204acc49dd8ffe2c55cb78fcf4.png

    五、修改配置文件

    vim /usr/local/nginx/conf/nginx.conf   #配置文件如下

    1. #user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. events {
    8. worker_connections 1024;
    9. }
    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;
    13. vhost_traffic_status_zone; #流量状态监控
    14. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. # '$status $body_bytes_sent "$http_referer" '
    16. # '"$http_user_agent" "$http_x_forwarded_for"';
    17. #access_log logs/access.log main;
    18. log_format main '{ "@timestamp": "$time_local", '
    19. '"@fields": { '
    20. '"uri":"$request_uri",'
    21. '"url":"$uri",'
    22. '"upstream_addr":"$upstream_addr",'
    23. '"remote_addr": "$remote_addr", '
    24. '"remote_user": "$remote_user", '
    25. '"body_bytes_sent": "$body_bytes_sent", '
    26. '"host":"$host",'
    27. '"server_addr":"$server_addr",'
    28. '"request_time": "$request_time", '
    29. '"request_time":"$request_time",'
    30. '"status":"$status",'
    31. '"request": "$request", '
    32. '"request_method": "$request_method", '
    33. '"size":$body_bytes_sent,'
    34. '"upstream_time":"$upstream_response_time"'
    35. '"http_referrer": "$http_referer", '
    36. '"body_bytes_sent":"$body_bytes_sent", '
    37. '"http_x_forwarded_for": "$http_x_forwarded_for", '
    38. '"http_user_agent": "$http_user_agent" } }';
    39. sendfile on;
    40. #tcp_nopush on;
    41. #keepalive_timeout 0;
    42. keepalive_timeout 65;
    43. #gzip on;
    44. server {
    45. listen 80;
    46. server_name localhost;
    47. #charset koi8-r;
    48. #access_log logs/host.access.log main;
    49. location / {
    50. root html;
    51. index index.html index.htm;
    52. }
    53. location /status {
    54. vhost_traffic_status_display;
    55. vhost_traffic_status_display_format html;
    56. }
    57. #error_page 404 /404.html;
    58. # redirect server error pages to the static page /50x.html
    59. #
    60. error_page 500 502 503 504 /50x.html;
    61. location = /50x.html {
    62. root html;
    63. }
    64. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    65. #
    66. #location ~ \.php$ {
    67. # proxy_pass http://127.0.0.1;
    68. #}
    69. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    70. #
    71. #location ~ \.php$ {
    72. # root html;
    73. # fastcgi_pass 127.0.0.1:9000;
    74. # fastcgi_index index.php;
    75. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    76. # include fastcgi_params;
    77. #}
    78. # deny access to .htaccess files, if Apache's document root
    79. # concurs with nginx's one
    80. #
    81. #location ~ /\.ht {
    82. # deny all;
    83. #}
    84. }
    85. # another virtual host using mix of IP-, name-, and port-based configuration
    86. #
    87. #server {
    88. # listen 8000;
    89. # listen somename:8080;
    90. # server_name somename alias another.alias;
    91. # location / {
    92. # root html;
    93. # index index.html index.htm;
    94. # }
    95. #}
    96. # HTTPS server
    97. #
    98. #server {
    99. # listen 443 ssl;
    100. # server_name localhost;
    101. # ssl_certificate cert.pem;
    102. # ssl_certificate_key cert.key;
    103. # ssl_session_cache shared:SSL:1m;
    104. # ssl_session_timeout 5m;
    105. # ssl_ciphers HIGH:!aNULL:!MD5;
    106. # ssl_prefer_server_ciphers on;
    107. # location / {
    108. # root html;
    109. # index index.html index.htm;
    110. # }
    111. #}
    112. }

    nginx   #开启服务

    nginx reload   #重新加载配置文件

    六、验证

    0a30effb49c94d758de87729f106260f.png

     a34d4884dc24441e8e27876cb7dd37bf.png

    这样模块就成功添加完毕了

    七、监控模块各字段信

    1. 监控列表各项信息
    2. Server main 主服务器
    3. **Host:**主机名
    4. **Version:**版本号
    5. **Uptime:**服务器运行时间
    6. Connections active:当前客户端的连接数 reading:读取客户端连接的总数 writing:写入客户端连接的总数
    7. Requsts accepted:接收客户端的连接总数 handled:已处理客户端的连接总数 Total:请求总数 Req/s:每秒请求的数量
    8. Shared memory:共享内存 name:配置中指定的共享内存名称 maxSize:配置中指定的共享内存的最大限制 usedSize:共享内存的当前大小 usedNode:共享内存中当前使用的节点数
    9. Server zones 服务器区域
    10. zone:当前区域
    11. Requests Total:请求总数 Req/s:每秒请求数 time:时间
    12. Responses:状态码数量 1xx、2xx、3xx、4xx、5xx:表示响应不同状态码数量 Total:响应状态码的总数
    13. Traffic表示流量 Sent:发送的流量 Rcvd:接收的流量 Sent/s:每秒发送的流量 Rcvd/s:每秒接收的流量
    14. Cache表示缓存 Miss:未命中的缓存数 Bypass:避开的缓存数 Expirde:过期的缓存数 Stale:生效的缓存数 Updating:缓存更新的次数 Revalidated:重新验证的缓存书 Hit:缓存命中数 Scarce:未达缓存要求的请求次数Total:总数

     

     

  • 相关阅读:
    【NR技术】 3GPP支持无人机服务的关键性能指标
    Linux进程概念(下)
    linux下使用selenium调用谷歌浏览器的一些问题
    玩转代码|Google Map api国内正常使用该如何配置
    html2canvas将html代码生成canvas转换成图片,并且保存到本地
    GaoNeng:我是如何为OpenTiny贡献新组件的?
    云原生尝试——docker容器域名绑定
    虚拟现实技术教学应用影响因素研究综述
    专精特新企业认定条件
    YOLOX 学习笔记
  • 原文地址:https://blog.csdn.net/qq_57377057/article/details/126552836