標籤:
前段時間在公司IDC伺服器上部署了zabbix3.0.3監控系統,除了內建的記憶體/頻寬/CPU負載等系統資源監控模板以及mysql監控模板外,接下來對諸如nginx、php、memcache、磁碟IO的監控項配置在此做下記錄,希望能協助到有用到的朋友們~
nginx的監控模板:zbx_nginx_templates.xml
php的監控模板:zbx_php-fpm_templates.xml
memcache的監控模板:zbx_memcached_templates.xml
Low-level discovery監控磁碟IO的監控模板:Template Linux DiskIO.xml
以上四個監控項的模板的:http://pan.baidu.com/s/1geAMZfl (提取密碼:zpyx)
--------------------------------------------------------------------------------------------------
一、配置nginx的監控
1)首先在客戶機的nginx設定檔裡添加:
[[email protected] ~]# vim www.world.huanqiu.conf
.......
location /nginx_status {
stub_status on;
access_log off;
}
........
添加後,重啟nginx服務:
[[email protected] ~]#/usr/local/nginx/sbin/nginx -s reload
2)zabbix監控nginx的自訂索引值
在客戶機的zabbix的monitor_scripts目錄下添加nginx-status.sh檔案,進行如下配置(這個配置可以適用於其他機器的nginx監控)
[[email protected] ~]# cd /usr/local/zabbix/monitor_scripts/
[[email protected] monitor_scripts]#cat nginx-status.sh
#!/bin/bash
##################################
# Zabbix monitoring script
#
# nginx:
# - anything available via nginx stub-status module
#
##################################
# Contact:
# [email protected]
##################################
# ChangeLog:
# 20100922 VV initial creation
##################################
# Zabbix requested parameter
ZBX_REQ_DATA="$1"
ZBX_REQ_DATA_URL="$2"
# Nginx defaults
URL="http://127.0.0.1/nginx_status"
WGET_BIN="/usr/bin/wget"
#
# Error handling:
# - need to be displayable in Zabbix (avoid NOT_SUPPORTED)
# - items need to be of type "float" (allow negative + float)
#
ERROR_NO_ACCESS_FILE="-0.9900"
ERROR_NO_ACCESS="-0.9901"
ERROR_WRONG_PARAM="-0.9902"
ERROR_DATA="-0.9903" # either can not connect / bad host / bad port
# save the nginx stats in a variable for future parsing
NGINX_STATS=$($WGET_BIN -q $URL -O - 2> /dev/null)
# error during retrieve
if [ $? -ne 0 -o -z "$NGINX_STATS" ]; then
echo $ERROR_DATA
exit 1
fi
#
# Extract data from nginx stats
#
case $ZBX_REQ_DATA in
active_connections) echo "$NGINX_STATS" | head -1 | cut -f3 -d‘ ‘;;
accepted_connections) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f2 -d‘ ‘;;
handled_connections) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f3 -d‘ ‘;;
handled_requests) echo "$NGINX_STATS" | grep -Ev ‘[a-zA-Z]‘ | cut -f4 -d‘ ‘;;
reading) echo "$NGINX_STATS" | tail -1 | cut -f2 -d‘ ‘;;
writing) echo "$NGINX_STATS" | tail -1 | cut -f4 -d‘ ‘;;
waiting) echo "$NGINX_STATS" | tail -1 | cut -f6 -d‘ ‘;;
*) echo $ERROR_WRONG_PARAM; exit 1;;
esac
exit 0
分布式監控系統Zabbix-3.0.3-完整安裝記錄(4)-監控nginx,php,memcache,Low-level discovery磁碟IO