Folder level size monitoring


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Folder level size monitoring
# 15  
Old 10-05-2011
Ah yes, never good at counting zeros. I agree, that's about 3Gb.

Smilie Sorry about that. Smilie



A change in content of /home could cause a spectacular failure, but as I'm not a software house, this is just some help to get started. Best to consider the 'interesting opportunity' for yourself to work out how you want to detect / handle this exception.

I'm not sure what happens at the end when the two data files that are pasted are different length. You would have to try and adjust the scripting suggestions. It might go a bit wild.



Take care,
Robin
Liverpool/Blackburn
# 16  
Old 10-05-2011
Hi Robin,

I am still not convinced how this script to cause any failure or trouble. From what I understand the script is going to check the du for home...report the size of each sub-folders...dump to current file and previous file...make a comparision between these two files...find which folder has 30 GB more data from the time the script was last run...and report any alert for such folders. Not sure am I missing out here? Sorry

Thanks
# 17  
Old 10-05-2011
Well, in /home on a test server I have, the du reports only a few lines:-
Code:
8     caroot
0     guest
0     lost+found

If I add an empty directory aaaaaaaa then capture the output from du -ks * to a file to use as my initial 'previous' file, then remove the directory aaaaaaaa again, running the script tell me that directory aaaaaaaa (which no longer exists, of course) has grown by 8, and caroot (which has not changed) has shrunk by 8. The others are unchanged, but it could get complicated if they had any contents to start with.


Try it out as a test (i.e. don't send any e-mail) It is just a report, after all.



Does that help to illustrate the risks? Of course, if you are sure that there will be no changes at the top level (e.g. new users) then go ahead.




Robin
Liverpool/Blackburn
This User Gave Thanks to rbatte1 For This Post:
# 18  
Old 10-06-2011
Hi Robin,

The script is working the way I desire. However, the email alert that is being generated looks like below:

Total amount of data in is KB and exceeds the limit of kB!

Our original script had "Total amount of data in $dir is ${size}KB and exceeds the limit of $limit kB!" .....how can I get the name of the actual directory name (that exceeds the limit) and the size in the alert email?

Thanks

---------- Post updated 10-06-11 at 02:19 PM ---------- Previous update was 10-05-11 at 09:56 PM ----------

Hi Robin,

Can you help me with my last post for the alert email. Thanks.

Shailesh
# 19  
Old 10-07-2011
Ah! Sorry.

The variable in the message should be $dir1 because that is what is being read back in from the work file. Of course, you could user $dir2 too, because they should always match, unless we have that problem where files/directories change in /home



Oops! Smilie

Apologies again,
Robin
Liverpool/Blackburn
# 20  
Old 10-07-2011
Hi Robin,

Thanks for the reply. Can you let me know whether we can also report the size of the folder along with this script. I need to have the alert saying that folder ABC current size is xx KB/MB and earlier it was xx KB/MB. Also, I need to get down deeper like it can check for more sub-folders within the /home/ABC folder...can that be done?

Regards.
# 21  
Old 10-07-2011
Quote:
Originally Posted by Shailesh6
Also, I need to get down deeper like it can check for more sub-folders within the /home/ABC folder...can that be done?
If you would have stated your requirements clearly to begin with, you would have saved yourself and Robin a lot of time.

The code you've been provided has a serious shortcoming which has been pointed out to you. That limitation, in conjunction with a requirment to monitor directories at all levels of a hierarchy, means that the serious shortcoming is almost certainly a dealbreaker.

Whereas monitoring the perhaps relatively static set of directories directly beneath /home may not trigger the flaw very often, monitoring directories at all levels is much, much more likely to yield errors.

And still, at this point, you haven't fully stated your requirements. For example, should the size calculated for a directory include the contents of all its subdirectories, or only the files in that directory? If the former, that means that any directory exceeding the growth limit will cause all components of its path to also exceed their limit, creating a lot of noise in the report. If the latter, the task is a bit more complicated.

Regards,
Alister

Last edited by alister; 10-07-2011 at 11:03 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting folder more than 100K size

Hi , I am trying to get the folder details having size more than sme specified value and also the name of the folder should be like TEST. so 1. In the current directory search for all the folders having name like TEST 2. Print the list of the folder names having size more than 100... (3 Replies)
Discussion started by: Anupam_Halder
3 Replies

2. UNIX for Dummies Questions & Answers

General question about folder level permissions

How is the level of access on a particular folder determined? I have heard (its just hearsay so am not particularly sure of it) that the access a particular user/group has to a low level directory is also affected by the level of access granted to the user/group on its parent directories. e.g. ... (1 Reply)
Discussion started by: jawsnnn
1 Replies

3. Shell Programming and Scripting

Log folder size monitoring script

Hi All, Can anyone refer to me a readymade script for the purpose of log folder size monitoring script. Example : I have a log folder of size 10 G, and as the logs keep accumulating the folder gets full and i have to manually zip/remove the files in order to keep the server running. Something... (1 Reply)
Discussion started by: findjai
1 Replies

4. UNIX for Dummies Questions & Answers

Network monitoring at boot level.

Whenever i start my server it takes app 2 minutes to get into network (After starting the network service on boot). I inquire the network guys for possible causes but they say it will need both side monitoring . One is switch side and the second is server side. I m not sure how do i check... (6 Replies)
Discussion started by: pinga123
6 Replies

5. UNIX for Dummies Questions & Answers

Redirect with htaccess to upper level folder, how to?

Hello, Well I have a web with a very bad structure (a vBulletin forum) and I want it redirected to a newer folder in the same server but with a upper level folder. Current structure is: https://www.unix.com/vbulletin/upload/index.php And I want it to be:... (0 Replies)
Discussion started by: Rafaweb
0 Replies

6. UNIX for Dummies Questions & Answers

find files on first level folder

Hi: I have: folderA |----folderB |----folder1 |----folder2 |----folder3 |----folder3.1 Question: How can I find *.txt ONLY from /folderA/folderB/ and not the others folder1,2,3?? I tried: find... (8 Replies)
Discussion started by: iga3725
8 Replies

7. Cybersecurity

Ubuntu folder level security

I have installed ubuntu. And I have create users ans groups. Suppose if the user enter into through Putty SSH. He should have access only to home folder and cannot move to other than $HOME. User should not able to root files and /$ files. Kindly provide solution. Regards Vasanth kumar (3 Replies)
Discussion started by: vasanthrj
3 Replies

8. UNIX for Dummies Questions & Answers

size of a folder ?

hi, is possible to calculate the size of a folder using ls ? ls -s works only for files.. thanks (2 Replies)
Discussion started by: aneuryzma
2 Replies

9. Shell Programming and Scripting

operation on a folder level

hi, need help in writing a script in perl. requirement : 1. Search for the files in a particular folder 2. search for a string in the file names 3. Delete the file which matches the string. Ex: if the folder is C:\TEST and the folder has 5 files like 2009ABCG.txt 2009MNO.txt... (2 Replies)
Discussion started by: adityamahi
2 Replies

10. UNIX for Dummies Questions & Answers

Need help in finding Folder Size

Hi, I would like to find the size of a folder. When I run the command du -k It is going through all the sub-folder and files and taking really much time. Is there any command to get the complete directory size without showing the sub-folder and file size. Appreciate your response. ... (3 Replies)
Discussion started by: TonySolarisAdmi
3 Replies
Login or Register to Ask a Question