Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Posts
    29

    Unanswered: Script required for disk growth

    Hi,

    I am seeking a small script which runs on a daily basis and informs me of the disk usage and growth on a daily basis.

    What I am seeking is something that will look like this in a report:

    Monday 25th March (or the current date)
    /u01 - disk usage 56% - growth today = 2%
    /u02 - disk usage 34% - growth today = 14%
    /u03 - disk usage 68% - growth today = 0%

    df -h is useful, but I cannot simply determine the data growth over a specific period.

    If anyone has something similar can you please post

    Many thanks in advance from a junior SA

    tspoon

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    I won't do it for you, but I will help you do it.
    Create a directory structure as:
    disk_usage_log
    2013
    01-12
    01-31
    You should be able to cd to disk_usage_log/2013/03/25 when you are finished.
    Write a script to do this for any year. Ignore the fact that some months do not have 31 days.

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Next create a script to place the output of 'df -v' into disk_usage_log/$year/$month/$day/all.
    Use the date command to assign values to $year, $month and $day.
    Run this script once per day.

  4. #4
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    SuSE Linux
    mail:~ # df -v
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/dm-3            295898632  25063376 255804444   9% /
    devtmpfs               1958980       136   1958844   1% /dev
    tmpfs                  1958980        12   1958968   1% /dev/shm
    /dev/dm-1                69972     30144     36215  46% /boot
    mail:~ #
    SCO Unix
    # df -v                                                                
    Mount Dir  Filesystem              blocks      used      free   %used  
    /          /dev/root              9297916   4917056   4380860    53%   
    /stand     /dev/boot                81918     12838     69080    16%   
    /u         /dev/u               102376956  29595696  72781260    29%   
    #
    At this point the file 'all' should look like one of the above.
    Now write a script to read this file and create a directory based on the file system name (you will have to remove any / in the file system name, or replace it with some other character, maybe an underscore.) Then create a directory with that name, and in that directory create two more files, one named 'size' the other named 'used'. The contents of these files should be the values for size and used.
    At the end you should have something like this:
    Code:
    # pwd                                                         
    /u/usage_log/2013/03/28/tmpfs                                 
    # l                                                           
    total 8                                                       
    -rw-r--r--    1 root     sys          8 Mar 28 09:46 size     
    -rw-r--r--    1 root     sys          3 Mar 28 09:46 used     
    # cat size                                                    
    1958980                                                       
    # cat used                                                    
    12                                                            
    #

  5. #5
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    After a few days of collecting data, you should be able to write a report script.
    The script should accept as input the starting year, month, day, the ending year, month, day and the file system name.
    The heart of the report scripts is:
    Code:
    start_used=`cat $start_year/$start_month/$start_day/$fs/used`
    end_used=`cat $end_year/$end_month/$end_day/$fs/used`
    percent_chg=`echo  "( $end_used - $start_used ) * 100 / $start_used"|bc`

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •