zabbix监控磁盘IO(二)
1.磁盘发现脚本
创新互联建站主营山亭网站建设的网络公司,主营网站建设方案,app开发定制,山亭h5成都小程序开发搭建,山亭网站营销推广欢迎山亭等地区企业咨询
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状态脚本
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.增加用户自定义的参数表
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.重启进程
/etc/init.d/zabbix_agentd restart
3.创建模板
4.创建discover rule
5.创建item prototype
6.创建Graph prototype
7.查看监控
新闻标题:zabbix监控磁盘IO(二)
分享地址:http://myzitong.com/article/gepshd.html