This document is part of the Operations Manager Management Pack Authoring Guide .
The following procedure shows how to create a monitor based on a custom data source module running a script in the Operations Manager 2007 Authoring console and Visual Studio Authoring Extensions.
This exercise applies to the following products:
Before you perform this procedure, you must first complete the following prerequisite procedures:
The Microsoft System Center team has validated this procedure as of the original revision. We will continue to review any changes and periodically provide validations on later revisions as they are made. Please feel free to make any corrections or additions to this procedure that you think would assist other users
A sample of the completed code for each exercise is available in the TechNet Gallery. There is a separate sample for each exercise that includes the management pack completed at the end of that exercise and each preceding exercise. This strategy allows you to work through each exercise in order and then compare your results. For VSAE, this also includes the Visual Studio solution.
The monitor created in this procedure has the following characteristics:
<![CDATA[ sComputerName = WScript.Arguments(0) bTestSuccessful = True Set oAPI = CreateObject("MOM.ScriptAPI") oAPI.LogScriptEvent "MyTransactionScript.vbs",10,4, "Running script on " & sComputerName Set oBag = oAPI.CreatePropertyBag() Call oBag.AddValue("ComputerName",sComputerName) If bTestSuccessful = True Then Call oBag.AddValue("Result","Good") Else Call oBag.AddValue("Result","Bad") End If oAPI.Return(oBag) ]]>
<![CDATA[
sComputerName = WScript.Arguments(0)
bTestSuccessful =
True
Set
oAPI = CreateObject(
"MOM.ScriptAPI"
)
oAPI.LogScriptEvent
"MyTransactionScript.vbs"
,10,4,
"Running script on "
& sComputerName
oBag = oAPI.CreatePropertyBag()
Call
oBag.AddValue(
"ComputerName"
,sComputerName)
If
Then
"Result"
,
"Good"
Else
"Bad"
End
oAPI.
Return
(oBag)
]]>
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<
IntervalSeconds
>$Config/IntervalSeconds$</
>
add the following line:
<SyncTime>$Config/SyncTime$</SyncTime>
SyncTime
>$Config/SyncTime$</
The Probe Action module contains the script itself and can be called from tasks and other modules. In the monitor, it is used for On Demand Detection which runs when the user selects Recalculate Health.
<TypeDefinitions> <ModuleTypes> <ProbeActionModuleType ID="MyMP.ProbeActionModule.MyTransactionScript" Accessibility="Internal" Batching="false" PassThrough="false"> <Configuration> <xsd:element minOccurs="1" name="ComputerName" type="xsd:string" /> </Configuration> <ModuleImplementation Isolation="Any"> <Composite> <MemberModules> <ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptProbeAction"> <ScriptName>MyTransactionScript.vbs</ScriptName> <Arguments>$Config/ComputerName$</Arguments> <ScriptBody>$IncludeFileContent/Composition/MyTransactionScript.vbs$</ScriptBody> <TimeoutSeconds>300</TimeoutSeconds> </ProbeAction> </MemberModules> <Composition> <Node ID="Script" /> </Composition> </Composite> </ModuleImplementation> <OutputType>System!System.PropertyBagData</OutputType> <InputType>System!System.BaseData</InputType> </ProbeActionModuleType> </ModuleTypes> </TypeDefinitions>
TypeDefinitions
ModuleTypes
ProbeActionModuleType
ID
=
"MyMP.ProbeActionModule.MyTransactionScript"
Accessibility
"Internal"
Batching
"false"
PassThrough
Configuration
xsd:element
minOccurs
"1"
name
type
"xsd:string"
/>
</
ModuleImplementation
Isolation
"Any"
Composite
MemberModules
ProbeAction
"Script"
TypeID
"Windows!Microsoft.Windows.ScriptProbeAction"
ScriptName
>MyTransactionScript.vbs</
Arguments
>$Config/ComputerName$</
ScriptBody
>$IncludeFileContent/Composition/MyTransactionScript.vbs$</
TimeoutSeconds
>300</
Composition
Node
OutputType
>System!System.PropertyBagData</
InputType
>System!System.BaseData</
The Data Source module calls the probe action module on a schedule. This is used for Regular Detection where the monitor is constantly running on the agent.
DataSourceModuleType
"MyMP.DataSourceModule.MyTransactionScriptTimed"
"IntervalSeconds"
"xsd:integer"
"0"
"SyncTime"
OverrideableParameters
OverrideableParameter
Selector
"$Config/IntervalSeconds$"
ParameterType
"int"
"$Config/SyncTime$"
"string"
DataSource
"Schedule"
"System!System.SimpleScheduler"
"Probe"
ComputerName
The monitor type calls the data source module and defines the logic for determining different health states.
UnitMonitorType
"MyMP.MyTransactionMonitorType"
MonitorTypeStates
MonitorTypeState
"Success"
NoDetection
"Failure"
<MonitorImplementation>
MonitorImplementation
"DataSource"
"PassThru"
"System!System.PassThroughProbe"
ConditionDetection
"FilterSuccess"
"System!System.ExpressionFilter"
Expression
SimpleExpression
ValueExpression
XPathQuery
Type
"String"
>Property[@Name='Result']</
Operator
>Equal</
Value
>Good</
"FilterFailure"
>Bad</
RegularDetections
RegularDetection
MonitorTypeStateID
OnDemandDetections
OnDemandDetection
>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</
>900</