zabbix でNginx の監視
1. まずはNginxに監視ページを設定しておく
http://wiki.nginx.org/HttpStubStatusModule
location /nginx_status { stub_status on; access_log off; allow SOME.IP.ADD.RESS; deny all; }
SOME.IP.ADD.RESS にはデータを収集するzabbix agentのIPアドレスを設定
2. zabbix agentにUserParamを登録
/etc/zabbix/zabbix_agentd.conf
# Nginx statuses UserParameter=nginx.active_connections,wget -q -O - http://localhost/status | grep "Active connections:" | cut -d " " -f 3 UserParameter=nginx.reading, wget -q -O - http://localhost/status | grep "Reading:" | cut -d " " -f 2 UserParameter=nginx.writing, wget -q -O - http://localhost/status | grep "Reading:" | cut -d " " -f 4 UserParameter=nginx.waiting, wget -q -O - http://localhost/status | grep "Reading:" | cut -d " " -f 6 UserParameter=nginx.accepted_connections, wget -q -O - http://localhost/status | grep "^ " | cut -d " " -f 2 UserParameter=nginx.handled_connections, wget -q -O - http://localhost/status | grep "^ " | cut -d " " -f 4 UserParameter=nginx.handled_requests, wget -q -O - http://localhost/status | grep "^ " | cut -d " " -f 6
これで各パラメーターがzabbixで取得できる。いや、簡単。
それにしても、zabbixのWeb UIでそのパラメータを設定していくのは。。。