差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:zabbix:ngnix [2015/06/07 23:33] jonathantech:zabbix:ngnix [2015/10/06 20:35] (目前版本) – [@nginx Server 設定程序] jonathan
行 1: 行 1:
 +====== nginx 納入 Zabbix 監控 ======
 +
 +===== @nginx Server 設定程序 =====
 +  * 設定 nginx 提供狀態頁面<code sh>
 +vi /etc/nginx/conf.d/default.conf</code><file>
 +:
 +    location / {
 +        root   /usr/share/nginx/html;
 +        index  index.html index.htm;
 +    }
 +
 +    location /nginx_status {
 +        stub_status on;
 +        access_log   off;
 +        allow 127.0.0.1;
 +        deny all;
 +    }
 +
 +    #error_page  404              /404.html;
 +:
 +</file><code sh>
 +service nginx restart
 +curl http://localhost/nginx_status</code><file>
 +Active connections: 1
 +server accepts handled requests
 + 3 3 3
 +Reading: 0 Writing: 1 Waiting: 0
 +</file>
 +  * 設定 Zabbix Agent Script<code sh>
 +cd /usr/local/bin/
 +wget https://github.com/blacked/zbx_nginx_template/raw/master/zbx_nginx_stats.py
 +chmod a+x zbx_nginx_stats.py
 +vi zbx_nginx_stats.py</code><file>
 +:
 +zabbix_host = '192.168.11.252'   # Zabbix server IP
 +zabbix_port = 10051         # Zabbix server port
 +hostname = 'kvm-nginx'   # Name of monitored host, like it shows in zabbix web ui
 +time_delta = 1              # grep interval in minutes
 +
 +# URL to nginx stat (http_stub_status_module)
 +stat_url = 'http://localhost/nginx_status'
 +
 +# Nginx log file path
 +nginx_log_file_path = '/var/log/nginx/access.log'
 +
 +# Optional Basic Auth
 +username = 'user'
 +password = 'pass'
 +:
 +</file><code sh>
 +vi /etc/crontab</code><file>
 +:
 +# zabbix nginx
 +* * * * * root /usr/local/bin/zbx_nginx_stats.py
 +</file><code sh>
 +service crond restart
 +</code>
 +
 +===== @Zabbix Server 設定程序 =====
 +  * 至 https://github.com/blacked/zbx_nginx_template 下載 [[https://github.com/blacked/zbx_nginx_template/raw/master/zbx_nginx_templates.xml|zbx_nginx_templates.xml]]
 +  * 將 zbx_nginx_templates.xml 匯入至 Zabbix Server → Configuration → Templates → Import
 +
 +===== 參考網址 =====
 +  * https://github.com/blacked/zbx_nginx_template
 +
 +{{tag>nginx zabbix}}