最近根据需求,使用Zabbix对ASM磁盘组的状态和使用率进行监控,于是写了个Shell脚步对ASM磁盘组进行监控。
1、Shell脚步如下:
#!/bin/bash ############################################################### # Check usage rate -- Check the ASM disk usage # # History: 2016/04/07 zhuwei First release ############################################################### # set a safe path before doing anything else PATH=/sbin:/usr/sbin:/bin:/usr/bin; export PATH # Display the normal print displayheader() { echo -e "\033[0m"$@"" } su - grid -c "asmcmd -p lsdg" | sed ‘1d‘ > /root/scripts/asm.txt num=`wc -l /root/scripts/asm.txt | awk ‘{print $1}‘` for((i=1;i<=num;i++)); do fail1=`awk ‘NR == ‘${i}‘ {if($1 != "MOUNTED" ) {print $13}}‘ /root/scripts/asm.txt` fail2=`awk ‘NR == ‘${i}‘ {if($11 != ‘0‘ ) {print $13}}‘ /root/scripts/asm.txt` usage=`awk ‘NR == ‘${i}‘ {printf ("%.0f\n",($7-$8)*100/$7)}‘ /root/scripts/asm.txt` if [ ${fail1} ];then displayheader "Diskgroup ${fail1} is not mount!" fi if [ ${fail2} ];then displayheader "Diskgroup ${fail2} have disk offline!" fi if [ "${usage}" -ge "${1}" ];then diskgroup=`awk ‘NR == ‘$i‘ {print $13}‘ /root/scripts/asm.txt` displayheader "Diskgroup ${diskgroup} usage is ${usage}" fi done
2、 执行脚步
#sh /root/scripts/monitor_asm.sh 85
意思是当磁盘使用率达到85%时,通过Zabbix的监控进行短信报警或者邮件报警。
注:其实做好存储的监控,保证存储端不出问题,ASM磁盘的监控是非必须的。
本文出自 “8932072” 博客,请务必保留此出处http://8942072.blog.51cto.com/8932072/1764251
原文地址:http://8942072.blog.51cto.com/8932072/1764251