Submit a ticketCall us

Looking to compare latest NPM features with previous versions of NPM?
The NPM new feature summary offers a comparison of new features and improvements offered with this release.

 

Home > Success Center > Database Performance Analyzer (DPA) > Create custom charts in DPA

Create custom charts in DPA

Table of contents

Overview

This article provides brief information and steps to create custom charts (specific performance counters) in DPA. 

From time to time we have customers ask about gathering details for specific performance counters. DPA allows for this degree of customization, all it takes is a quick edit of some XML files and a little custom T-SQL code.

Environment

All DPA versions

Steps

The following steps are for adding objects to your DPA collection in the Page Life Expectancy:

1. Create a metrics directory in {install directory}\Ignite PI\iwc\tomcat\ignite_config\idc.

2. Create two files, and name them as: 

  • {install directory}\Ignite PI\iwc\tomcat\ignite_config\idc\metrics\custom-metrics-queries.xml
  • {install directory}\Ignite PI\iwc\tomcat\ignite_config\idc\metrics\custom-metrics-properties_SQLServer.xml

3. In the custom-metrics-properties_SQLServer.xml file, add the following code, and save the file. 

<metricsPropertiesList>
<metricsProperties name="Page Life Expectancy">
  <displayName>Page Life Expectancy</displayName>
    <description>Number of seconds a page stays in buffer pool.
</description>
  <category>Memory</category>
  <units>seconds</units>
  <heartbeat>60</heartbeat>
  <minY></minY>
  <maxY></maxY>
  <thresholds>
     <warning>
        <minValue>300</minValue>
        <maxValue>600</maxValue>
     </warning>
     <critical>
        <minValue></minValue>
        <maxValue>300</maxValue>
     </critical>
  </thresholds>
</metricsProperties>
</metricsPropertiesList>

 

4. Open the custom-metrics-queries.xml file, and enter the following code. This code will run the T-SQL to get the desired performance counter Page Life Expectancy:

<metricsQueryList>
<metricsQuery className="com.confio.idc.database.metrics.domain.queries.
SingleValueMetricsQuery">
  <sql>
     <![CDATA[
        select cntr_value
        from sys.dm_os_performance_counters
        where counter_name = 'Page life expectancy'
        and object_name like '%Buffer Manager%'
     ]]>
  </sql>
<frequency>60</frequency>
  <queryTimeout>10</queryTimeout>
  <name>Page Life Expectancy</name>
<supportedDatabaseList>
  <supportedDatabase>
     <databaseType>SQL Server</databaseType>
     <minimumVersion>9.0.0</minimumVersion>
   </supportedDatabase>
</supportedDatabaseList>
</metricsQuery>
</metricsQueryList>

 

Additional Information:

The sys.dm_os_performance_counters DMV contains a number of objects found in System Monitor.

If you what you need is NOT in the DMV, for example, Avg. Disk sec/Read, you can use some WMI objects using sp_OA.

 

The following example should help customize DPA collections, especially if the counter is already available in the sys.dm_os_performance_counters DMV.

 

<metricsQuery className="com.confio.idc.database.metrics.domain.queries.
DeltaCalculationMetricsQuery">
  <sql>
     <![CDATA[
        DECLARE @WmiServiceLocator INT ,
                @WmiService INT ,
                @CounterObject INT ,
                @DiskSecPerRead BIGINT ,
                @DiskSecPerRead_Base BIGINT ,
                @DiskSecPerWrite BIGINT ,
                @DiskSecPerWrite_Base BIGINT

        EXEC sp_OACreate 'WbemScripting.SWbemLocator',
@WmiServiceLocator OUTPUT, 5

        EXEC sp_OAMethod @WmiServiceLocator, 'ConnectServer',
@WmiService OUTPUT, '.', 'root\cimv2'

        IF ISNULL(@WmiService, -1) <= 0
           BEGIN
              EXEC sp_OADestroy @WmiServiceLocator
                 RAISERROR('Could not access WMI service.
See: http://support.confio.com/kb/1588', 16, 1)
              RETURN
           END

        EXEC sp_OAMethod @WmiService, 'Get', @CounterObject OUTPUT,
'Win32_PerfRawData_PerfDisk_PhysicalDisk="_Total"'

        EXEC sp_OAGetProperty @CounterObject, 'AvgDiskSecPerRead',
@DiskSecPerRead OUTPUT
        EXEC sp_OAGetProperty @CounterObject, 'AvgDiskSecPerRead_Base',
@DiskSecPerRead_Base OUTPUT
        EXEC sp_OAGetProperty @CounterObject, 'AvgDiskSecPerWrite',
@DiskSecPerWrite OUTPUT
        EXEC sp_OAGetProperty @CounterObject, 'AvgDiskSecPerWrite_Base',
@DiskSecPerWrite_Base OUTPUT

        EXEC sp_OADestroy @CounterObject
        EXEC sp_OADestroy @WmiService
        EXEC sp_OADestroy @WmiServiceLocator  

        IF @DiskSecPerRead IS NULL OR @DiskSecPerWrite IS NULL
           BEGIN
              RAISERROR('Could not access WMI counter:
Win32_PerfRawData_PerfDisk_PhysicalDisk.Name="_Total".
See: http://support.confio.com/kb/1588', 16, 1)
              RETURN
           END

        SELECT @DiskSecPerRead, @DiskSecPerRead_Base, @DiskSecPerWrite,
@DiskSecPerWrite_Base
        ]]>
    </sql>
        <frequency>60</frequency>
        <querytimeout>30</querytimeout>
        <metricslist>
            <metric name="DiskSecPerRead">
                <expression>args[0].divide(ONE_HUNDRED,
BigDecimal.ROUND_HALF_DOWN)
.divide(TEN, BigDecimal.ROUND_HALF_DOWN).divide(args[1],
BigDecimal.ROUND_HALF_DOWN)
</expression>
            </metric>
            <metric name="DiskSecPerWrite">
                <expression>args[2].divide(ONE_HUNDRED,
BigDecimal.ROUND_HALF_DOWN)
.divide(TEN, BigDecimal.ROUND_HALF_DOWN).divide(args[3],
BigDecimal.ROUND_HALF_DOWN)
</expression>
            </metric>
        </metricslist>
        <supporteddatabaselist>
          <supporteddatabase>
            <databasetype>SQL Server</databasetype>
            <minimumversion>8.0.0</minimumversion>
          </supporteddatabase>
        </supporteddatabaselist>
</metricsquery>

 

 

If you need to get additional counters not in that DMV then you need to resort to other methods to pull the data from the OS. 

You can use WMICodeCreator tool available for free from Microsoft.

Last modified
19:08, 22 Jun 2016

Tags

Classifications

Public