标签:ios 正则 === 匹配 脚本 文件 ice ase data
##需要在zabbix界面配置宏变量===》正则来匹配磁盘
disk_discovery.sh
————————————————————————————————————————————————
#!/bin/bash
# this script is Automatic discovery
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"
————————————————————————————————————————————————
nohup /usr/bin/iostat -dxkt 1 >> /tmp/iostat_output 2>/dev/null & #nohup 让命令挂在进程里不中断 持续执行。也是取数据的文件
disk_status.sh
磁盘发现脚本 ##需要在zabbix 自动发现 来配置 {#DEVICE}
#!/bin/bash
#this scrips is Get disk io info script
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
标签:ios 正则 === 匹配 脚本 文件 ice ase data
原文地址:https://www.cnblogs.com/sxgaofeng/p/9189318.html