顯示頁面舊版反向連結Fold/unfold all回到頁頂 本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。 ====== 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}} tech/zabbix/ngnix.txt 上一次變更: 2015/10/06 20:35由 jonathan