locked
Update Object in SCOM by using SDK RRS feed

  • Question

  • I tried to update properties of a object in Web Application Availability Monitoring in SCOM Server by using SDK, value in database is changed,  but value on Operation Manager Console is not changed.

    Could you give a suggestion  or show me a another way to changing property for it?

    Below code is detail information for changing “test  frequency” property to 4567:

    1.C# Code :

    public void Change()

    {

                    ManagementPack mp = GetManagementPackByName("Microsoft.SystemCenter.WebApplicationSolutions.Library");

                    ManagementPackClass requestClass = mp.GetClass("Microsoft.SystemCenter.WebApplicationSolutions.SingleUrlTest");

                    IObjectReader<EnterpriseManagementObject> reader;

                    var criteria = new EnterpriseManagementObjectCriteria("", requestClass);

                    reader = mg.EntityObjects.GetObjectReader<EnterpriseManagementObject>(criteria, ObjectQueryOptions.Default);

                    foreach (var item in reader)

                    {

                                    EnterpriseManagementObjectProjection projection = new EnterpriseManagementObjectProjection(item);

                                    if (item.DisplayName == "HaiWAT")

                                    {

                                                    //Change property for object

                                                    projection.Object[requestClass, "IntervalInSeconds"].Value = 4567;

                                                    projection.Overwrite();

                                    }

                    }

    }

    2.To verify value changed in database, I use SQL Query

    SELECT TOP 1000 [ManagedEntityPropertyRowId]

          ,[ManagedEntityRowId]

          ,[PropertyXml]

          ,[DeltaXml]

          ,[FromDateTime]

          ,[ToDateTime]

          ,[DWCreatedDateTime]

          ,[DWLastModifiedDateTime]

      FROM [dbo].[ManagedEntityProperty]

      WHERE

      CAST(PropertyXml AS VARCHAR(MAX)) LIKE '%HaiWAT%'

      AND (CAST(PropertyXml AS VARCHAR(MAX)) LIKE '%4567%' )

    From result for this query, click on PropertyXml column to view xml content :

    <Root>

      <Property Guid="AFB4F9E6-BF48-1737-76AD-C9B3EC325B97">microsoft page [MPSDVMOLSCOM.redmond.corp.microsoft.com]</Property>

      <Property Guid="11927069-6957-DFCF-A277-08A784221325">ACDCEDB7-100C-8C91-D664-4629A218BD94</Property>

      <Property Guid="6916F554-56BC-7576-7BBF-041EA88A6A1F">4567</Property>

      <Property Guid="3C8A48D4-97FA-59E9-5E92-7071257875CF">1</Property>

      <Property Guid="70268268-00E8-6426-FC52-75CD0974F42C">HaiWAT</Property>

      <Property Guid="B32B63AE-7D02-0EC7-8852-B066EEDF4AF9">94c42855-be18-e4a6-a4c8-f4be72a4c5d9</Property>

      <Property Guid="720EF4AA-ACB6-29CA-318C-BD9AEBDD07DB">1</Property>

      <Property Guid="59EC4EB8-BB19-CA4C-7E2A-C4E371012203">&lt;TestConfig version="1.0"&gt;&lt;Requests&gt;&lt;Request&gt;&lt;RequestID&gt;1&lt;/RequestID&gt;&lt;URL&gt;http://www.microsoft.com&lt;/URL&gt;&lt;HttpHeaders&gt;&lt;HttpHeader&gt;&lt;Name&gt;Accept&lt;/Name&gt;&lt;Value&gt;*/*&lt;/Value&gt;&lt;/HttpHeader&gt;&lt;HttpHeader&gt;&lt;Name&gt;Accept-Language&lt;/Name&gt;&lt;Value&gt;en-us&lt;/Value&gt;&lt;/HttpHeader&gt;&lt;Htt</Property>

      <Property Guid="28398B92-E7D6-DE9D-D3F2-D0682153E640">&lt;Parameters&gt;&lt;Parameter name="URL"&gt;http://www.microsoft.com&lt;/Parameter&gt;&lt;/Parameters&gt;</Property>

      <Property Guid="88E1C043-2612-71FC-690E-EB47736DE37C">a96e1e1c-8892-4d3b-81a4-a46fa4323d76</Property>

    </Root>

    We can view  on DeltaXml column as well

    <Root>

      <Property Guid="6916F554-56BC-7576-7BBF-041EA88A6A1F">

        <NewValue>4567</NewValue>

        <OldValue>1234</OldValue>

      </Property>

    </Root>

    Thank you,

    Henry


    • Edited by Henry umi Thursday, March 28, 2013 11:35 PM
    Thursday, March 28, 2013 11:35 PM

All replies

  • Hi,

    Can you give some info on what and why you want to do this , and why you want to do this using C# SDK coding.. ? Can't you use basic overrides to change the interval value for the rule/monitor ? Or if you want to force a change on a property for a instance (target) you can also create a custom discovery and let this discovery change the value...

    p.s however did you try to clear your scom console cache already ?

    Michel Kamp

    http://michelkamp.wordpress.com


    ------ Michel Kamp http://michelkamp.wordpress.com

    Sunday, April 28, 2013 7:24 PM