none
How to pass Property Bag values to a monitor's recovery script ?

    Question

  • Hello all,

    we are using a Two State script monitor.

    The monitoring script finds the error and stores some items in the PropertyBag:


    ' Enter a script that outputs a property bag
    ' Example VBScript:
    '
     Dim oAPI, oBag
     Set oAPI = CreateObject("MOM.ScriptAPI")
     Set oBag = oAPI.CreatePropertyBag()

     Call oBag.AddValue("Details","These are the details")

     Call oBag.AddValue("Status","ERROR")

     Call oAPI.Return(oBag)


    We then have a recovery script which runs automatically:

    '
    '
    Option Explicit

    Dim oAPI
    Dim strArg0
    Dim objArgs

    Wscript.Echo "Recovery started"
    Set objArgs=WScript.Arguments

    Set oAPI = CreateObject("MOM.ScriptAPI")

    Call oAPI.LogScriptEvent ("_Test_Accessing_PropertyBag_Recovery",198,0,"Starting Recovery")

    strArg0 = "objArgs(0) >>" & objArgs(0) & "<<"


    Call oAPI.LogScriptEvent ("_Test_Accessing_PropertyBag_Recovery",200,0,strArg0)


    I want to pass an item of the PropertyBag as a parameter to the recovery script.

    What is the correct XML notation here ?

    I found that $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$ is accepted as parameter and works.
    Unfortunately $Data/Context/DataItem/Property[@Name='Details']$ does not work. This parameter even prevents the recovery procedure from starting !

    If somebody knows how to make reference to the PropertyBag from inside the recovery script or to give the correct syntax for the parameter, please let me know.

    Thanks for your time

    number33

    Please not that I'm using only the integrated Authoring Console within SCOM 2007 R2

    Friday, January 07, 2011 4:06 PM

Answers

  • Hi,

    Try $Data/StateChange/DataItem/Context/DataItem/<relative path>

    $Data/StateChange/DataItem/Context/DataItem/Property[@Name='Details']$

    or

    $Data/StateChange/DataItem/Context/DataItem/Details$


    http://OpsMgr.ru/
    Saturday, January 29, 2011 3:28 PM
    Moderator
  • Alexey gave the syntax, and I don't think we documented that with the other $Data variable examples in the MP Authoring Guide.  I'll have a look at that and get that syntax documented in there if it's missing.

    You can get an example of passing these values to Diagnostics and Recoveries in the sample MP called MPAuthor.DiagnosticAndRecovery in the OpsManJam Management Pack Library.  There are both VBScript and PowerShell examples in there that be pretty similar to what it sounds like you're tryihng to do.


    This posting is provided "AS IS" with no warranties, and confers no rights. Use of attachments are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
    Monday, January 31, 2011 1:54 AM
    Moderator
  • Hi Alexey, Brian and Dan,

    thanks to you all. Unfortunately priorities had changed rapidly so I could not continue following this issue.

    I think I will try Alexey's proposal.

    Furthermore I found a hint in the "Management Pack Authoring Guide, April 16, 2010", Page 161. They gave a headline "To create a recocvery based on the output of a diagnostic" .

    Thanks again.

    sebastian

    Tuesday, March 29, 2011 8:49 AM

All replies

  • There isn't a way to do this in the console.  Offhand, I think you need to move your diagnostic logic into your recovery script and not have the monitor feed it.

    At issue is what data passes from the monitor to the recovery.  The only way to figure out if your property bag is in the context that is provided in the workflow is to use the workflow analyzer tool linked to a live agent that is running the monitor workflow.  This tool lets you see all of the data that passes between each stage of the workflow - so if there is ANY useful data in the flow at this time, you could determine if what you want to do is even possible in this way.

    Since what typically passes from one stage to another is only the output of the prior stage, and your monitor's output is a state change event, I suspect you will only have the state information.

    This is a great scenario that requires advanced, direct in XML authoring plus a deep knowledge of debuggers at the code level, and cannot be done from the console.


    Microsoft Corporation
    Friday, January 07, 2011 4:50 PM
  • Hi Dan,

    thanks for your answer. I tried the WorkflowAnalyzer from the R2 Resource Kit.

    Unfortunately the invocation of the recovery task ( here my scirpt ) is not logged.

    This is true for both cases: When there are valid parameters for the recovery script ( then we have the Wscript.Echo-Output in the monitor's State Change Events ) and when the parameters are somehow invalid ( then we have no output in the monitor's State Change Event )

     Is there a way to have WFAnalyzer.Exe trace the recovery-part as well ?

    Thanks

    number33

    Monday, January 10, 2011 9:53 AM
  • Hi,

    Try $Data/StateChange/DataItem/Context/DataItem/<relative path>

    $Data/StateChange/DataItem/Context/DataItem/Property[@Name='Details']$

    or

    $Data/StateChange/DataItem/Context/DataItem/Details$


    http://OpsMgr.ru/
    Saturday, January 29, 2011 3:28 PM
    Moderator
  • Alexey gave the syntax, and I don't think we documented that with the other $Data variable examples in the MP Authoring Guide.  I'll have a look at that and get that syntax documented in there if it's missing.

    You can get an example of passing these values to Diagnostics and Recoveries in the sample MP called MPAuthor.DiagnosticAndRecovery in the OpsManJam Management Pack Library.  There are both VBScript and PowerShell examples in there that be pretty similar to what it sounds like you're tryihng to do.


    This posting is provided "AS IS" with no warranties, and confers no rights. Use of attachments are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
    Monday, January 31, 2011 1:54 AM
    Moderator
  • Hi Alexey, Brian and Dan,

    thanks to you all. Unfortunately priorities had changed rapidly so I could not continue following this issue.

    I think I will try Alexey's proposal.

    Furthermore I found a hint in the "Management Pack Authoring Guide, April 16, 2010", Page 161. They gave a headline "To create a recocvery based on the output of a diagnostic" .

    Thanks again.

    sebastian

    Tuesday, March 29, 2011 8:49 AM