Capacity of directory... Pulling hair out :-)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Capacity of directory... Pulling hair out :-)
# 1  
Old 06-26-2009
Capacity of directory... Pulling hair out :-)

I am new to scripting and thought I was doing rather well however I ran into a issue and I am not sure how to fix it. I am using the following command to obtain the capacity percent of the directory listed however it seems that this command gets the capacity of the whole mount rather then just the directory specified.

Code:
df -bhk /lcl/prd/data/sm2p/archives | cut -d "y" -f1 | awk '{print$5}'

81%

I only want toe capacity of archives and not the capacity of the whole mount. The folder archives is empty yet it comes back with 81% because its looking at the whole mount.

Am I using the wrong command (df)? I am not sure how to obtain what I want here.

Thanks in advance for the help.
# 2  
Old 06-26-2009
You are asking the system a question for which there is no sensible answer. Free space is by FILESYSTEM, not directory. If the filesystem mountpoint is the directory, then free space is for the directory (which == filesystem) and all of its children.

You can ask are there any files in the directory, or how many bytes are used by the files in the directory. Then
Code:
 100 * (bytes used/bytes in filesystem)

gives an approximate answer. This doesn't take into account the fact that files are uusally mapped onto a minimum allocated disk space. For example, a 1 byte file actually uses say 1024 bytes, and a 480 byte file is also stored in a 1024 byte parking place.

480 + 1 = 481 but the actual used space is really 2048 - in this example.
# 3  
Old 06-26-2009
Sounds like you need 'du' instead of 'df' but it's going to give you the size of a file/directory not percentages.
# 4  
Old 06-26-2009
Quote:
Originally Posted by mglenney
Sounds like you need 'du' instead of 'df' but it's going to give you the size of a file/directory not percentages.

Is there a way to convert that to percentages?
I am not concerned with the sizes of the folders leading up to the one I want to monitor. I only want the percentage full of the archives folder.

Thanks again for the help.

---------- Post updated at 08:09 AM ---------- Previous update was at 07:06 AM ----------

I see how to use the du... for example....

Code:
du -s /lcl/prd/data/sm2p/archives | cut -f1

But I still do not understand how to figure out the capacity of the folder from the return or how to take that and turn it into a percentage.

Last edited by Yogesh Sawant; 06-26-2009 at 01:23 PM.. Reason: added code tags
# 5  
Old 06-26-2009
The format of "df" varies across platforms. Please state you Operating System and preferred shell.
Ignoring unix quotas (rarely ever used).the maximum total size of the files in a
directory equates to the available free space in that mountpoint.
# 6  
Old 06-27-2009
Code:
But I still do not understand how to figure out the capacity of the folder from the return or how to take that and turn it into a percentage.

As Jim Mcnamara there is no concept of "capacity of a folder" in Unix or GNU/Linux. For starters Unix and GNU/Linux has directories not folders. And unlike Windows/DOS FAT12 or FAT16 there is no inherent limitation on the number of files in a directory. Unless you are using quotas (and generally only large organizations use quotas) the best you can do is determine the capacity of the filesystem on which the directory resides and the amount of free or allocated space on that filesystem.
# 7  
Old 06-29-2009
Quote:
Originally Posted by fpmurphy
Code:
But I still do not understand how to figure out the capacity of the folder from the return or how to take that and turn it into a percentage.

As Jim Mcnamara there is no concept of "capacity of a folder" in Unix or GNU/Linux. For starters Unix and GNU/Linux has directories not folders. And unlike Windows/DOS FAT12 or FAT16 there is no inherent limitation on the number of files in a directory. Unless you are using quotas (and generally only large organizations use quotas) the best you can do is determine the capacity of the filesystem on which the directory resides and the amount of free or allocated space on that filesystem.
So I want to make sure I am understanding this correctly....
There is no way to monitor only the size of the directory?
We have file systems that may have a few directories within them that belong to different groups so I want to be able to monitor the directories independantley. So for example if I have 3 directories....

Directory 1 Belongs to Group A
Directory 2 belongs to Group B
Directory 3 belongs to Group C

If Directory 2 fills beyond 80% of its capacity I do not want Group A and C to have to check their directories when we know its not theirs thats filling things up.

Also the OS is Solaris 10 and shell is ksh.

Last edited by LRoberts; 06-29-2009 at 08:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

FS capacity

can anyone tell me how to reduce Fs capacity by using echo zero. (3 Replies)
Discussion started by: nkchand
3 Replies

2. AIX

Directories getting 100% capacity

I am new to using AIX but ive ran into issues with 100% full and then rebooting and having a socket error repeating over and over. My question is, what can I do besides just monitoring to ensure I dont run into these issues? Scripts? anything? Thanks (3 Replies)
Discussion started by: terry.berger
3 Replies

3. AIX

TSM capacity

Dears, The TSM storage that we have is already configured to backup some Application,directories & logs or let's say backup different path from 15 servers, I want to add more Items to be backuped by this storage, how to be confirmed if that possible or not? I mean how do we know the capacity of... (7 Replies)
Discussion started by: arm
7 Replies

4. Shell Programming and Scripting

Can't Commit Directory... is this guy pulling my leg?

Hello, I hired a coder a couple weeks ago to develop 3 small modules for a popular CMS. I created Github repos for each module so as to manage the code and allow others to download it at will. The CMS in question is structured in such a way that each module is housed in its own... (2 Replies)
Discussion started by: fern
2 Replies

5. Shell Programming and Scripting

Filesystems using more than 75% capacity

i need to write a shell script for printing the list of filesystems whose disk utilization is more than 75%...i tried using df -h along with awk but cud'nt make the combination work.....:wall: when we do df -h then the filesystems which are using more than 75% capacity shud be printed according to... (11 Replies)
Discussion started by: xtatic
11 Replies

6. Shell Programming and Scripting

Monitor capacity of directory

Good morning. I have been attempting to find a way to monitor the capacity of a directory so that when it reaches 80% or higher I can send an event. I was able to find a script that does this for the whole drive by I can not seem to figure out how to do this for just a single directory. ... (1 Reply)
Discussion started by: LRoberts
1 Replies

7. AIX

capacity planning on aix

Hi All, What do you usually use for capacity planning on AIX? Any idea will do? Thanks in advance, itik (1 Reply)
Discussion started by: itik
1 Replies

8. AIX

How to increase capacity?

Hello everybody, is a very simple question how can I increase the capacity of a disk wich is on a DS4300?, I have done the procedure on the Storage Manager but the space is the same on the AIX (5.3) , what should I do to obtain the new ammount of disk space? (16 Replies)
Discussion started by: GermanSkull
16 Replies

9. UNIX for Advanced & Expert Users

i'm pulling my hair out getting a solaris 8 box to work as a caching name server

i've gone through the sun docs as well as a Solaris Network Admin book. while the book is fair, it lacks detail and i'm sure there are things it's missing on getting a caching only name server working. as for the sun docs... what it has is really miserable. i can't make anything out of it. ... (4 Replies)
Discussion started by: xyyz
4 Replies
Login or Register to Ask a Question