This script will be the best to monitor ASM space and send alert. i will send alert if its reaches 90% utilization and also send alert if space is less than 100GB if utilization is above 80%.
#!/bin/bash
export ORACLE_SID=`egrep -i ":Y|:N" /etc/oratab | cut -d":" -f1 | grep -v "\#" | grep -v "\*"|grep ASM`
if [ -z "$ORACLE_SID" ]
then
exit;
else
export ORACLE_HOME=`egrep -i ":Y|:N" /etc/oratab |grep $ORACLE_SID| cut -d":" -f2 | grep -v "\#" | grep -v "\*"`
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
DG_SPACE=`sqlplus -s "/ as sysdba" <<EOF
set heading off feedback off verify off
SELECT name group_name,total_mb/1024,ROUND((free_mb)/1024) Avail_GB,ROUND((1- (free_mb / total_mb))*100) pct_used FROM v\\$asm_diskgroup ORDER BY name;
exit
EOF`
fi
PCT="`echo $DG_SPACE|awk '{ print $4}'`"
AVL_GB="`echo $DG_SPACE|awk '{ print $3}'`"
if [ $PCT -ge 80 ] && [ $PCT -lt 90 ]
then
if [ $AVL_GB -lt 100 ]
then
echo "$NUM_OF_REC" | mail -r "sender_mail_id@comp.com" -s "ASM disk space alert- critical" "email_id@comp.com"
fi
else if [ $PCT -ge 90 ]
then
echo "$NUM_OF_REC" | mail -r "sender_mail_id@comp.com" -s "ASM disk space alert- critical" "email_id@comp.com"
fi
fi
#!/bin/bash
export ORACLE_SID=`egrep -i ":Y|:N" /etc/oratab | cut -d":" -f1 | grep -v "\#" | grep -v "\*"|grep ASM`
if [ -z "$ORACLE_SID" ]
then
exit;
else
export ORACLE_HOME=`egrep -i ":Y|:N" /etc/oratab |grep $ORACLE_SID| cut -d":" -f2 | grep -v "\#" | grep -v "\*"`
export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH
DG_SPACE=`sqlplus -s "/ as sysdba" <<EOF
set heading off feedback off verify off
SELECT name group_name,total_mb/1024,ROUND((free_mb)/1024) Avail_GB,ROUND((1- (free_mb / total_mb))*100) pct_used FROM v\\$asm_diskgroup ORDER BY name;
exit
EOF`
fi
PCT="`echo $DG_SPACE|awk '{ print $4}'`"
AVL_GB="`echo $DG_SPACE|awk '{ print $3}'`"
if [ $PCT -ge 80 ] && [ $PCT -lt 90 ]
then
if [ $AVL_GB -lt 100 ]
then
echo "$NUM_OF_REC" | mail -r "sender_mail_id@comp.com" -s "ASM disk space alert- critical" "email_id@comp.com"
fi
else if [ $PCT -ge 90 ]
then
echo "$NUM_OF_REC" | mail -r "sender_mail_id@comp.com" -s "ASM disk space alert- critical" "email_id@comp.com"
fi
fi
No comments:
Post a Comment