[comment]: # ({e93b7644-f89c7380})
# 6 Windows 性能计数器

[comment]: # ({/e93b7644-f89c7380})

[comment]: # ({47e1ae8b-47e1ae8b})

#### 概览

你可以使用 *perf\_counter\[\]* 这个key有效的监控Windows性能计数器。

例如：

    perf_counter["\Processor(0)\Interrupts/sec"]

或

    perf_counter["\Processor(0)\Interrupts/sec",10]

有关使用此key的更多信息请参阅[Windows专用监控项](/manual/config/items/itemtypes/zabbix_agent/win_keys)。

为了获取可用于监控的新能计数器完整列表，你可以运行：

    typeperf -qx

可以通过低级别发现来发现windows性能计数器的多[对象实例](/manual/discovery/low_level_discovery/examples/windows_perf_instances)，并自动创建多实例对象的性能计数器监控项。

[comment]: # ({/47e1ae8b-47e1ae8b})

[comment]: # ({8a2ce6ff-38d80c32})
#### 数字表示

Windows 为对象和性能计数器名称维护了数字表示形式（索引）。Zabbix 支持在 `perf_counter`、`perf_counter_en` 监控项键以及 `PerfCounter`、`PerfCounterEn` 配置参数中使用这些数字表示形式作为参数。

但是，除非你能够保证这些数字索引在特定主机上映射到正确的字符串，否则不建议使用它们。如果你需要创建可在不同主机和各种本地化 Windows 版本之间通用的可移植监控项，可以使用 `perf_counter_en` 键或 `PerfCounterEn` 配置参数，它们允许无论系统区域设置如何都使用英文名称。

要找出对应的数字值，请运行 **regedit**，然后在 *HKEY\_LOCAL\_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009* 中找到 *Counter*。

注册表项中包含如下信息：

    1
    1847
    2
    System
    4
    Memory
    6
    % Processor Time
    10
    File Read Operations/sec
    12
    File Write Operations/sec
    14
    File Control Operations/sec
    16
    File Read Bytes/sec
    18
    File Write Bytes/sec
    ....

在这里，你可以找到性能计数器各个字符串部分对应的数字，例如在 '\\System\\% Processor Time' 中：

    System → 2
    % Processor Time → 6

然后，你就可以使用这些数字来用数字形式表示该路径：

    \2\6

[comment]: # ({/8a2ce6ff-38d80c32})

[comment]: # ({96efda14-96efda14})

#### 性能计数器参数

你可以部署一些PerfCounter参数，来完成通过Windows性能计数器监控。

例如，你可以将下面的内容添加到Zabbix agent配置文件中：

       PerfCounter=UserPerfCounter1,"\Memory\Page Reads/sec",30
       或
       PerfCounter=UserPerfCounter2,"\4\24",30

配置了这些参数后，你就可以简单的使用 *UserPerfCounter1* 或*UserPerfCounter2* 作为key来创建相应的监控项。

当然，别忘了在更改配置文件后重新启动Zabbix agent。

[comment]: # ({/96efda14-96efda14})
