AD General Response (Attività diagnostica)

Microsoft.Server.AD.2008.GeneralResponseCheck (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
Script ProbeAction System.Secure.CommandExecuterProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout in secondi
FailureThresholdint$Config/FailureThreshold$Soglia binding DC in secondi. Se viene superata la soglia, il controllo avrà esito negativo.

Source Code:

<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"/>
<xsd:element name="FailureThreshold" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="FailureThreshold" Selector="$Config/FailureThreshold$" 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$ $Config/FailureThreshold$</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
'*************************************************************************

Option Explicit

SetLocale ("en-us")

'Event Constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

'Other constants
Const SCRIPT_NAME = "AD General Response"

Const EVENTID_INVALID_PARAMETER = 66
Const EVENT_ID_AGENTLESS = 98
Const EVENTID_SCRIPT_FAILURE = 1000
Const EVENT_ID_AD_GENERAL_RESPONSE_OK = 1091
Const EVENT_ID_AD_GENERAL_RESPONSE_NOTOK = 18909

Dim oAPI, oParams, TargetFQDNComputer, IsTargetAgentless, lFailureThreshold
Set oParams = WScript.Arguments
if oParams.Count &lt; 2 then
Wscript.Quit -1
End if

TargetFQDNComputer = oParams(0)
lFailureThreshold = oParams(1)
Set oAPI = CreateObject("Mom.ScriptAPI")

Err.Clear

Sub Main()

Dim objAD, objParams, objADsObject
Dim lLastBind, strComputer, bBindSuccessful

On Error Resume Next

Set objParams = Nothing

strComputer = TargetFQDNComputer
strComputer = LCase(strComputer)

Set objAD = CreateObject("McActiveDir.ActiveDirectory")
If (0 &lt;&gt; Err.Number) Or (Not(IsObject(objAD))) Then
Dim errorString

errorString = "The script '" &amp; SCRIPT_NAME &amp; "' failed to create object " &amp; _
"'McActiveDir.ActiveDirectory'. This is an unexpected error." &amp; vbCrLf &amp; vbCrLf &amp; _
GetErrorString(Err.Number, Err.Description) &amp; vbCrLf &amp; vbCrLf &amp; _
"The Active Directory Management Pack Objects (OOMADs) components are not installed on the Domain Controller. These components are required for the monitoring scripts to run successfully. See Alert Knowledge for additional details."
HandleScriptFailure errorString
Else
objAD.Server = strComputer

Set objADsObject = objAD.BindObject("LDAP://rootDSE")

If (Err.Number &lt;&gt; 0) Or (Not(IsObject(objADsObject))) Then
Set oBag = oAPI.CreateTypedPropertyBag(StateDataType)

HandleScriptFailure "Failed to bind to 'LDAP://rootDSE'. This is an unexpected error." &amp; vbCrLf &amp; vbCrLf &amp; _
GetErrorString(Err.Number, Err.Description)
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: " &amp; (lLastBind / 1000) &amp; " sec"
If ((lLastBind / 1000) &gt; CLng(lFailureThreshold)) then
HandleScriptFailure "The current DC bind time was " &amp; (lLastBind / 1000) &amp; _
" second(s) which is outside of the defined threshold of " &amp; lFailureThreshold &amp; _
" second(s). Please check the domain controller as this may indicate a performance problem."
End If
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)
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 &gt;= 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 = &amp;HFFFF0000
Const HiWord8007 = &amp;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 " &amp; (lErrNumber And LoWordMask))

Dim strMessage, i
Do
strMessage = oExec.stdout.ReadLine()
i = i + 1
Loop While (Len(strMessage) = 0) And (i &lt; 5)

strErrDescription = strMessage
End If
End If
End If

GetErrorString = "The error returned was '" &amp; strErrDescription &amp; "' (0x" &amp; Hex(lErrNumber) &amp; ")"
End Function

'******************************************************************************
' Name: HandleScriptFailure
'
' Purpose: Handles a script failure.
'
' Parameters: strFailure, the description of the failure.
'
' Return: Nothing
'
Sub HandleScriptFailure (strFailure)
CreateEvent EVENTID_SCRIPT_FAILURE, EVENT_TYPE_WARNING, strFailure
WScript.Echo "Error: " &amp; strFailure
End Sub

Call Main()

</Script></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>