<DataSourceModuleType ID="Microsoft.Windows.Server.2012.AD.Availability.DiskSpace.DITPercent.DataSource" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ResultType" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/Disk_Space_DIT.vbs$ $Config/ResultType$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>Disk_Space_DIT.vbs</Name>
<Contents><Script>'*************************************************************************
' Script Name - Disk space
'
' Purpose - Gets the current free space on the disk drive that holds the AD database file
'
' (c) Copyright 2014, Microsoft Corporation, All Rights Reserved
' Proprietary and confidential to Microsoft Corporation
'*************************************************************************
Option Explicit
SetLocale("en-us")
On Error Resume Next
' TypedPropertyBag
const PerformanceDataType = 2
' Location of the DIT file
const DatabaseRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters\DSA Database File"
Sub Main()
Dim sPathDB, oAPI, oPerfBag, oDrive, oReg, oFileSystem, oParams, iResultType
Set oAPI = CreateObject("Mom.ScriptAPI")
Set oReg = CreateObject("WScript.Shell")
Set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oParams = WScript.Arguments
if oParams.Count <> 1 then
iResultType = 1
Else
iResultType = CInt(oParams(0))
if iResultType > 2 or iResultType < 1 then
iResultType = 1
End if
End if
' Read the path to the database file from the registry
sPathDB = oReg.RegRead(DatabaseRegKey)
Set oDrive = oFileSystem.GetDrive(oFileSystem.GetDriveName(sPathDB))
Set oPerfBag = oAPI.CreateTypedPropertyBag(PerformanceDataType)
if iResultType = 1 Then
oPerfBag.AddValue "StatusCounter" , "Database Drive Free Space"
oPerfBag.AddValue "StatusInstance" , sPathDB
oPerfBag.AddValue "StatusValue", "" & oDrive.FreeSpace
Else
oPerfBag.AddValue "StatusCounter" , "Database Drive Percent Free Space"
oPerfBag.AddValue "StatusInstance" , sPathDB
oPerfBag.AddValue "StatusValue", "" & (oDrive.FreeSpace / oDrive.TotalSize) * 100
End If