监控IO瓶颈
来源:互联网 发布:音乐播放器源码 编辑:程序博客网 时间:2024/05/22 03:47
chech_io_bio脚本内容如下:
#!/bin/sh
#
# Version 0.0.1 - Jan/2017
# Changes: added device verification
#
# by curious
vmstat=`which vmstat 2>/dev/null`
bc=`which bc 2>/dev/null`
function help {
echo -e "\n\t此功能为检测主机I/O是否达到瓶颈,检测参数为bi和bo。\n\t一般情况bi+bo<1000。如果bi+bo>1000且wa>20(wa越高,表示I/O等待越严重),则考虑提高磁盘的读写性能\n\t-w <bi+bo警告阈值>,<wa警告阈值> \n\t-c <bi+bo critical阈值>,<wa critical阈值>\n\t \n"
exit -1
}
# Ensuring we have the needed tools:
( [ ! -f $vmstat ] || [ ! -f $bc ] ) && \
( echo "ERROR: You must have vmstat and bc installed in order to run this plugin" && exit -1 )
# Getting parameters:
while getopts "w:c:h" OPT; do
case $OPT in
"w") warning=$OPTARG;;
"c") critical=$OPTARG;;
"h") help;;
esac
done
# Adjusting the three warn and crit levels:
crit_bio=`echo $critical | cut -d, -f1`
crit_wa=`echo $critical | cut -d, -f2`
warn_bio=`echo $warning | cut -d, -f1`
warn_wa=`echo $warning | cut -d, -f2`
# Checking parameters:
( [[ "$warn_bio" -ge "$crit_bio" ]] || \
[[ "$warn_wa" -ge "$crit_wa" ]] ) && \
echo "ERROR: critical levels must be highter than warning levels" && help
# Doing the actual check:
si=`$vmstat 1 2| tail -1 | awk '{print $9}'`
so=`$vmstat 1 2| tail -1 | awk '{print $10}'`
wa=`$vmstat 1 2| tail -1 | awk '{print $16}'`
bio=`echo "$si+$so"|bc`
# Checking parameters:
( [[ "$warn_bio" -ge "$crit_bio" ]] || \
[[ "$warn_wa" -ge "$crit_wa" ]] ) && \
echo "ERROR: critical levels must be highter than warning levels" && help
# Comparing the result and setting the correct level:
if ( [ "`echo "$bio >= $crit_bio" | bc`" == "1" ] && [ "`echo "$wa >= $crit_wa" | bc`" == "1" ] ); then
msg="CRITICAL"
status=2
else if ( [ "`echo "$bio >= $warn_bio" | bc`" == "1" ] && [ "`echo "$wa >= $warn_wa" | bc`" == "1" ] ); then
msg="WARNING"
status=1
else
msg="OK"
status=0
fi
fi
# Printing the results:
echo "$msg - IO bi/so/wa stats bio=$bio wa=$wa | 'bio'=$bio;$warn_bio;$crit_bio 'wa'=$wa;$warn_wa;$crit_wa"
# Bye!
exit $status
#!/bin/sh
#
# Version 0.0.1 - Jan/2017
# Changes: added device verification
#
# by curious
vmstat=`which vmstat 2>/dev/null`
bc=`which bc 2>/dev/null`
function help {
echo -e "\n\t此功能为检测主机I/O是否达到瓶颈,检测参数为bi和bo。\n\t一般情况bi+bo<1000。如果bi+bo>1000且wa>20(wa越高,表示I/O等待越严重),则考虑提高磁盘的读写性能\n\t-w <bi+bo警告阈值>,<wa警告阈值> \n\t-c <bi+bo critical阈值>,<wa critical阈值>\n\t \n"
exit -1
}
# Ensuring we have the needed tools:
( [ ! -f $vmstat ] || [ ! -f $bc ] ) && \
( echo "ERROR: You must have vmstat and bc installed in order to run this plugin" && exit -1 )
# Getting parameters:
while getopts "w:c:h" OPT; do
case $OPT in
"w") warning=$OPTARG;;
"c") critical=$OPTARG;;
"h") help;;
esac
done
# Adjusting the three warn and crit levels:
crit_bio=`echo $critical | cut -d, -f1`
crit_wa=`echo $critical | cut -d, -f2`
warn_bio=`echo $warning | cut -d, -f1`
warn_wa=`echo $warning | cut -d, -f2`
# Checking parameters:
( [[ "$warn_bio" -ge "$crit_bio" ]] || \
[[ "$warn_wa" -ge "$crit_wa" ]] ) && \
echo "ERROR: critical levels must be highter than warning levels" && help
# Doing the actual check:
si=`$vmstat 1 2| tail -1 | awk '{print $9}'`
so=`$vmstat 1 2| tail -1 | awk '{print $10}'`
wa=`$vmstat 1 2| tail -1 | awk '{print $16}'`
bio=`echo "$si+$so"|bc`
# Checking parameters:
( [[ "$warn_bio" -ge "$crit_bio" ]] || \
[[ "$warn_wa" -ge "$crit_wa" ]] ) && \
echo "ERROR: critical levels must be highter than warning levels" && help
# Comparing the result and setting the correct level:
if ( [ "`echo "$bio >= $crit_bio" | bc`" == "1" ] && [ "`echo "$wa >= $crit_wa" | bc`" == "1" ] ); then
msg="CRITICAL"
status=2
else if ( [ "`echo "$bio >= $warn_bio" | bc`" == "1" ] && [ "`echo "$wa >= $warn_wa" | bc`" == "1" ] ); then
msg="WARNING"
status=1
else
msg="OK"
status=0
fi
fi
# Printing the results:
echo "$msg - IO bi/so/wa stats bio=$bio wa=$wa | 'bio'=$bio;$warn_bio;$crit_bio 'wa'=$wa;$warn_wa;$crit_wa"
# Bye!
exit $status
阅读全文
0 0
- 监控IO瓶颈
- 监控内存瓶颈
- io监控
- 集群瓶颈:磁盘IO必读
- liunx 定位IO瓶颈方法
- 突破无线监控网络链路高带宽瓶颈
- IO是程序效率的瓶颈
- 如何识别SQL Server中的IO瓶颈
- linux下 vmstat截取io瓶颈命令
- 记一次性你调优 IO瓶颈
- linux服务器下磁盘IO瓶颈测试
- 关于磁盘性能(IO)瓶颈
- 如何识别SQL Server中的IO瓶颈
- linux监控多线程io
- linux监控多线程io
- window 计时器IO监控
- Linux IO资源监控
- linux IO 性能监控
- 《软件测试的艺术》读书心得 --- 软件测试的心理学和经济学
- 监控内存瓶颈
- 使用construct2制作简单游戏
- 有重复元素的排列问题
- FTPrep, 107 Binary Tree Level Order Traversal II
- 监控IO瓶颈
- java基础知识总结2
- JVM内存结构与垃圾回收总结
- 9. 外观模式
- win10下电脑磁盘打开闪退问题解决方法
- linux服务器安全
- 数据分析介绍之八——双变量建立关系之散点图
- cameraFi live & nginx & linux deploy 开发全景推流
- Spring Cloud项目实践【2 项目环境搭建】