Populating an Alert Description with PropertyBag data

If you are running a script via a rule, and that script returns a propertybag, then it is possible you'll want the data returned to show up in the alert description assuming an alert is generated. The syntax for this in OpsMgr 2007 isn't that straight forward, but with some assistance we figured it out.

Here is what the proper syntax is for the alert description: $Data/Property[@Name='ret']$

Here is an example of the script that returns a PropertyBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
strReturn = "Test"
Call oBag.AddValue("ret",strReturn)
Call oAPI.Return(oBag)
Call oAPI.LogScriptEvent("TestScript.vbs", 9999, 0, strReturn)

Comments (8)

  1. sstranger says:

    Hi Russ,

    I’ve a Time Command Execute a Script Alert Rule created, but how do I use the syntax you described?

    Part of the vbs script:

    ‘If query is empty then there are no errors

    If Not RS1.EOF Then

           strMessage = RS1.Fields("Message")

    ‘wscript.echo strMessage



    ‘Write no records in there are no records

    ‘Wscript.echo "Sorry, no records were found!"

    End If

    Set oAPI = CreateObject("MOM.ScriptAPI")

    Set oBag = oAPI.CreatePropertyBag()

    Call oBag.AddValue("ret",strMessage)

    Call oAPI.Return(oBag)

    Call oAPI.LogScriptEvent("CheckLogging.vbs", 9999, 0, strMessage)


    Thanks for your help.

    Stefan Stranger


  2. sstranger says:


    It seems that you can only use the $Data/Property[@Name=’ret’]$

    in a Monitor and not a Rule.

    Am I correct?


    Stefan Stranger


  3. Russ Slaten says:

    The syntax for a monitor should be:


    The syntax for a rule should be:


  4. isfleming says:

    I’m trying to populate an alert description for a monitor using the $Data/Context/Property[@Name=’something’]$ syntax but the resultant text has {0} {1} {2} etc where my variable data is supposed to be. Any idea what’s wrong? I have verified that the property bag values are set properly in the alert context tab of the alert properties display.


  5. isfleming says:

    No. I don’t have more than 10 parameters in the description. In fact here is the description:

    The process $Data/Context[@Name=’Process’]$ is not running properly. The number of instances is suposed to be $Data/Context[@Name=’Operator’]$ to $Data/Context[@Name=’Count’]$. The actual number of instances was $Data/Context[@Name=’ActualCount’]$.

    Now do you mean more than 10 parameter defined in the property bag via addvalue? Even then I have only 6 key:value pairs.

    Any other ideas?


  6. Over a year ago I blogged about the proper syntax required to populate an alert description with data

Skip to main content