Universal Disk Free Space Monitoring (One Template Will Handle All Logical Disks + Exceptions And Overrides)

Dear All Thwack Members,


It is my pleasure to present you with this elegant template to help you out with monitoring free disk space across all your windows servers. As a matter of fact - 80% of all our incidents are disk space related and I hope this will help you out to handle this part in a simple and very flexible way


What's in the tin?

  • Monitor all your disks on all servers (requires just 1 SAM license per server)
  • Set global threshold based on Free MBytes AND Free % levels. This works perfectly well for both large (TBytes) disks and small (MBytes) disks
  • Differentiate between warning and critical level
  • Set overrides on a per disk per server level (very granular approach)
  • Exclude disks you do not want monitoring (either completely or setup overrides)
  • Track usage as a graph
  • Have it on your dashboard as a green/yellow/red blob (which is not possible out-of-the-box with SAM volumes)


Screenshots:


Component

001.JPG

Multi stat chart

002.JPG

Script Arguments:

003.JPG

Global Statistic:

004.JPG

Individual Disk Statistic for global overrides (example for "J" drive)

005.JPG

Dashboard:

006.JPG

007.JPG


Benefits:

  • If you are short on licenses - this will help you to monitor all disks with just 1 license per server
  • The biggest benefit for me (as my SAM is unlimited and first point is not really applicable) is that I can have it as a group item on  my dashboard. Very handy. Screenshot above
  • Ability to compare against both MBytes and Percentage levels definitely makes it very self-sustained and self-managed template. It just works for every single disk. I only have very few exceptions configured across 700+ volumes
  • When you add a new disk (in virtual world this is quite common) - you have your monitoring automatically enabled for it (without the need to discover new disk in SAM, what I often forget)


Additional info:


User description notes (copy-paste from template, for those craving more info):

---------------------------------

This smart script will monitor free space on all fixed local disks on Windows server.

* Global threshold, which is going to be applied for all disks on a server by default, is based on free percentage AND free bytes (for example, a particular disk has to be less than 5% AND less than 20GB to fire off warning alert). This works perfectly well for large disks measured in TBytes and small disks measured in MBytes

* You can exclude particular disk on a particular server from being monitored by global threshold and set custom threshold for this disk instead

* You can differentiate between critical/warning threshold levels.

>>> For the global threshold - this is achieved by incrementing "Statistic" counter in 100s for any critical breached disk and in 1s for any warning breached disk. (for example: Statistic value 102 means that we have 1 disk breached critical threshold and 2 disks have breached warning. Note, that when disk falls in critical level it will also be in breach of warning level as well. So, value 101 will indicate that 1 disk has fallen into critical level; likewise value 102 will indicate 1 disk critical and 1 disk warning)

>>> For the custom threshold - you just simply set values in SAM template for warning and for critical level for a particular disk

How to exclude disk / configure custom threshold:

When you need to override global threshold for a particular disk - you would first exclude this disk from being monitored by global threshold and second - you would configure separate threshold, which is based on free MBytes value, in SAM template below.

For example: disk F needs to trigger an alert when it drops below 150GB. In this case you would override script arguments with "${IP} 2 5000 5 20000 A,B,F" and you would set critical threshold to "less than 150000" as a SAM threshold value. You can also set SAM warning threshold as 200000 to be notified in advance

Limitations (all with very limited impact on usability and flexibility):

- You can only define custom thresholds for the first 8 disks (C,D,E,F,G,H,I,J). Note, that global threshold will still be applicable for all logical fixed disks, regardless of the quantity (unless you exclude any of them as explained above). In fact - this is very limited limitation as most of the servers will probably not have as many disks and even if they will - it is very rarely when you will need to define custom thresholds anyway - so, probability of this limiting your monitoring abilities is very low

- When you exclude particular disk - you can only set "MBytes" threshold value (no percentage threshold here). This is also very very limited issue, because at the time when you exclude particular disk - you already know exact size of it and you can work out yourself at what level in MBytes you want an alert to come through.

---------------------------------


Enjoy, comment, like, rate emoticons_wink.png


To Your Monitoring Success,

Alex


Update: 08/01/2016 - Slightly update script as per comments below to enable it to pick up mount points. Also, improve variable for disks exclusions - you will now need to enclose disk letter in square brackets to exclude it. Example usage is in the script/template itself. Thank you, Alex


  • This topic hasn't been updated in quite awhile.  Have there been any changes to this template that would allow it to monitor any drive that is available on a server?.. beyond J?  I have servers with many drives.  Thanks

  • Think I have found issue, needed to add the following lines above: Message = Message & " | " & objItem.Caption & "(" & objItem.Label & "), " & strFreePercentCurrent & "% Free, " & strFreeMBCurrent & "MB Free"

    strFreePercentCurrent = Round( ( (objItem.FreeSpace * 100) / objItem.Capacity),0 )

    strFreeMBCurrent = Round((objItem.FreeSpace / 1000000),0)

  • Hello,

    I'm running this script and it works perfect for drives C-J.  However, it doesn't work for other driver letters, see below it doesn't pick up the disk stats for the M: and S: drive.

    Capture.JPG

    I've also ran the VBScrpt from command prompt on various servers with multiple disks and get the same error:

    C:\_temp>cscript volumes.vbs 10.50.2.38 2 5000 5 20000 \A,B

    Microsoft (R) Windows Script Host Version 5.8

    Copyright (C) Microsoft Corporation. All rights reserved.

    Message.C: C:\(), 78% Free, 83779MB Free

    Statistic.C: 83779

    Message.01_Global: ALL DISKS: | \\?\Volume{bc4f20fe-6afe-11e6-80ee-806e6f6e6963}

    \(System Reserved), % Free, MB Free | M:\(Media), % Free, MB Free | S:\(Shadow C

    opy), % Free, MB Free | C:\(), 78% Free, 83779MB Free

    Statistic.01_Global: 303

    Is the script missing a section?  There seems to be a section to deal with calculating MB / Percent free in the If strElementInArray = 0 statement, but nowhere else to calculate this if this is false (i.e. not in the pre-programmed letters).

    If strElementInArray = 0 Then

    strFreePercentCurrent = Round( ( (objItem.FreeSpace * 100) / objItem.Capacity),0 )

    strFreeMBCurrent = Round((objItem.FreeSpace / 1000000),0)

    strDiskMessage = objItem.Caption & "(" & objItem.Label & "), " & strFreePercentCurrent & "% Free, " & strFreeMBCurrent & "MB Free"

    WScript.Echo "Message." & strDiskLetter & ": " & strDiskMessage

    WScript.Echo "Statistic." & strDiskLetter & ": " & CLng(strFreeMBCurrent)

    End If

    Thanks

    Chris

  • Hello Alex, thank you very much for the script! A quick question if you could help me, I am trying to modify the script so I can use it to monitor the disks on a scale out file server. From the WMI Explorer I can run a query (namespace: \ROOT\Microsoft\Windows\Storage, Class: MSFT_PhysicalDisk) and get the required information, see below:

    Capture.jpg

    Is there a way to output these information using your script? I changed the "Set objWMIService = GetObject ()" to only include "\ROOT\Microsoft\Windows\Storage" and under the main routine changed the "Set colItems = objWMIService.ExecQuery" to ""SELECT FriendlyName, Size, AllocatedSize, Healthstatus, Model, SerialNumber, PhysicalLocation FROM MSFT_PhysicalDisk" but when I am testing the script against one of my servers it fails with the following message: C:\ProgramData\SolarWinds\Orion\temp\66d778aa-8cca-4f44-8c45-255f3e68f4f3(61, 158) Microsoft VBScript compilation error: Unterminated string constant

    Any help will be greatly appreciated!

    Regards,

    Thanos

  • actually, just thinking further, it would be best fro you to re-create template with new script. When you create template, multiple arguments will be assigned with names upon creation. If you will just modify script, it will work correctly, but you will still see J for the output #9, even though it will work with M now. Can be confusing long term. So, just graba script, modify, create new template, save - that's it, should work with M and output number #9 will read as "M"

    pastedImage_0.png