gulden PT
gulden PT

Reputation: 411

Get Garbage Collector metrics using WMI

  1. I need to collect metrics about the Percent Time in GarbageCollector using WMI Classes for Windows servers. I'm using the Class: "Win32_PerfRawData_NETFramework_NETCLRMemory". Is this correct?

  2. Then I take two samples for that class and i made the following calculation:

        # PSEUDO CODE
        PercentTime in GC = 
        (
          (sample2->'PercentTimeinGC' - sample1->'PercentTimeinGC') / 
          (sample2->'TimeStamp_Sys100NS' - sample1->'TimeStamp_Sys100NS')
        )
    

This calculation is definitively wrong, how to do it in the right way?

Tks in advance.

gulden

Upvotes: 1

Views: 455

Answers (1)

gulden PT
gulden PT

Reputation: 411

After some digging in the unknown world of windows I've found the solution:

I've started with this link that explains the calculation methods for each kind of metric:

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

However, we need to know the countertype, in this case the countertype for "PercentTimeinGC". To know that i need to run the WEBMTest.exe program:

http://technet.microsoft.com/en-us/library/cc180684.aspx

  1. Connect to "root\CIMV2"
  2. Open Class... "Win32_PerfRawData_NETFramework_NETCLRMemory"
  3. Select the property "PercentTimeinGC"
  4. Click in the button "Show MOF"
  5. Find the line:

    "[DisplayName("% Time in GC"): ToInstance, countertype(537003008): ToInstance, perfindex(2606): ToInstance, helpindex(2607): ToInstance, defaultscale(0): ToInstance, perfdetail(100): ToInstance] uint32 PercentTimeinGC;"

Now that we know the countertype (537003008), you need to map it to a human readable form. This link will help:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa389383(v=vs.85).aspx

The mapping for coutertype 537003008 is PERF_RAW_FRACTION.

We go back for the first link and find the calculation method for PERF_RAW_FRACTION that is:

(100 * CounterValue) / BaseValue

I love windows.

gulden

Upvotes: 2

Related Questions