====== nginx 納入 Zabbix 監控 ====== ===== @nginx Server 設定程序 ===== * 設定 nginx 提供狀態頁面 vi /etc/nginx/conf.d/default.conf : 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; : service nginx restart curl http://localhost/nginx_status Active connections: 1 server accepts handled requests 3 3 3 Reading: 0 Writing: 1 Waiting: 0 * 設定 Zabbix Agent Script 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 : 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' : vi /etc/crontab : # zabbix nginx * * * * * root /usr/local/bin/zbx_nginx_stats.py service crond restart ===== @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}}