The Drive Space module collects disk space usage data, including drive name, type, label, capacity, free space, percent free, and file system.

Discussion

One of the biggest issues DBAs have is with disk management, aka “disk free space monitoring”. This makes sense: we as DBAs aren’t usually in control of ordering or parceling out disk space, but the systems we’re in charge of typically take up more space than anything else in the company.

So, we have a great storm brewing:

  • Database and backup files take up a ton of space
  • DBAs usually don’t manage disk space allocation, and must request space
  • There is no automatic space monitor/alert/management that comes installed with the OS, or with SQL Server

We’re absolutely primed for disks to run out of space, bringing down databases or ruining backup solutions. The best solution must have a few key features, and of course Minion Enterprise does:

  • Collect disk space usage data into SQL Server tables in a central location.
  • Use that data to project when the disk is likely to become full (or better still, 80% or 90% full).
  • Automatically alert the DBA team. 
  • Provide disk-specific configuration. After all, not all disks should be alerted on at 10% free space.
  • Allow for disk alert exceptions (for disks that should never be alerted on).
  • Allow for disk alert deferrals (for those times when the new SAN is already on the way and there's nothing else to do).
 

Tables

Collector.DriveSpace

Holds drive space data collected from servers.  Drive space alerts depend on the information in this table.

Name Type Description
ID bigint Primary key row identifier.
ExecutionDateTime datetime The execution date and time, common to the run of a collection for a single instance.
InstanceID int The instance ID of the instance in question, as defined in the table dbo.Servers.
Name varchar The name of the drive. Example: C:\
Caption varchar The capion of the drive. Example: C:\
DriveLetter varchar The drive letter. For example, C:
DriveType varchar The drive type. Minion Enterprise only collects data on drives of type 3 (Local Disk), including mount points mapped as local disks.
FileSystem varchar File system on the logical disk. Example: NTFS.
Label varchar The volume label (the name) of the disk.
Capacity bigint Size of the volume. Measured in bytes.
FreeSpace bigint Space available on the logical disk. Measured in bytes.
%Free decimal Percentage of the disk that is free.

 

dbo.DriveSpaceReport

This table is where alert thresholds are configured.
Name Type Description
InstanceID bigint The instance ID of the instance in question, as defined in the table dbo.Servers.
Drive nvarchar(1000) Drive letter of the drive you wish to configure a threshold for. 'MinionDefault' means all drives.  See below for details.  A drive letter must be in the format of '<drive letter>:\'
AlertMethod varchar(10) The unit of measure you want to use for the threshold.  Accepted values are Percent, KB, MB, GB.
AlertValue int The value of the threshold you wish to create.
Report bit This denotes where you want to report on threshold violations.  Use this column to disable alerts for a server or an individual drive.
IsActive bit This denotes whether the current threshold row is active.  This allows you to deactivate threshold rows temporarily without losing the values. 
Comment nvarchar(1000) Any comment you want to make about the row itself.  It's standard to use this to explain why the config value was set, but can also be used in conjunction with IsActive to help programmatically turn rows on and off.
 

Alert.DriveSpaceDefer

This table holds drive space deferrment orders. Insert a row here to prevent ME from sending drive space alerts for a particular drive, for a set period of time.

Name Type Description
ID int Primary key row identifier.
InstanceID int The instance ID of the instance in question, as defined in the table dbo.Servers. Note: Any time you see InstanceID = 0 in Minion Enterprise, it represents a global default.
DriveLetter varchar The drive letter. For example, C:\
Caption varchar The capion of the drive. Example: C:\
DeferDate date The date on which the deferment begins.
DeferEndDate Date The date on which the deferment expires.
DeferEndTime time The time at which the deferment expires.
 

Views

Collector.DriveSpaceCurrent

Provides the most recent collection of drive space data.

Each “Current” view associated with a Collector table contains all (or nearly all) of the columns from the base table, plus a “ViewDesc” description column, and columns from dbo.Servers data:

  • ServerName
  • ServiceLevel
  • Version
  • Edition
  • Descr

Collector.DriveSpacePrevious

Provides the next-to-most recent collection of drive space data.

Each “Previous” view associated with a Collector table contains all (or nearly all) of the columns from the base table, plus a “ViewDesc” description column, and columns from dbo.Servers data:

  • ServerName
  • ServiceLevel
  • Version
  • Edition
  • Descr

Stored Procedures

Collector.spDriveSpaceInsert

The script calls this procedure to perform the insert into the Collector.DriveSpace table.

Important: This procedure is meant to be used by automated collectors; we recommend against using it manually. Therefore, the parameter set is only documented internally.

Setup.DriveSpaceDefer

Allows you to set up a drive space deferment for a specific drive, for a set period of time. This allows you to keep the alerting system in place, but prevent alerts for situations that are under control.

For example, if Server1 drive D: has 2GB space left, but the drive is scheduled to be expanded over the weekend, you can defer alerts for Server1 drive D: until Monday.

Parameter Type Description
@ServerName varchar The name of the server to receive the deferment.
@DriveLetter varchar Drive letter to defer alerts on. E.g., ‘C:\’.
@DeferDate date The date on which the deferment should begin.
@DeferEndDate date The date on which the deferment should end.
@DeferEndTime time The time at which the deferment should end.
 

Setup.DriveSpaceException

Allows you to set up a drive space exception for a specific drive.
Parameter Type Description
@ServerName varchar The name of the server to receive the deferment.
@DriveName varchar Drive letter to except alerts on. E.g., ‘C:\’.

Jobs

CollectorDriveSpace-GOLD

Calls the executable DriveSpace.exe for all servers with ServiceLevel = ‘Gold’, to retrieve drive space information.
 

CollectorDriveSpace-SILVER

Calls the executable DriveSpace.exe for all servers with ServiceLevel = ‘Silver’, to retrieve drive space information.
 

CollectorDriveSpace-BRONZE

Calls the executable DriveSpace.exe for all servers with ServiceLevel = ‘Bronze’, to retrieve drive space information.
 

Executables

DriveSpace.exe

Collects drive space data for the instances in the specified service level, and logs the results to Collector.DriveSpace via the procedure Collector.spDriveSpaceInsert.

Input parameters:
  • $Query – This parameter refers to the service level that the collector should operate on. Examples: Gold, Silver, Bronze. For more information on this topic, see the article “Executables and Service Levels”.
Example execution:
C:\MinionByMidnightDBA\Collector\DriveSpace.exe Gold
 

Examples

Examples: Set up deferments, exceptions, and thresholds

Drive Space is a particularly flexible module, in that you can set your own drive-level alert deferments, drive-level alerting exceptions, server-level alert thresholds, and even drive-level thresholds.
Drive level alert deferment:
On Svr1, the E:\ drive is slowly filling up. Today it hit the threshold configured or the server – 5GB space free – and sent you an alert. You did your due diligence and determined that the E:\ drive really needs more space, and so you put in your request. Since you know about the issue, and now have to wait a week for the disk team to fulfil your request, you can defer further alerts about that drive for the next seven days. You shouldn’t keep getting the alert if the situation is under control!

Insert a row to the Alert.DriveSpaceDefer table, using the Setup.DriveSpaceDefer procedure, for Svr1 drive E:\, that ends 7 days from now:

EXEC Setup.DriveSpaceDefer @ServerName = 'Svr1',
    @DriveLetter = 'E:\',
    @DeferDate = '2016-02-23',
    @DeferEndDate = '2016-03-01',
    @DeferEndTime = '08:00:00';

 
Alert deferments can be extremely powerful. For example, you may want to turn off all alerts for C:\ drives across all “Bronze” level servers.  One simple insert statement will do this for you:

INSERT INTO Alert.DiskSpaceDefer (InstanceID
     , DriveLetter
     , Caption
     , DeferDate
     , DeferEndDate
     , DeferEndTime )
SELECT  InstanceID
      , 'C:\' AS DriveLetter
      , 'C:\' AS Caption
      , '01/01/2015' AS DeferDate
      , '12/31/2100' AS DeferEndDate
      , '00:00:00' DeferEndTime
FROM    dbo.Servers
WHERE   ServiceLevel = 'Bronze';

 
You could just as easily defer alerts in this way by environment, by SQL Server version or Windows version, or in any other way you can image. The data is there.

Drive level alerting exception:
Let’s say that there’s a drive you never, ever want to receive an alert on (in our case, drive D:\ on Svr10, which has InstanceID 10). Perhaps it’s someone else’s responsibility; perhaps there are no, and never will be, any SQL files on that drive. For whatever reason, you just don’t want to hear about it. In that case, insert a row to the dbo.DriveSpaceReport table:

INSERT INTO dbo.DriveSpaceReport
        ( InstanceID , Drive , AlertMethod, AlertValue, Report, IsActive, Comment)
-- Svr10: 
VALUES  ( 10 , 'D:\'  , 'GB'  , 5, 0, 1, 'Never alert on D: for this server.' );

 
Now, you will never be alerted on the Svr10 D:\ drive.
While the threshold was set to 5GB, it was only done for continuity purposes in case reporting ever gets turned back on the values aren't NULL.  The import part here is that Report is set to 0.

Server-level threshods:
You can set the drive space alert threshold at the server level using the dbo.DriveSpaceThresholdServer table (which makes this a sort of “server level default” for drive space thresholds, right?). What’s more, you can use one of a handful of alert methods: percent, GB, MB, or KB remaining on disk.

Let’s configure Svr1 to have a 10% threshold for alerts, and Svr2 to have a 5GB threshold:

INSERT INTO dbo.DriveSpaceReport
        ( InstanceID , Drive , AlertMethod, AlertValue, Report, IsActive, Comment)
-- Svr1:
VALUES  ( 10 , 'MinionDefault'  , 'Percent'  , 10, 1, 1, 'All drives for this server.' ),
-- Svr2:
VALUES  ( 17 , 'MinionDefault'  , 'GB'  , 5, 1, 1, 'All drives for this server.' );


Done!

Drive-level threshods:
Drive level thresholds are extremely similar to server level; they’re just drive-specific. If you have a server-level threshold, and a drive-level threshold, for the same server, then of course the drive-level threshold will apply for that drive; and the server level threshold will apply for all the other drives on the server.

Let’s configure Svr1’s Z:\ drive to have a 2GB threshold for alerts:
INSERT INTO dbo.DriveSpaceReport
        ( InstanceID , Drive , AlertMethod, AlertValue, Report, IsActive, Comment)
-- Svr1:
VALUES  ( 16 , 'Z:\'  , 'GB'  , 2, 1, 1, '2GB alert on Z: for this server.' );
Now, we will receive alerts when the Svr1 Z:\ drive is below 2 GB free space; and when any other drive on Svr1 is below 10% of its free space.

Global threshods:
One of the features that makes Minion Enterprise unique is its ability to be configured at a global level.  The system is installed with a single global threshold.  But you can define your own to perform some powerful things.  You can define individual drive thresholds at a global level.  Let's say that you want to never alert on a C: anywhere in your environment.  That's really easy to do.

INSERT INTO dbo.DriveSpaceReport
        ( InstanceID , Drive , AlertMethod, AlertValue, Report, IsActive, Comment)
-- Svr1:
VALUES  ( 0, 'C:\'  , 'GB'  , 2, 0, 1, 'Globally disable alerts for C:.' );
Now, you'll never see alerts for C: for any servers.

***It should be noted though that more-specific always beats less-specific.  So while the above global setting applies, it can be overridden by a server-specific setting.  This means that if there is a server that you do want to receive alerts on C: for, you can simply enter in a row for that server and it'll be excepted from the global setting.

 
https://minionware.desk.com/customer/portal/articles/2376684-drive-space-module
http://www.MinionWare.net