首页 > 代码库 > zabbix监控磁盘IO(二)
zabbix监控磁盘IO(二)
1.磁盘发现脚本
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.查看监控
本文出自 “深呼吸再出击” 博客,请务必保留此出处http://ckl893.blog.51cto.com/8827818/1891127
zabbix监控磁盘IO(二)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。