AD Log File Disk Free Space (bytes) Script Data source

Microsoft.Windows.Server.2012.R2.AD.Availability.DiskSpace.LogBytes.DataSource (DataSourceModuleType)

Data source for the AD Log File Disk Free Space monitors.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterPropertyBagSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.Server.2012.R2.AD.Availability.DiskSpace.LogBytes.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_Log.vbs$ $Config/ResultType$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>Disk_Space_Log.vbs</Name>
<Contents><Script>'*************************************************************************
' Script Name - Disk space
'
' Purpose - Gets the current free space on the disk drive that holds the AD log 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 log file
const LogFileRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NTDS\Parameters\Database log files path"

Sub Main()
Dim sPathLog, 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 &lt;&gt; 1 then
iResultType = 1
Else
iResultType = CInt(oParams(0))

if iResultType &gt; 2 or iResultType &lt; 1 then
iResultType = 1
End if
End if

' Read the path to the database file from the registry
sPathLog = oReg.RegRead(LogFileRegKey)

Set oDrive = oFileSystem.GetDrive(oFileSystem.GetDriveName(sPathLog))

Set oPerfBag = oAPI.CreateTypedPropertyBag(PerformanceDataType)

if iResultType = 1 Then
oPerfBag.AddValue "StatusCounter" , "Log File Drive Free Space"
oPerfBag.AddValue "StatusInstance" , sPathLog
oPerfBag.AddValue "StatusValue", "" &amp; oDrive.FreeSpace
Else
oPerfBag.AddValue "StatusCounter" , "Log File Drive Percent Free Space"
oPerfBag.AddValue "StatusInstance" , sPathLog
oPerfBag.AddValue "StatusValue", "" &amp; (oDrive.FreeSpace / oDrive.TotalSize) * 100
End If

oAPI.AddItem oPerfBag

oAPI.ReturnItems
End Sub

Call Main()
</Script></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>