手机版
你好,游客 登录 注册
背景:
阅读新闻

用nginx-rrd监控nginx访问数

[日期:2013-03-21] 来源:51cto  作者:老徐_kevin [字体:大 中 小]

查看已安装的nginx是否包含stub_status模块

  1. /usr/local/nginx/sbin/nginx -V
  2. nginx version: Nginx/1.2.0
  3. configure arguments: --with-http_stub_status_module

确定支持stub_status模块后编辑修改nginx.conf

  1. vim /usr/local/nginx/conf/nginx.conf
  2. //server{} 中,需要已经加入如下内容
  3. location / {
  4. root html;
  5. index index.php index.html index.htm;
  6. location /nginx_status {
  7. stub_status on; //这个选项参数就是在编译时对stub_status模块的支持,如果不编译加入则会在启动nginx时有警告信息
  8. access_log off;
  9. }
  10. }
  11. #error_page 404 /404.html;
  12. # redirect server error pages to the static page /50x.html
  13. #
  14. error_page 500 502 503 504 /50x.html;
  15. location = /50x.html {
  16. root html;
  17. }
  18. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  19. #
  20. #location ~ \.php$ {
  21. # proxy_pass http://127.0.0.1;
  22. #}
  23. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  24. #
  25. // 去掉如下内容的注释,这里是对php的支持,注意文件路径
  26. location ~ \.php$ {
  27. root html;
  28. fastcgi_pass 127.0.0.1:9000;
  29. fastcgi_index index.php;
  30. fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
  31. include fastcgi_params;
  32. }

重启Nginx服务器

  1. /usr/local/nginx/sbin/nginx -s reload

设置定时收集数据

  1. crontab -e
  2. * * * * * root /usr/sbin/nginx-collect
  3. */10 * * * * root /usr/sbin/nginx-graph
 
访问页面http://域名/index.php,nginx的连接数如下图

nginx请求数如下图

linux
相关资讯       Nginx  nginx-rrd  nginx监控 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款