最近根據需求,使用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