Need your help. I have a requirement to create one bash script for analyzing the disk usage. Let me detail here. We have a NetApp filer and it hosts many users’ home folders. The problem we face is that the disk usage is becoming full always. As the filer consists of too many folders, its very difficult for us to trace out the disk usage correctly. The procedure we follow now is to take a folder-wise screen-shot in a file and compare it to the previous screen-shot, by which we can find the difference in the folder size and trace out the folder whose size increased recently. Screen-shot in the sense, being in root /, we run this command: #du –sk * > filename.<date>. E.g: #du –sk * > diskusage.04Oct06
This file will contain the disk usage detail of all the folders in the root folder. To list all the folders based on size, we use the following command:
#cat diskusage.04Oct06|sort –n.
So when we want to find which folder size has increased recently, we will manually do a comparison between the current file and the previous week file. But this process is tedious, as we have to check several folders. That’s the reason I like to write a script for this (But I don't know much about scripting).
Let me tell you in simple terms about my requirements:
We have two files (say diskusage.04Oct06 and diskusage.28Sep06) which contains the folder-size details of a directory (say /). Now we need a script which compares these two files and get us a output of difference in disk usage of the respective folder.
The logic can work like this. First it should compare the strings (filenames) in both the files, if it matches, calculate the difference (filesize value) and display the result. Incase if both the strings aren’t matching then it should discard it. Hope you got it. Can anyone work on this and get me the script?
Sample disk usage screenshot file:
bash-2.05# cat dus.04-26-06|sort -n
PS: IF YOU HAVE ANY OTHER ALTERNATIVE SCRIPT ALSO, FINE WITH ME. All I want is to trace the disk usage.