<ProbeActionModuleType ID="Microsoft.Server.AD.2008.GeneralResponseCheck" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element name="TargetComputer" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Script" TypeID="System!System.Secure.CommandExecuterProbe">
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/GeneralResponseCheck.vbs$ $Config/TargetComputer$</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>GeneralResponseCheck.vbs</Name>
<Contents><Script>
'*************************************************************************
' Script Name - AD General Response Task
'
' Purpose - Monitors the general responsiveness of active directory and prints to stdout
'
' (c) Copyright 2006, Microsoft Corporation, All Rights Reserved
' Proprietary and confidential to Microsoft Corporation
'*************************************************************************
Dim objAD, objParams, objEvent, objADsObject
Dim lLastBind, lAverageBind, lCount, lFailureThreshold
Dim strMessage, strComputer
Dim bBindSuccessful
Dim dtStart
dtStart = Now
' Other Variables
Dim oParams, TargetFQDNComputer, strFailureThreshold, bLogSuccessEvent, IsTargetAgentless
Set oParams = WScript.Arguments
if oParams.Count < 1 then
WScript.Echo "One Parameter: <Computername> is required"
Wscript.Quit -1
End if
Set objAD = CreateObject("McActiveDir.ActiveDirectory")
If (0 <> Err.Number) Or (Not(IsObject(objAD))) Then
HandleScriptFailure "Failed to create object 'McActiveDir.ActiveDirectory'." & _
"This is an unexpected error." & vbCrLf & _
GetErrorString(Err.Number, Err.Description), _
lFailureThreshold
Else
objAD.Server = strComputer
Set objADsObject = objAD.BindObject("LDAP://rootDSE")
If (Err.Number <> 0) Or (Not(IsObject(objADsObject))) Then
Set oBag = oAPI.CreateTypedPropertyBag(StateDataType)
HandleScriptFailure "Failed to bind to 'LDAP://rootDSE'. This is an unexpected error." & vbCrLf & _
GetErrorString(Err.Number, Err.Description), _
lFailureThreshold
Else
bBindSuccessful = True
End If
Set objADsObject = Nothing
If bBindSuccessful Then
Set oBag = oAPI.CreateTypedPropertyBag(StateDataType)
lLastBind = objAD.BindLast
' Write the perf data, after converting to seconds (originally milliseconds)
Set oBag = oAPI.CreateTypedPropertyBag(PerformanceDataType)
WScript.Echo "Current DC bind time: " & (lLastBind / 1000) & " sec"
End If
Set objAD = Nothing
End If
End Sub
'******************************************************************************
' Name: CreateEvent
'
' Purpose: Creates a MOM event
'
' Parameters: lEventID, the ID for the event
' lEventType, the severity for the event. See constants at head of file
' strMessage, the message for the event
'
' Return: nothing
'
Sub CreateEvent(lEventID, lEventType, strMessage)
Dim sevString
Select Case lEventType
Case EVENT_TYPE_SUCCESS sevString="Success"
Case EVENT_TYPE_ERROR sevString="Error"
Case EVENT_TYPE_WARNING sevString="Warning"
Case EVENT_TYPE_INFORMATION sevString="Information"
End Select
If lEventType <> EVENT_TYPE_SUCCESS Then
WScript.Echo "AD General Respone Check - Event ID: " & lEventID & " " & lEventType
WSCript.Echo strMessage
End If
' oAPI.LogScriptEvent "AD General Response", lEventID, lEventType, strMessage
End Sub
'******************************************************************************
' Name: GetErrorString
'
' Purpose: Attempts to find the description for an error if no description
' is passed in.
'
' Parameters: lErrNumber, the error number
' strErrDescription, the error description (if known)
'
' Return: String, the description for the error. (Includes the error code.)
'
Function GetErrorString(lErrNumber, strErrDescription)
On Error Resume Next
If 0 >= Len(strErrDescription) Then
' If we don't have an error description, then check to see if the error
' is a 0x8007xxxx error. If it is, then look it up.
Const ErrorMask = &HFFFF0000
Const HiWord8007 = &H80070000
Const LoWordMask = 65535 ' This is equivalent to 0x0000FFFF
If (lErrNumber And ErrorMask) = HiWord8007 Then
Dim oShell
Set oShell = CreateObject("WScript.Shell")
If IsObject(oShell) Then
Dim oExec
Set oExec = oShell.Exec("net helpmsg " & (lErrNumber And LoWordMask))
Dim strMessage, i
Do
strMessage = oExec.stdout.ReadLine()
i = i + 1
Loop While (Len(strMessage) = 0) And (i < 5)
strErrDescription = strMessage
End If
End If
End If
GetErrorString = "The error returned was '" & strErrDescription & "' (0x" & Hex(lErrNumber) & ")"
End Function
'******************************************************************************
' Name: HandleScriptFailure
'
' Purpose: Handles a script failure. This checks to see if the number of
' failures has exceeded the threshold and if so generates an
' event. Also updates the daily count.
'
' Parameters: strFailure, the description of the failure.
' lThreshold, the failure threshold.
'
' Return: Nothing
'
Sub HandleScriptFailure(strFailure, lThreshold)
On Error Resume Next