script getasmdh.sh
#!/bin/sh
mkdir /tmp/hc 2> /dev/null
rm -f /tmp/hc/asmdisks.lst 2> /dev/null
rm -f /tmp/hc/asm_diskh.sh 2> /dev/null
echo " "
echo "############################################"
echo " 1) collecting information about the disks:"
echo "############################################"
sqlplus '/nolog' set linesize 90
col path format a60
set heading off
set head off
set feedback off
spool /tmp/hc/asmdisks.lst
select group_number,disk_number,path from v\$asm_disk_stat where group_number > 0 order by group_number,disk_number;
spool off;
eof
echo " "
echo " "
ls -l /tmp/hc/asmdisks.lst
echo " "
echo "############################################"
echo " 2) generating "asm_diskh.sh" script."
echo "############################################"
echo " "
grep -v sql /tmp/hc/asmdisks.lst > /tmp/hc/asmdisks_tmp.lst
mv /tmp/hc/asmdisks_tmp.lst /tmp/hc/asmdisks.lst
sed 's/orcl:/\/dev\/oracleasm\/disks\//g' /tmp/hc/asmdisks_new.lst
mv /tmp/hc/asmdisks_new.lst /tmp/hc/asmdisks.lst
cat /tmp/hc/asmdisks.lst|while read line
do
comm=`echo $line|awk '{print "dd if="$3 " of=/tmp/hc/dsk_"$1"_"$2".dd bs=1048576 count=1"}'`
echo $comm >> /tmp/hc/asm_diskh.sh
done
chmod 700 /tmp/hc/asm_diskh.sh
ls -l /tmp/hc/asm_diskh.sh
echo " "
echo "############################################"
echo " 3) executing asm_diskh.sh script to "
echo " generate dd dumps."
echo "############################################"
echo " "
### for display only
/tmp/hc/asm_diskh.sh 2> /dev/null
ls -l /tmp/hc/*dd
echo " "
echo "############################################"
echo " 4) compressing dd dumps in the next format:"
echo " (asm_dd_header_all_.tar)"
echo "############################################"
echo " "
now=$(date "%m-%d-%y_%t")
tar -cvf /tmp/hc/asm_dd_header_all_$now.tar /tmp/hc/*.dd 2> /dev/null
compress /tmp/hc/asm_dd_header_all_$now.tar
ls -l /tmp/hc/*.z
阅读(2955) | 评论(0) | 转发(0) |