locked
SCOM 2012 SDK GetMonitoringPerformanceData not returning data RRS feed

  • Question

  • Hi

    We are attempting to use the SCOM SDK to provide a web interface to data.  We are fine pulling out monitoring objects, however when using the method GetMonitoringPerformanceData on an instance we don't get any data for certain management class searches.  

    To keep things simple we have used the code in the following link:

    http://msdn.microsoft.com/en-us/library/hh329063.aspx

    We have only changed the server name in the ManagementGroup creation and the ManagementPackClassCriteria has been changed to either of the following:

    1. Microsoft.Windows.Server.Computer (returns no performance data)
    2. System.NetworkManagement.Node (returns performance data)

    So:

    using System;
    using System.Collections.ObjectModel;
    using System.Collections.Generic;
    using System.Linq;
    using Microsoft.EnterpriseManagement;
    using Microsoft.EnterpriseManagement.Common;
    using Microsoft.EnterpriseManagement.Configuration;
    using Microsoft.EnterpriseManagement.Monitoring;
    
    namespace SDKSamples
    {
        internal class Program
        {
            private static void Main(string[] args)
            {
                ManagementGroup mg = new ManagementGroup("localhost");
    
                // The criteria specifies that you want to collect
                // computers running Windows Server 2003.
                ManagementPackClassCriteria classCriteria =
                    new ManagementPackClassCriteria("Name = 'Microsoft.Windows.Server.Computer'");
    
                //or:
                //ManagementPackClassCriteria classCriteria =
                //    new ManagementPackClassCriteria("Name = 'System.NetworkManagement.Node'");
    
                Console.WriteLine("Querying for data...");
                // There should only be one item in the monitoringClasses collection.
                IList<ManagementPackClass> monitoringClasses =
                    mg.EntityTypes.GetClasses(classCriteria);
    
                // Get all instances of computers running Windows Server 2003 in the management group.
                List<MonitoringObject> targets = new List<MonitoringObject>();
                IObjectReader<MonitoringObject> reader =
                    mg.EntityObjects.GetObjectReader<MonitoringObject>(monitoringClasses[0], ObjectQueryOptions.Default);
                targets.AddRange(reader);
    
    
    
                if (targets.Count > 0)
                {
                    //We have filtered this to be an object that displays performance data in Console
                    Console.WriteLine("Monitoring Object name: " + targets[0].DisplayName +
                                      Environment.NewLine);
    
                    DisplayPerformanceData(targets[0]);
                }
    
            }
    
            //-----------------------------------------------------------------------------------
            private static void DisplayPerformanceData(MonitoringObject mObject)
            {
                Console.WriteLine();
                Console.WriteLine("Performance data information: ");
                foreach (MonitoringPerformanceData perfData in mObject.GetMonitoringPerformanceData())
                {
                    Console.WriteLine("Performance counter name: " + perfData.CounterName);
                    Console.WriteLine("Last sampled value: " + perfData.LastSampledValue);
                }
            }
        }
    }

    Like mentioned above "System.NetworkManagement.Node" returns data, however "Microsoft.Windows.Server.Computer" doesn't.

    We have tried multiple ways to get at this data (adding criteria, different methods, 2007 SDK methods).

    Is there something obvious we are missing?  The dll's we have for Microsoft.EnterpriseManagement.* are version 7.0.5000.0.

    The account I run the console app against has access to the data via the console.

    Cheers in advance!

    Edit1:

    Using the following code to GetMonitoringAlerts also doesn't return data monitoring object classes for the class "Microsoft.Windows.Server.Computer".


    Monday, November 11, 2013 1:33 AM

Answers

  • Hi,

    you have to add the TraversalDepth:
    GetMonitoringPerformanceData(Microsoft.EnterpriseManagement.Common.TraversalDepth.Recursive)

    Most performance data isn't collected directly for the Windows Computer class but for the Operating System.
    By getting data Recursive you'll get the Performance Data of all underlying class instances that belong to this computer.

    Also - if you plan on getting Performance Data itself I recommend doing so through the datawarehouse, not through the SDK.
    You can find sample queries here: http://technet.microsoft.com/en-us/library/gg508714.aspx

    Friday, November 15, 2013 1:34 PM

All replies

  • Hi,

    you have to add the TraversalDepth:
    GetMonitoringPerformanceData(Microsoft.EnterpriseManagement.Common.TraversalDepth.Recursive)

    Most performance data isn't collected directly for the Windows Computer class but for the Operating System.
    By getting data Recursive you'll get the Performance Data of all underlying class instances that belong to this computer.

    Also - if you plan on getting Performance Data itself I recommend doing so through the datawarehouse, not through the SDK.
    You can find sample queries here: http://technet.microsoft.com/en-us/library/gg508714.aspx

    Friday, November 15, 2013 1:34 PM
  • Thanks a lot for helping me.  Will go through the samples and got down the DW path. 

    Cheers!

    Friday, November 15, 2013 9:34 PM