建立zabbix_agentd的子配置檔案
在/etc/zabbix/zabbix_agentd.d/中建立關聯nginx status和php-fpm status的子配置檔案,建立一個,或者在已有的某配置檔案中增加也可以,我這裡分别為它們建立配置檔案,檔案名可自定義,隻要確定此檔案夾全部内容在zabbix_agentd.conf中包含(include)了。
zabbix-agent配置檔案的自定義key:
userparameter_nginx.conf
[root@spark ~]# cat /etc/zabbix/zabbix_agentd.d/userparameter_nginx.conf
#/usr/local/zabbix/bin/nginx_status.sh
#UserParameter=nginx.status[*],/etc/zabbix/scripts/nginx_status.sh $1
#這種寫法比較簡潔,參考zabbix 3.2.4中自帶的的userparameter_examples.conf
UserParameter=nginx.version,/usr/sbin/nginx -v
#UserParameter=nginx.accepts,/etc/zabbix/scripts/check_nginx_status.sh accepts
#UserParameter=nginx.handled,/etc/zabbix/scripts/check_nginx_status.sh handled
#UserParameter=nginx.requests,/etc/zabbix/scripts/check_nginx_status.sh requests
#UserParameter=nginx.connections.active,/etc/zabbix/scripts/check_nginx_status.sh active
#UserParameter=nginx.connections.reading,/etc/zabbix/scripts/check_nginx_status.sh reading
#UserParameter=nginx.connections.writing,/etc/zabbix/scripts/check_nginx_status.sh writing
#UserParameter=nginx.connections.waiting,/etc/zabbix/scripts/check_nginx_status.sh waiting
userparameter_php-fpm.conf
[root@spark ~]# cat /etc/zabbix/zabbix_agentd.d/userparameter_php-fpm_status.conf
#UserParameter=idle.processe,/etc/zabbix/scripts/php-fpm_status.sh idle
#UserParameter=total.processes,/etc/zabbix/scripts/php-fpm_status.sh total
#UserParameter=active.processes,/etc/zabbix/scripts/php-fpm_status.sh active
#UserParameter=max.active.processes,/etc/zabbix/scripts/php-fpm_status.sh mactive
#UserParameter=listen.queue.len,/etc/zabbix/scripts/php-fpm_status.sh listenqueuelen
#UserParameter=listen.queue,/etc/zabbix/scripts/php-fpm_status.sh listenqueue
#UserParameter=start.since,/etc/zabbix/scripts/php-fpm_status.sh since
#UserParameter=accepted.conn,/etc/zabbix/scripts/php-fpm_status.sh conn
UserParameter=max.children.reached,/etc/zabbix/scripts/php-fpm_status.sh reached
UserParameter=slow.requests[],/etc/zabbix/scripts/php-fpm_status.sh requests
#/usr/local/zabbix/bin/php_fpm_status.sh
UserParameter=php-fpm.status[],/etc/zabbix/scripts/php-fpm_status.sh $1
UserParameter=php-fpm.version,/usr/local/php56/sbin/php-fpm -v | awk 'NR==1{print $0}'
#擷取php-fpm版本資訊
确認子配置檔案被zabbix_agentd配置檔案包含
确認在/usr/local/zabbix/etc/zabbix_agentd.conf中包含:Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/且沒有被注釋。
zabbix服務端的get數值
[root@mha ~]# zabbix_get -s 192.168.198.131 -k 'nginx.status[ping]'
1

zabbix頁面:
nginx:
添加nginx status監控模闆
建立nginx status模闆
定義nginx status模闆
建立nginxApplication
定義nginx status items,這裡我使用的是被動臨控
增加nginx status狀态碼映射
nginx trigger定義
定義nginx監控視圖
添加php-fpm status監控模闆
php-fpm status的模闆添加步驟和上述方法一樣,此處不在贅述。
1、 選擇相應的主機或主機組關聯上相應的模闆
實際監控效果展示(不知道為什麼我的latest data沒資料出來)
檢視監控效果可以通過檢視Monitoring---->Latest data,過濾出相應的主機及應用名進行檢視,最新收集的各item的監控結果,凡是監控到資料的item會顯示資料,出現灰色的表示沒有監控到資料,需要排查原因。如下所示:
nginx的監控資料
也可以通過定義的Graphs檢視監控效果:
nginx status監控視圖
nginx request監控視圖
php的監控資料
memcached監控資料
zabbix-agent配置添加memcached
在用戶端到/usr/local/zabbix/conf/zabbix_agentd.conf裡添加:
UserParameter=memcached_stats[*],(echo stats; sleep 1) | telnet 127.0.0.1 $1 2>&1 | awk '/STAT $2 / {print $NF}'
儲存完畢後重新開機memcached和nginx
memcached監控模闆
<a href="https://pan.baidu.com/s/1mik9jMK">https://pan.baidu.com/s/1mik9jMK</a>
本文轉自wsw26 51CTO部落格,原文連結:http://blog.51cto.com/wsw26/2064990,如需轉載請自行聯系原作者