• nginx server 实时监控


    本文建立在Centos基础上,也可应用在其他版本的linux上。适合使用nginx为反向代理的java开发人员。写本文的原因是nginx在apache下面也有 一些监控的工具,不过大部分都是基于php的。java开发者可能不愿意再去配置php环境的apache,本文提供了一种简易专业的nginx监控方 法,比较适合小型应用(server number<10),半小时就能搞定服务器实时状态监控,喝口水,听本lz慢慢讲。

    本文可能用到的软件
    rrd
    collectd
    perl
    nginx

    第一步,
    apt-get install collectd
    (for collectd you may also need:
    sudo apt-get install librrds-perl libconfig-general-perl libhtml-parser-perl  libregexp-
    librrd2-dev libsensors-dev libsnmp-dev….)

    第二步,
    为您的nignx添加stub status模块(http://wiki.nginx.org/NginxHttpStubStatusModule),nginx最好的监控手段应该 是分析log,高压下log比这个模块要精准点,误差在千分之一不到。不过那是另外一篇文章了,等有空再写一篇

    第三步,
    mkdir /server_status, /server_status将被用来保存网页文件

    第四步,将genCollectdInfo.pl , collectd2html.pl拷贝到/server_status中

    第五步,
    将以下几行添加到你的nginx配置
    location /stub_status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
    }
    location /server_status {
    access_log off;
    allow 127.0.0.1;
    deny all;
    root /;
    }
    第六步,
    保存附件中的nginx-rrd_new.pl到本地
    1.mkidr /var/nstatus/rrd
    2.mkdir /server_status/img
    3.vim /etc/crontab, 在最后添加一行,

    *  *    * * *   root    /pathtoyourfile/nginx-rrd_new.pl
    4.save crontab
    5.restart crond

    第七步,
    step 7.
    1.cd /server_status;
    2./genCollectdInfo.pl /var/lib/collectd/rrd/yourServerName
    注:yourhostname 是你的当前hostname, collectd可以被用于linux集群,你可以对脚本或者参数稍作修改来查看后台其他机器的状态

    第八步,
    打开http://localhost/server_status/index.html,你应该已经可以看到所有的系统状态列表包括nginx,cpu,io,interface

  • 相关阅读:
    springmvc到底怎么工作的
    (netty专题)初步认识BIO、NIO、AIO
    dubbo基本使用理解
    warning: ignoring option PermSize=512m; support was removed in 8.0解决
    面试都看那些
    MySQL——通过EXPLAIN分析SQL的执行计划
    springboot中的json、gson、fastjson如何使用与日期格式转换
    如何生成一个不重复的四位数
    深入理解SpringCloud之Gateway 接上篇Webflux快速入门
    Layui 手册2
  • 原文地址:https://www.cnblogs.com/amityat/p/2150171.html
Copyright © 2020-2023  润新知