MOMScriptAPI.CreateTypedPropertyBag Method
It came to my attention that CreateTypedPropertyBag method of MOMScriptAPI is not documented in MSDN (or at least not published at the time I’m writing this post). I will try to offer a bit of insight for this API as well as provide a sample for its usage.
This method creates a new property bag object, which is used to “temporarily” store operations data (such as discovery, event, performance data, or any other data) as a collection of name-value pairs. This property bag data then may serve as input to subsequent mapping module which is converting property bag into “more” specific operations data type. Such converted data type is likely to be used within a workflow later (to collect in operational DB etc).
MOMScriptAPI.CreateTypedPropertyBag(type)
Parameters
Parameter |
Type |
Description |
type |
Long |
The type of allowed conversion/mapping. |
Return Value
Type |
Description |
Object |
A new instance of the MOMPropertyBag object. |
Remarks
A script uses a property bag to store output data that will be used by subsequent modules. When CreatePropertyBag API is used, output data can be handled by any subsequent module that allows property bag as its input. With discussed API, only possible uses of property bags are:
· Map data to an alert and store in the database.
· Map data to an event and store in the database.
· Map data to a performance point and store in the database.
· Use data to evaluate state as part of a monitor.
It is also imperative that with this API, there is just one conversion use at one time only. Use is specifically driven by API input argument - type. This is ultimately what community already tried to resolve on its own (rather successfully I must say). So to summarize in this post as well, possible conversions based on type used are:
· oBag = CreateTypedPropertyBag(0)
property bag can be converted only to alert, it is not convert-able to anything else and would be ultimately dropped with such conversion request
· oBag = CreateTypedPropertyBag(1)
property bag can be converted only to event, it is not convert-able to anything else and would be ultimately dropped with such conversion request
· oBag = CreateTypedPropertyBag(2)
property bag can be converted only to perf data, it is not convert-able to anything else and would be ultimately dropped with such conversion request
· oBag = CreateTypedPropertyBag(3)
property bag can be converted only to state data, it is not convert-able to anything else and would be ultimately dropped with such conversion request
With current release of OpsMgr2007, only mapping modules performing conversion to event and perf data make use of this conversion type check (there is not really a mapping module to alert and state data type implemented and/or needed yet), but in the future I would expect all mapping modules expecting property bag as its input and producing particular operations data to follow this paradigm.
Perf conversion example
This example shows possible creation of a property bag typed for performance data conversion and adds a name-value pair for performance counter name, performance counter instance name and performance counter value. Those pairs of such property bag then need to be properly “mapped” in configuration of module creating performance data type to allow for correct conversion.
NOTE: This example also uses API functions that I may post later (AddItem, ReturnItems)
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")
...
Set objAD = CreateObject("McActiveDir.ActiveDirectory")
objAD.Server = strComputer
If objAD.GetDatabaseInfo(strPathDB, lSizeDB, lFreeSpaceDB) Then
strPathDB = LCase(strPathDB)
Set oBag = oAPI.CreateTypedPropertyBag(PerformanceDataType)
oBag.AddValue "StatusCounter" , "Database Drive Free Space"
oBag.AddValue "StatusInstance" , strPathDB
oBag.AddValue "StatusValue", "" & lFreeSpaceDB
oAPI.AddItem oBag
Set oBag = oAPI.CreateTypedPropertyBag(PerformanceDataType)
oBag.AddValue "StatusCounter" , "Database Size"
oBag.AddValue "StatusInstance" , strPathDB
oBag.AddValue "StatusValue", "" & lSizeDB
oAPI.AddItem oBag
End If
...
Call oAPI.ReturnItems
<ConditionDetection ID="PerfMapper" TypeID="SystemPerf!System.Performance.DataGenericMapper">
<ObjectName>AD Storage</ObjectName>
<CounterName>$Data/Property[@Name='StatusCounter']$</CounterName>
<InstanceName>$Data/Property[@Name='StatusInstance']$</InstanceName>
<Value>$Data/Property[@Name='StatusValue']$</Value>
</ConditionDetection>
Comments
Anonymous
January 25, 2008
PingBack from http://www.systemcenterforum.org/opsmgr-scripting-createtypedpropertybag-explained/Anonymous
January 30, 2008
Hi, I just want to inform you about one troublesome thing. I found out what OpsMgr have problems with moving performance data to DW if this data was collected by ONE rule with more then ONE counter. Here is MS answer: DW does not support multiple object/counter pairs collected by one rule (multiple instances is Ok). You’d need to create as many rules as the number of object/counter pairs you wish to collect. So, your example is ok, but only for UI performance view.Anonymous
February 01, 2008
Thanks Denis! Sorry for my negligence, I just grabbed first sample I could think of. I also wanted to show that script is able to created batched property bag (I will comment on that in my future post) ...Anonymous
February 02, 2008
With my last post , I started to look at undocumented methods of MOMScriptAPI . These methods are publishedAnonymous
February 02, 2008
With my last post , I started to look at undocumented methods of MOMScriptAPI . These methods are publishedAnonymous
August 03, 2008
This is useful.. I am looking to pass a database name to a custom Tsql script within VBS, and I understand this is possible with CreatePropertyBag: "When CreatePropertyBag API is used, output data can be handled by any subsequent module that allows property bag as its input" Does Tsql allow property bag as its input?Anonymous
August 03, 2008
It all depends on the module you will use. I guess it will be command executer in your case, so yes, you will be able to do $Data replacement as far as I remember (not an owner of said module, but I'm fairly certain most of the MS modules are capable of $Data replacements)Anonymous
August 29, 2008
momscriptapi-createtypedpropertybag