none
OpsMgr custom monitor data properties

    Question

  •  

    Hello,

     

    I'm trying to return custom data properties from a script to a monitor, like this:

        Call objBag.AddValue(CStr(Name), CStr(Value))
        Call objAPI.Return(objBag)

     

     

    And I see my custom properties correctly in the Alert Context tab.  But I can't get those to show in the Alert Description.  As a test, I've tried adding one of these properties to the Alert Description in different formats, like this:

    SearchFolder: $Data/Context/SearchFolder$

    SearchFolder: $Data/Context/Property[@Name='SearchFolder']$

    SearchFolder: $Data/Context/DataItem/SearchFolder$

    SearchFolder: $Data/Context/DataItem/Property[@Name='SearchFolder']$

     

    But in the alert it looks like this:

                   SearchFolder: {0}

                   SearchFolder: {1}

                   SearchFolder: {2}

                   SearchFolder: {3}


     

    I've tried most of Kevin Holman's examples:

    http://blogs.technet.com/b/kevinholman/archive/2007/12/12/adding-custom-information-to-alert-descriptions-and-notifications.aspx

     

     

    So to summarize, how do I get the custom data from the Alert Context tab into the Alert Description, so I can reference it in the body of an email subscription? Thanks.

     

    Thursday, December 16, 2010 4:36 PM

Answers

  • We're definitely talking about 2007 here.  The Authoring console is part of the MP Authoring Resource Kit, but it doesn't sound like you need that here.  You only need that console if you can't get done what you want in the Operations console.

    It sounds like you may be mixing up $Target variables and $Data variables.  Is this SearchFolder a property on a discovered object?  If so, then this is not accessible from $Data.  The $Data variables, which are accessible in the alert description access values in the data.  In this case, that means the property bag coming from your script. 

    I'm not sure where you got the syntax $Data/Contact/[PropertyName]$ because when I walk through the steps you list, I get $Data/Context/Property/[@Name='<<STRING>>']$.  That is the correct syntax for retrieving a property from a property bag.  You would replace <<STRING>> with the name of the value such as $Data/Context/Property/[@Name='SearchFolder']$.  I'm using SCOM 2007 R2 CU3, so maybe the option is a bit different in previous versions.

    If you're trying to access a property on an object though, you would use a $Target variable, and you can't include that in an alert description.  In order to do that you would add the $Target variable as an argument into your script.  The script would then include that value in a property of the property bag.  The value would then be accessible from a $Data variable.

    Hopefully, I have your issue correct, and that all makes sense.  I may have made it sound more complex than it really is, because this one really isn't that tough (assuming I'm understanding you correctly).  You can find a variety of sample management packs in our management pack library on OpsManJam for different examples of using property bags.  You can also get documentation on scripts and property bags in the section on monitoring scripts in the Authoring Guide


    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
    Saturday, December 18, 2010 12:08 AM
    Moderator

All replies

  • We have the syntax for variables in alerts from monitors in the MP Authoring Guide.  The one you want is $Data/Context/Property[@Name='<PropertyName>']$ which is on your list above.  Everything in Kevin's list should be correct as well.

    Are you using the Operations Console or Authoring Console to build your monitor?  You should be able to add the variable using menu options.


    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
    Friday, December 17, 2010 6:47 AM
    Moderator
  • Hi Brian,

    Thank you for the reply.  When you mention Operations Console or Authoring Console, that sounds like you are talking about MOM 2005.  Did I post this in the wrong forum?

    I created this as a unit monitor under Authoring, under Management Pack Objects, Monitors, Scripting, Generic, Timed Script Two State Monitor.  When I edit the monitor properties and go the Alerting tab, under Alert Description ...  I choose Data -> Property and it enters "$Data/Context/[PropertyName]$" which I replace with "$Data/Context/SearchFolder$" and "$Data/Context/[SearchFolder]$" as well as several others.  I can see the SearchFolder property and value changing on the Alert Context tab of the alert, so I think the script is sending it back properly.

    Friday, December 17, 2010 6:05 PM
  • We're definitely talking about 2007 here.  The Authoring console is part of the MP Authoring Resource Kit, but it doesn't sound like you need that here.  You only need that console if you can't get done what you want in the Operations console.

    It sounds like you may be mixing up $Target variables and $Data variables.  Is this SearchFolder a property on a discovered object?  If so, then this is not accessible from $Data.  The $Data variables, which are accessible in the alert description access values in the data.  In this case, that means the property bag coming from your script. 

    I'm not sure where you got the syntax $Data/Contact/[PropertyName]$ because when I walk through the steps you list, I get $Data/Context/Property/[@Name='<<STRING>>']$.  That is the correct syntax for retrieving a property from a property bag.  You would replace <<STRING>> with the name of the value such as $Data/Context/Property/[@Name='SearchFolder']$.  I'm using SCOM 2007 R2 CU3, so maybe the option is a bit different in previous versions.

    If you're trying to access a property on an object though, you would use a $Target variable, and you can't include that in an alert description.  In order to do that you would add the $Target variable as an argument into your script.  The script would then include that value in a property of the property bag.  The value would then be accessible from a $Data variable.

    Hopefully, I have your issue correct, and that all makes sense.  I may have made it sound more complex than it really is, because this one really isn't that tough (assuming I'm understanding you correctly).  You can find a variety of sample management packs in our management pack library on OpsManJam for different examples of using property bags.  You can also get documentation on scripts and property bags in the section on monitoring scripts in the Authoring Guide


    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
    Saturday, December 18, 2010 12:08 AM
    Moderator