We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Monitor capacity of directory only

Medium Priority
364 Views
Last Modified: 2013-12-26
I am really stuck on finding a solution to a problem here.
I have a directory located at /lcl/app/prd/test1

I would like to be able to do the following...
Find the allowed space given to the directory test1.
Then find the capacity at which the directory test1 is at.

I was doing it this way...
space=`df -bhk /lcl/app/prd/test1| cut -d "y" -f1 | awk '{print$5}'`

However that seems to give me the capacity of the whole mount.  I only want a capacity of the directory test1, nothing before it should be included in the calculation.

I also thought of using the du command however I do not understand how to first look at the space given to the directory test1 and then how to compare that to the results of du since du does not give capacity.  I am not sure how to convert that into a capacity number which is exactly what I must have.

For example I would like to know if the directory test1 is at 80% capacity.
Again I do not want the whole filesystem... ONLY the directory test1.

Can anyone help me with this?  I am having a hard time figuring it out and I can not seem to find any answers on it.  Thank you in aadvance.

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013

Commented:

Hi,
unless you were using quotas, there is no such thing as 'directory capacity'.
So you're on the right track when using 'df'.
Should there be quotas, however, you can check with
'repquota /lcl/app/prd/test1'
Note, however, that quotas exist only on a per-user basis.
wmp

Author

Commented:
The issue is I am not sure how to check for what the amount of storage that was given to that directory in the first place so that I can run the df return number against the amount of storage given number to see what percentage of that is full.  Or for that matter how to turn the value given from the df into a percentage.
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013

Commented:
df gives you a percentage!
Look at the column titled 'Use%' (or the like, depending on your Unix flavor).
 
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013

Commented:
Don't worry about the #!/bin/ksh
The script will run under bash as well!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.