OpsMgr 2007 PropertyBags to type or not to type


As a part time MP developer I’m always struggling to make my rules as optimized as I can. I posted about cookdown and the way to leverage it to make monitoring as light as possible. In this respect the optimum data source runs just once regardless of the number of instances of a class monitored by a specific HealthService. A customer of ours asked me to build a MP to monitor mailbox directories (or drop directories if you prefer). It needs to know if the content is up to date and have a check on the size of each folder, it needs to report on the folder size grow over time. This translates into two monitors (one for age and the other for the size) and a performance collection rule for the folder size. On a specific server I can have several mailbox directories and I wanted to run my script just once regardless of the number of them. Long story short I wrote one script (read Probe) that does it all: it returns the data used by both monitors and the performance data points as well.

I though It was a good idea to differentiate my returned property bags, so I started returning two typed property bags: state and performance. The key to do this is to use the CreateTypedPropertyBag method documented in the OpsMgr SDK. The possible types can be:

Value Definition

0

Alert Data

1

Event Data

2

Performance Data

3

State Data

Returning to my data source I coded something like the following:

Set oBag = g_API.CreateTypedPropertyBag(StateDataType)
call oBag.AddValue("Path", f.Path)    ‘key property we filter on
call oBag.AddValue("Name", f.Name)   
call oBag.AddValue("SizeMB", Round(f.Size/1024/1024,2))
call oBag.AddValue("AgeHR", datediff("h", LastDate, now))
g_API.AddItem oBag

Set oBag = g_API.CreateTypedPropertyBag(PerformanceDataType)
call oBag.AddValue("Name", f.Name)   
call oBag.AddValue("SizeMB", Round(f.Size/1024/1024,2))
g_API.AddItem oBag

Then I coded my monitor and the performance collecting rule, using the appropriate condition detections. Analyzing the MP behavior I noticed that both property bags (state and performance) are processed by each and every condition detection. I should have think of it from the start, anyway I thought this was a suboptimal solution, and though by myself that since I’m using exactly the same data I should have returned just one property bag. I recoded the data source as follows:

Set oBag = g_API.CreateTypedPropertyBag(StateDataType)
call oBag.AddValue("Path", f.Path)    ‘key property we filter on
call oBag.AddValue("Name", f.Name)   
call oBag.AddValue("SizeMB", Round(f.Size/1024/1024,2))
call oBag.AddValue("AgeHR", datediff("h", LastDate, now))
g_API.AddItem oBag

with my surprise the performance collecting rule stopped to work. It took me sometime to get to the culprit, but at that time I didn’t have the latest version of the SDK, in fact it states:

“With the current release of Operations Manager 2007, the only modules that use the conversion type check are the mapping modules that perform conversion to event and performance data.”

Since I’m returning a State Data Type the performance mapper discarded my property bag. Eventually things started to be clear, so I have two choices:

  1. Return two typed property bags, and accept the fact that the condition detections will process each of them. The performance mapper will get instantiated and then just discard the state bag, the monitor condition detections will need to take into account the fact they will get multiple bags for the same monitored instance (i.e. you need to tailor the xpath query accordingly).
  2. Return just one untyped property bag

To return an untyped property bag it is sufficient to change the CreateTypedPropertyBag method call with CreatePropertyBag

Set oBag = g_API.CreatePropertyBag()
call oBag.AddValue("Path", f.Path)    ‘key property we filter on
call oBag.AddValue("Name", f.Name)   
call oBag.AddValue("SizeMB", Round(f.Size/1024/1024,2))
call oBag.AddValue("AgeHR", datediff("h", LastDate, now))
g_API.AddItem oBag

In conclusion, it is really up to you the decision about using typed or untyped property bags, just be aware of the pre-defined filtering on event and performance data mappers.

– Daniele

This posting is provided "AS IS" with no warranties, and confers no rights.

Advertisements
  1. OpsMgr 2007 Base Concepts and Helpful Links « Vinachip
  2. OpsMgr 2007 Base Concepts and Helpful Links « windowsmasher

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: