A while ago, I posted a better “du” for asmcmd . Since then, Oracle 12cR2 beta has been released but it seems that our poor old “du” will not be improved.
I then wrote a better “better du for asmcmd” with some cool new features compared to the previous one which was quite primitive.
In this second version you will find :
- No need to set up your environment, asmdu will do it for you
- If no parameter is passed to the script, asmdu will show you a summary of all the diskgroups :
- If a parameter (a diskgroup) is passed to the script, asmdu will show you a summary of the diskgroup size with its filling rate and the list of the directories it contains with their sizes :
Note : you can quickly see in this screenshot that “DB9” consumes the most space in the FRA diskgroup; it is perhaps worth to have a closer look
- You can also pass a directory as a parameter and asmdu will then show you the size of each of its subdirectories — it is useful to quickly see which day has been archivelog intensive as well as finding that there’s no archivelog backup for a database as you will find old archivelog directories and more…
- A list of all running instances on the server is now shown on top of the asmdu output; I found that handy to have that list here
- I also put some colored thresholds (red, yellow and green) to be able to quickly see which diskgroup has a space issue; you can modify it easily in the script :
# # Colored thresholds (Red, Yellow, Green) # CRITICAL=90 WARNING=75
- The only pre-requisite is that oraenv has to work
You can find the code here.
We use it a lot in my team and found no issue with the script so far. Let me know if you find one and enjoy!
21 Comments. Leave new
Thanks for sharing, it is very cool.
Awesome script Fred!
Awesome script Fred ..working without any issues …
many thanks for sharing
Hi Fred,
Nice script. This works only with bash shell?
Regards
Suraj
Hi Suraj,
No, I do not use any bash specific syntax here, you can run it with ksh as well.
Fred
Thanks guys for your comments !
I have just edit the post to add a link to the script in case you have issues copying it from the blog as well as a paragraph about the fact that you can also pass a directory as a parameter (and not only a diskgroup) like :
[[email protected]_server ~]$ ./asmdu.sh FRA/DB6/ARCHIVELOG
This is very useful :)
Have a good day,
Fred
Hi Fred,
awesome script, I modified it a little bit that it works additionally for solaris.
the trick is for solaris to change from awk (in the solaris this is the ‘classic’ version) to nawk.
additionally the egrep regular expression format has to be modified that the new syntax works for linux and solaris.
Another difference is the parameters of the hostname command, in solaris there is no parameter ‘-s’
These are the modifications I made to your code, to get this script working on both operating systems.
# before setting ASM env
OS_TYPE=`uname -s`
case “${OS_TYPE}” in
“SunOS”) AWK_BIN=/usr/bin/nawk
HOST_NAME=`hostname`
;;
“Linux”) AWK_BIN=/bin/awk
HOST_NAME=`hostname -s`
;;
*) echo “unknown OS –> ${OS_TYPE}”
exit 1
;;
esac
# modify all occurences of plain ‘awk’ to ${AWK_BIN}
# modify egrep part: OLD: egrep “^([+]|[Aa-Zz])” –> NEW: egrep “([+]|[A-Z]|[a-z])”
# change first ‘grep pmon’ to ‘grep pmon_’ as ther is a solaris deamon with the name ‘ipmon’
ps -ef | grep pmon_ | grep -v grep | ${AWK_BIN} ‘{print $NF}’ | sed s’/.*_pmon_//’ | egrep “([+]|[A-Z]|[a-z])” | sort | ${AWK_BIN} -v H=”${HOST_NAME}” ‘BEGIN {printf(“%s”, “Databases on ” H ” : “)} { printf(“%s, “, $0)} END{printf(“\n”)}’ | sed s’/, $//’
Regards,
Timo
Thx fred for this script.
Comme d’hab, tu roxes!
hub
Great script, thanks!
I’m running on Solaris, and in my environments, I had to change all of the “awk -v” commands to “nawk”, and removed “-s” in the hostname command on line 27. Other than those changes, it worked great.
Hi, in AIX appears….
[RACQA-nodo1]> ./asmdu.sh
invalid range expression
syntax error The source line is 1.
The error context is
BEGIN {printf(“%s”, “>> href=”https: <<<
awk: The statement cannot be correctly parsed.
The source line is 1.
DiskGroup Total_MB Free_MB % Free
——— ——– ——- ——
CRS 40961 40523 98
DATA 957441 346548 36
Hi Facundo,
It is due to a bad copy and paste from the blog.
I will upload the script using github and update the post, it will be better — I’ll let you know.
Sorry for the inconvenience.
Fred
Hi Facundo,
I have modified the link to the code to a github one (https://raw.githubusercontent.com/freddenis/oracle-scripts/master/asmdu.sh); please use this new link to copy and paste the script. It should be better now.
Thanks,
Awesome script.
Hi Fred,
Thanks for sharing the script. Ths is very usefu. But unfortunately the du command is very slow in our env. Which is causing the script to run for longer time. I read in docs that if we use *_STAT tables instead like instead of using v$asm_diskgroup if we use V$ASM_DISKGROUP_STAT the queries will be quicker as the queries on _STAT will read data from cache. But I am having trouble getting sql equivalent of du which we can use to retrieve data on subdirectories. Can you please let me know of you are aware of this?
Thanks again!
Hi Aditya,
Yes, “du” is slow but to speed it up, we would have to redevelop the command itself then being unaware of anything if Oracle changes something in his design. Or wait for Oracle to make a better “du” for ASM but I don’t think it is worth waiting for that. Sadly, I think we have to live with it as long as ASM will live.
About the _STAT views, it is a bit different; the _STAT views are faster because they do not perform a rediscover of new diskgroups.
Have a good day,
Fred
Is possible to create a recursive version, just like ordinary **ix du implementations?
Hi Luis,
As far as I understand your question, this is what it does.
Could you please give me an example of what you expect and that is not implemented ?
Thanks,
Fred
Hi,
Thanks for your awesome script
I have just found my old version of “df emulation in ASM”
System guys like to have the same format :)
https://oracledba.blogspot.com/2007/12/df-emulation-in-asm-asmbdf.html
Hello Fred,
Thanks for the wonderful script.
For me, Diskgroup parameter is not working.
ed07-prd01:ed07adm01vm01(ororgrid:+ASM1): ./asmdu.sh
Instances running on ed07adm01vm01 : +ASM1, ………………………….
DiskGroup Redundancy Total TB Usable TB % Free
——— ———– ——– ——— ——
DATAC1 HIGH 64.29 43.65 67
DBFS_DG1 HIGH 0.02 0.02 100
RECOC1 NORMAL 2.87 2.51 87
ed07-prd01:ed07adm01vm01(ororgrid:+ASM1): ./asmdu.sh DATAC1
Instances running on ed07adm01vm01 : +ASM1, …………………
DiskGroup Redundancy Total TB Usable TB % Free
——— ———– ——– ——— ——
DATAC1 HIGH 64.29 43.65 67
DBFS_DG1 HIGH 0.02 0.02 100
RECOC1 NORMAL 2.87 2.51 87
ed07-prd01:ed07adm01vm01(ororgrid:+ASM1): ./asmdu.sh +DATAC1
Instances running on ed07adm01vm01 : +ASM1, …………….
DiskGroup Redundancy Total TB Usable TB % Free
——— ———– ——– ——— ——
DATAC1 HIGH 64.29 43.65 67
DBFS_DG1 HIGH 0.02 0.02 100
RECOC1 NORMAL 2.87 2.51 87
Anything I am missing ?
Hello Fred,
Passing diskgroup with -d works.
# ./asmdu.sh -d RECOC1
Thanks
Hi Rajesh,
Indeed, this behavior has been modified with version 3 : https://unknowndba.blogspot.com/2018/03/asmdush-far-better-du-for-asmcmd.html
Thanks,
Fred