Disk Trend Analysis

Overview

This script was written to help with reporting on disk activity. Initially it simply collected daily disk utilisation data and created a graph showing the available disk space in percent. Each server would have one graph with each drive being a different colour line.

This initial script worked quite nicely, but there were some issues, like how many days of data is needed, how do we restrict or rotate the data in the files to only keep a specified amount of data? Since I didn’t want to prune the data files myself I decided to add a section to the script to rotate the data files. This section will ensure that the files keep no more than one year of data.

Now that I had a nice report and a clean, automatically managed set of data files, I felt that more could be done with the data. What resulted was a second report detailing the growth of each disk. The script generates a table with growth and change figures for each disk calculated from the data files. It also generates a graph report for each disk showing monthly utilisation and growth as well as a six month forecast, also calculated using the data.

The final reports give me a very good idea of the growth trend for each disk and it even highlights any of the disks that are expected to reach capacity in the next six months.

This has all been combined into a single script which needs to be run daily, preferably at the end of the day. I have built some intelligence into the script so that it only calculates growth after the first day of each month.

For the appearance in the reports, I have used a CSS file. If you would like to customise the look of the reports all you have to do is edit this file.

The graphs are generated using a freeware utiliy called Ploticus. This can be downloaded from this site or the source site. For this script all that is needed is the PL.EXE file. While there is a setting in the INI file for the location of the PL file, I find it better if it’s just located in the same directory as the script.

I have also added some ability to accept switches, should you need only some of the functionality. The current switches are:

-graphonly – Only generates the daily trend graph, no data collection
-growthonly – Only generates the growth table and graphs, no data collection
-nogrowth – Does not generate the growth table and graphs

To use this script, simply edit the DISKTREND.INI file to customise the reports and environment, then schedule the script to run once a day. I prefer to run it at about 11:00pm so that the data is accurate for the end of each working day.

It should be noted that the growth reports will not be generated until there is data from at least two months. The growth figures also can’t really be considered accurate until there is a years worth of data.

Required Tools

The following command line utilities are required for this script:

  • CLC.EXE
  • FINDSTR.EXE
  • SRVINFO.EXE
  • PL.EXE

The Files

This script is made up of a number of files. To view the files simply click on the link. They can also be downloaded from the download page.
The script files are explained briefly below:

  • DISKTREND.INI – File containing the general settings for the script. This makes customisations easier.
  • DISKTREND.CMD – The primary script. This collects the data then generates the graphs and growth reports.
  • SERVERS.TXT – This file simply contains a list of servers to be interrogated.
  • DISKTREND.CSS – This is the CSS file used for formatting the report pages. An alternative one can also be specified in the INI file.

The Reports

The script generates two reports. It would be worth having a look a them:

  • The Disk Trend Report displays a graph for each host showing the available disk space in percent for the last year or portion there-of.
  • The Disk Growth Report displays a table of growth figures for each volume on each host. It also has links to pages that contain historical bar graphs for each server.

How It Works

There is quite a process involved in this script, so I’ll be as detailed as I can.

First, this script reads the DISKTREND.INI for settings. I use the INI file for storing settings that can be easily changed to customise the script. In this script I only have a few settings, three for paths to the Ploticus, data and report directories, two for specifying the report and CSS file names, one for the number of months to forecast and one for a custom title.
I set the forecast to six months because I don’t believe any more would be useful.
There is also a setting to specify whether to use a locally generated host list. If set to yes, the script will extract a list of host names by running the NET VIEW command.
The UseFilter setting can be used to filter this list. The result will be all the host names that contain that string. If the string is preceded with a minus sign(-) it will return all host names not containing the string. The AlternateDomain setting is used if the command should be run against a different domain. The result is written to the SERVERS.TXT file.

The script then interrogates each server listed in the SERVERS.TXT file for information about it’s disks. I use SRVINFO.EXE to do this because it produces figures in megabytes only, making calculations and comparisons a lot easier. The script extracts the fields it needs from the output, calculates the percent value and appends the data to the file belonging to that server. If the script is run twice on the same day the data will only be written to the file the first time.

Once the data has been collected from all servers the graphs are generated. Custom GRA files are created based on the content of the data files. This GRA file is then used by the Ploticus utility to create the graphs.

Once the graphs have been generated the script will create the growth report. This is only done if the date is the second of the month or greater, and if the report does not already exist.

The growth section of the script creates a new set of data files that contain only that last line of data for each month, so basically the growth figures are based on the state of the disks on the last day of the month only. The script does this by dropping the day off the date field in the data file. It compares this from line to line and when it finds that the next line has higher date, it writes the current line to a new data file prefixed with a ‘~’. What you end up with is a data file that contains only the data from the last day of every month. This data is used to calculate both the growth from one month to the next and the change in growth from one month to the next. The average growth and the average change in growth are then used to forecast the growth for the next six months. I’m no statistics expert, but I believe that this is relatively accurate. If you know a better way, please let me know.

Once all the reports and graphs have been created, the script prunes the data files. This section splits the date into day, month and year, then subtracts one from the year. It then uses this to compare with the dates found in the data files, deleting entries that precede it.

When it’s all done, you have a series of web pages that contain the reports and graphs. What you do with them is up to you.

Leave a Reply

Your email address will not be published. Required fields are marked *