Microsoft Windows 2003 DFS Client Side Monitoring

Microsoft_Windows_DFS_Client_Side_Monitoring (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{45B1C8B0-E74B-47CE-92F9-916A43E9B3EC}

Member Modules:

ID Module Type TypeId RunAs 
RunScriptAction WriteAction System.Mom.BackwardCompatibility.ScriptResponse Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
UNCPathsstring$Config/Parameters/UNCPaths$UNCPathsA colon separated list of UNC paths (e.g.: \\computer1\share:\\computer2\share)

Source Code:

<WriteActionModuleType ID="Microsoft_Windows_DFS_Client_Side_Monitoring" Accessibility="Internal" Comment="{45B1C8B0-E74B-47CE-92F9-916A43E9B3EC}">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>MomBackwardCompatibility!System.Mom.BackwardCompatibility.AlertGenerationSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AlertGeneration" type="AlertGenerationType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InvokerType" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Parameters" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="UNCPaths" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="UNCPaths" Selector="$Config/Parameters/UNCPaths$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="RunScriptAction" TypeID="MomBackwardCompatibility!System.Mom.BackwardCompatibility.ScriptResponse">
<AlertGeneration>$Config/AlertGeneration$</AlertGeneration>
<InvokerType>$Config/InvokerType$</InvokerType>
<Body><Script>
'-------------------------------------------------------------------
' &lt;company&gt;Microsoft Corporation&lt;/company&gt;
' &lt;copyright&gt;Copyright (c) Microsoft Corporation. All rights reserved.&lt;/copyright&gt;
' &lt;name&gt;
' Microsoft Windows DFS Client Side Monitoring
' &lt;/name&gt;
' &lt;summary&gt;
'
' &lt;/summary&gt;
'-------------------------------------------------------------------

Option Explicit

Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const EVENT_TYPE_AUDITSUCCESS = 8
Const EVENT_TYPE_AUDITFAILURE = 16

Function ThrowScriptErrorNoAbort(ByVal sMessage, ByVal oErr)
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'

Dim sErrDescription, sErrNumber
sErrDescription = oErr.Description
sErrNumber = oErr.Number

On Error Resume Next

Dim oScriptErrorEvent

Set oScriptErrorEvent = ScriptContext.CreateEvent()
With oScriptErrorEvent
.EventNumber = 40000
.EventType = EVENT_TYPE_ERROR
.Message = sMessage
.SetEventParameter """Microsoft Windows Distributed File Systems"""
.SetEventParameter sMessage
.SetEventParameter sErrDescription
.SetEventParameter sErrNumber
End With
ScriptContext.Submit oScriptErrorEvent
ScriptContext.Echo "ThrowScriptError('" &amp; sMessage &amp; "')"
End Function

Function ThrowScriptError(Byval sMessage, ByVal oErr)
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'
On Error Resume Next
ThrowScriptErrorNoAbort sMessage, oErr
ScriptContext.Quit()
End Function


Function MomCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error

On Error Resume Next
Set MomCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0

If oError.Number &lt;&gt; 0 Then ThrowScriptError "Unable to create automation object '" &amp; sProgramId &amp; "'", oError
End Function

Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile
Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub
Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = m_lNumber
End Property
Public Property Get Source()
Source = m_sSource
End Property
Public Property Get Description()
Description = m_sDescription
End Property
Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class

''******************************************************************************
' Name: CreateAlert
'
' Purpose: Creates, but does not submit, an alert
'
' Parameters:
' iSeverity - The severity of the alert.
' sName - The name of the alert.
' sDescription - The alert description.
' sRole - The server role
' sInstance - The server role instance for which to issue a state alert.
' sComponent - The component affected
' iProblemState - The problem state
'
Function CreateAlert(ByVal iSeverity, ByVal sName, ByVal sDescription, ByVal sRole, ByVal sInstance, ByVal sComponent, ByVal iProblemState)
Dim oAlert

Set oAlert = ScriptContext.CreateAlert()

oAlert.Name = sName
oAlert.Description = sDescription
oAlert.AlertSource = "Microsoft Windows DFS Client Side Monitoring"
oAlert.AlertLevel = iSeverity

'If there is a role, instance and component specified then this is a state alert
If sRole &lt;&gt; "" And sInstance &lt;&gt; "" And sComponent &lt;&gt; "" Then
oAlert.ProblemState = iProblemState
oAlert.ServerRole = sRole
oAlert.ServerRoleInstance = sInstance
oAlert.Component = sComponent
oAlert.ComponentInstance = ""
End If

Set CreateAlert = oAlert
End Function

''******************************************************************************
' Name: Submit Alert
'
' Purpose: Raises an alert
'
' Parameters:
' iSeverity - The severity of the alert.
' sName - The name of the alert.
' sDescription - The alert description.
' sRole - The server role
' sInstance - The server role instance for which to issue a state alert.
' sComponent - The component affected
' iProblemState - The problem state
'
Sub SubmitAlert(ByVal iSeverity, ByVal sName, ByVal sDescription, ByVal sRole, ByVal sInstance, ByVal sComponent, ByVal iProblemState)
ScriptContext.Submit CreateAlert(iSeverity, sName, sDescription, sRole, sInstance, sComponent, iProblemState)
End Sub

Const ALERT_SUCCESS = 10
Const ALERT_INFORMATION = 20
Const ALERT_WARNING = 30
Const ALERT_ERROR = 40
Const ALERT_CRITICAL_ERROR = 50
Const ALERT_SECURITY_BREACH = 60
Const ALERT_SERVICE_UNAVAILABLE = 70

Sub Main()
Dim aRootNames
aRootNames = Split(CStr(ScriptContext.Parameters.Get("UNCPaths")), ":")

Dim oFSO
Set oFSO = MomCreateObject("Scripting.FileSystemObject")

Dim e
Set e = New Error

Dim sAlertDescription
Dim sTargetPath
Dim oFolder
Dim oFile
For Each sTargetPath In aRootNames
On Error Resume Next
Set oFolder = oFSO.GetFolder(sTargetPath)
e.Save
On Error Goto 0

If e.Number = 0 Then
On Error Resume Next
For Each oFile In oFolder.Files
Exit For
Next
e.Save
On Error Goto 0
End If

If e.Number = 0 Then
ScriptContext.Echo "Passed"
Else
SubmitAlert ALERT_CRITICAL_ERROR, _
"A DFS destination is unreachable [" &amp; sTargetPath &amp; "]", _
"The DFS client side monitoring routine detected that the following destination is unreachable:" &amp; vbCrLf &amp; vbCrLf &amp; _
sTargetPath &amp; vbCrLf &amp; vbCrLf &amp; _
"The error code is: " &amp; e.Description, _
"", "", "", ""
End If
Next
End Sub</Script></Body>
<Language>VBScript</Language>
<Name>Microsoft Windows DFS Client Side Monitoring</Name>
<Parameters>
<Parameter>
<Name>UNCPaths</Name>
<Value>$Config/Parameters/UNCPaths$</Value>
</Parameter>
</Parameters>
<ManagementPackId>[Microsoft.Windows.Server.DFS,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>