-
-
Save amitzilblog/5648e321bb697be720ff22136f50291b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ora_user=oracle | |
asm_sid=+ASM | |
padding=20 | |
function get_dg() { | |
asm_disk=$1 | |
su - ${ora_user} -c " | |
export ORACLE_SID=${asm_sid} | |
ORAENV_ASK=NO | |
. /usr/local/bin/oraenv -s | |
sqlplus -s / as sysasm <<- EOF | |
set pages 0 lines 100 feedback off | |
select name from v\\\$asm_diskgroup | |
where group_number=(select group_number from v\\\$asm_disk where path='ORCL:${asm_disk}'); | |
exit | |
EOF | |
" | |
} | |
## main | |
if [ "$(whoami)" != "root" ]; then | |
echo "Please run this script as root" | |
exit | |
fi | |
echo | |
echo "List of ASM disks in the system" | |
echo "===============================" | |
echo | |
printf "%-${padding}s %-${padding}s %s\n" "ASM DISK" "Physical Device" "ASM Diskgroup" | |
printf "%-${padding}s %-${padding}s %s\n" "--------" "---------------" "-------------" | |
for asm_disk in $(oracleasm listdisks); do | |
p_disk=$(oracleasm querydisk -p ${asm_disk} | egrep '^/dev/' | cut -d ':' -f 1) | |
asm_dg=$(get_dg ${asm_disk}) | |
printf "%-${padding}s %-${padding}s %s\n" ${asm_disk} ${p_disk} ${asm_dg} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment