1.磁盤發(fā)現(xiàn)腳本
創(chuàng)新互聯(lián)建站主營山亭網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app開發(fā)定制,山亭h5成都小程序開發(fā)搭建,山亭網(wǎng)站營銷推廣歡迎山亭等地區(qū)企業(yè)咨詢
vim disk_io.sh #!/bin/bash diskarray=(`cat /proc/diskstats |grep -E "\bsd[a-z]\b|\bxvd[a-z]\b|\bvd[a-z]\b"|awk '{print $3}'|sort|uniq 2>/dev/null`) length=${#diskarray[@]} printf "{\n" printf '\t'"\"data\":[" for ((i=0;i<$length;i++)) do printf '\n\t\t{' printf "\"{#DISK_NAME}\":\"${diskarray[$i]}\"}" if [ $i -lt $[$length-1] ];then printf ',' fi done printf "\n\t]\n" printf "}\n"
2.磁盤io狀態(tài)腳本
vim disk_stats.sh #/bin/sh device=$1 item=$2 case $item in rrqm) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b"|tail -1|awk '{print $2}' ;; wrqm) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b"|tail -1|awk '{print $3}' ;; rps) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b"|tail -1|awk '{print $4}' ;; wps) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $5}' ;; rKBps) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $6}' ;; wKBps) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $7}' ;; avgrq-sz) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $8}' ;; avgqu-sz) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $9}' ;; await) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $10}' ;; svctm) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $11}' ;; util) /usr/bin/tail -n20 /tmp/iostat_output |grep "\b$device\b" |tail -1|awk '{print $12}' ;; esac
3.增加用戶自定義的參數(shù)表
vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf #add the two lines UserParameter=disk.discovery[*],/bin/bash /usr/local/zabbix-agent/scripts/disk_io.sh UserParameter=disk.status[*],/bin/bash /usr/local/zabbix-agent/scripts/disk_stats.sh $1 $2
4.重啟進(jìn)程
/etc/init.d/zabbix_agentd restart
3.創(chuàng)建模板
4.創(chuàng)建discover rule
5.創(chuàng)建item prototype
6.創(chuàng)建Graph prototype
7.查看監(jiān)控