性能计数器收集器类型

可以使用性能计数器收集器类型来收集运行 SQL Server 2008 的计算机上的特定性能计数器信息。以后可以使用此类数据作为故障排除或容量规划的依据。此收集器类型在 core.supported_collector_types 视图中注册。

此收集器类型具有以下输入参数:

  • 对象。在 SQL Server 实例中运行的 SQL Server 对象。

  • 计数器。与 SQL Server 对象关联的计数器。

  • 实例。指定对象的实例。

有关对象和计数器的详细信息,请参阅使用 SQL Server 对象

注意注意

一些输入参数支持通配符,这使得您可以在一个语句中包含多个计数器。不过,对通配符的支持是有限的。不能在“对象”级使用通配符。而在“计数器”和“实例”级,只能在字符串开头(例如,“* Processor”)或字符串结尾(例如,“Memory *”)使用通配符。

性能计数器输入架构

性能计数器收集器类型使用以下输入参数架构。

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="DataCollectorType">
  <xs:element name="PerformanceCountersCollector">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="PerformanceCounters">
          <xs:complexType>
            <xs:attribute name="Objects" type="xs:string" use="required" />
            <xs:attribute name="Counters" type="xs:string" use="required" />
            <xs:attribute name="Instances" type="xs:string" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="StoreLocalizedCounterNames" type="xs:boolean" use="optional" default="false" />
    </xs:complexType>
  </xs:element>
</xs:schema>

下面的代码示例演示如何使用该架构。

<ns:PerformanceCountersCollector xmlns:ns="DataCollectorType">  
<PerformanceCounters 
      Objects="SQLServer:Locks" 
      Counters="Lock *" 
      Instances="_Total" 
      /> 
<PerformanceCounters 
      Objects="SQLServer:SQL Statistics" 
      Counters="*/sec" 
      /> 
<PerformanceCounters 
      Objects="Processor" 
      Counters="% Processor Time" 
      Instances="*"
      /> 
</ns:PerformanceCountersCollector>

此示例将为“_Total”实例生成名称以“Lock”开头的计数器,将为 SQLServer:Locks 对象检索这些计数器。它还将为 SQLServer:SQLStatistics 对象检索以“/sec”结尾的所有计数器的所有实例。最后,此示例将检索 Processor 对象的所有实例的“% Processor Time”计数器。

处理和输出

性能计数器收集器类型使用数据收集器提供的收集和上载包。此收集器类型通过 Performance Data Helper API 从性能计数器中查询和获取数据。有关详细信息,请参阅 MSDN 上的 Using the Performance Data Helper Library(使用 Performance Data Helper Library)。

完成数据收集后,数据收集器会将数据大容量上载到管理数据仓库中的 snapshots.performance_counters 视图。有关详细信息,请参阅管理数据仓库

更改历史记录

更新的内容

更正了性能计数器收集器类型的输入架构。

更正了演示如何使用该架构的代码示例。