最近根据需求,使用Zabbix对ASM磁盘组的状态和使用率进行监控,因而写了个Shell脚本对ASM磁盘组进行监控。bash
一、Shell脚本以下:ide
#!/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}' {if($2 != "EXTERNAL") {printf ("%.0f\n",($9-$10)*100/$9)} else {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
二、 执行脚步
orm
#sh /root/scripts/monitor_asm.sh 85
ip
意思是当磁盘使用率达到85%时,经过Zabbix的监控进行短信报警或者邮件报警。cmd
注:其实作好存储的监控,保证存储端不出问题,ASM磁盘的监控是非必须的。it