#!/bin/bash
/home/oracle/atgsysdb_env
PWD=`pwd`
VALUE=60
function get_asm_usage {
sqlplus -S /nolog<<EOF
conn / as sysdba
set heading off
spool /\$PWD/asm.out
select trunc((TOTAL_MB-FREE_MB)/TOTAL_MB*100) usage from v\$asm_diskgroup where name='DATADISK';
spool off
exit;
EOF
}
function delete_archive {
export ORACLE_SID=atgsysdb1
RMAN_CMD=/oracle/app/oracle/product/11.2.0/db_1/bin/rman
$RMAN_CMD target / log=/home/oracle/log/sunhailong/rman_`date +%y%m%d`.log append<<EOF
delete archivelog all completed before 'SYSDATE-6/24';
yes
exit
EOF
}
#######get_asm_usage##############
get_asm_usage
USAGE=`grep -v ^$ asm.out`
#echo $USAGE
echo `date`>>/home/oracle/log/sunhailong/delete_`date +%y%m%d`.log
echo "USAGE IS $USAGE"
###############main##############
if [ $USAGE -ge $VALUE ]
then
delete_archive
# echo "needed deleted"
else
echo "ASM USAGE IS $USAGE,LESS THAN 70"
fi
/home/oracle/atgsysdb_env
PWD=`pwd`
VALUE=60
function get_asm_usage {
sqlplus -S /nolog<<EOF
conn / as sysdba
set heading off
spool /\$PWD/asm.out
select trunc((TOTAL_MB-FREE_MB)/TOTAL_MB*100) usage from v\$asm_diskgroup where name='DATADISK';
spool off
exit;
EOF
}
function delete_archive {
export ORACLE_SID=atgsysdb1
RMAN_CMD=/oracle/app/oracle/product/11.2.0/db_1/bin/rman
$RMAN_CMD target / log=/home/oracle/log/sunhailong/rman_`date +%y%m%d`.log append<<EOF
delete archivelog all completed before 'SYSDATE-6/24';
yes
exit
EOF
}
#######get_asm_usage##############
get_asm_usage
USAGE=`grep -v ^$ asm.out`
#echo $USAGE
echo `date`>>/home/oracle/log/sunhailong/delete_`date +%y%m%d`.log
echo "USAGE IS $USAGE"
###############main##############
if [ $USAGE -ge $VALUE ]
then
delete_archive
# echo "needed deleted"
else
echo "ASM USAGE IS $USAGE,LESS THAN 70"
fi