Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30958
  • 博文数量: 19
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2015-03-24 21:19
文章分类

全部博文(19)

分类: LINUX

2015-12-23 11:10:15

原文地址:zabbix 监控 nginx 作者:baochenggood

   zabbix 监控 nginx 


①先运行我们之前写的脚本,配置好 zabbix-agentd 


②配置 client

使用git 下载下来 

Git  地址 

# git  clone  

我们需要改这个文件zbx_nginx_stats.py


点击(此处)折叠或打开

  1. zabbix_host = '172.16.1.218'   # Zabbix server IP
  2. zabbix_port = 10051            # Zabbix server port
  3. hostname = 'nginx-node4.example.com' # Name of monitored host, like it shows in zabbix web ui
  4. time_delta = 1 # grep interval in minutes

  5. # URL to nginx stat (http_stub_status_module)
  6. stat_url = 'http://172.16.1.222/nginx_stat'

  7. # Nginx log file path
  8. nginx_log_file_path = '/usr/local/nginx/logs/access.log'

  9. # Optional Basic Auth
  10. username = 'user'
  11. password = 'pass'

  12. # Temp file, with log file cursor position
  13. seek_file = '/tmp/nginx_log_stat'

修改完毕放入 /etc/zabbix/ 里面

这些需要我们修改

③赋予,脚本可执行权限,我们zabbix客户端需要调用这个脚本

chmod +x /etc/zabbix/zbx_nginx_stats.py

④写计划任务,来运行这个脚本收集数据

# sudo crontab -e

*/1 * * * * /etc/zabbix/zbx_nginx_stats.py


⑤.在zabbix web界面 导入 zbx_nginx_template.xml 模块

这个不细讲了,web界面,点击configure ---模板 ----导入模板,导入即可

⑥ 配置nginx 开启 nginx_satus功能

location /nginx_stat {

  stub_status on;       # Turn on nginx stats

  access_log   off;     # We do not need logs for stats

  allow 127.0.0.1;      # Security: Only allow access from IP

  deny all;             # Deny requests from the other of the world

}

配置过后,主机上添加上这个模板进行测试

参考官方文档:


阅读(1236) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~