分布式監控系統Zabbix-3.0.3-完整安裝記錄(4)-監控nginx,php,memcache,Low-level discovery磁碟IO

來源:互聯網
上載者:User

標籤:

 

 

前段時間在公司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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.