en	# 10 Virtual machine monitoring
zh-cn	# 10. 虚拟机监控

en	#### Overview Zabbix can use [low-level discovery](/manual/discovery/low_level_discovery) rules to automatically discover VMware hypervisors and virtual machines, and create hosts to monitor them based on pre-defined [host prototypes](/manual/discovery/low_level_discovery/host_prototypes). Zabbix also includes [ready-to-use templates](/manual/config/templates_out_of_the_box/vmware) for monitoring VMware vCenter or ESXi hypervisors. The minimum required VMware vCenter or vSphere version is 5.1.
zh-cn	#### 概述 Zabbix可以使用[低级别发现规则](/manual/discovery/low_level_discovery)自动发现VMware hypervisors（宿主机）和virtual machines（虚拟机），并根据预定义的[主机原型](/manual/discovery/low_level_discovery/host_prototypes)创建监控主机来完成监控功能。 在Zabbix中同样包含多个现成的监控模板用于监控VMware vCenter 或者 ESXi hypervisors。 截至目前为止，支持监控的VMware vCenter或vSphere 版本为5.1版。

en	#### Data collection Virtual machine monitoring consists of two steps: 1. Zabbix *vmware collector* processes collect virtual machine data - the processes obtain necessary information from VMware web services over the SOAP protocol, pre-process it, and store it in Zabbix server shared memory. 2. Zabbix *poller* processes retrieve data using Zabbix simple check [VMware monitoring item keys](/manual/vm_monitoring/vmware_keys). Zabbix divides collected data into VMware configuration data and VMware performance counter data. Both types of data are collected independently by the *vmware collector* processes. The following statistics are available based on the VMware performance counter information: - Datastore - Disk device - CPU - Power - Network interface - Custom performance counter items For the complete list of items that obtain data from VMware performance counters, see [*VMware monitoring item keys*](/manual/vm_monitoring/vmware_keys#footnotes). Note that the frequency of VMware event retrieval depends on the polling interval of [vmware.eventlog](/manual/vm_monitoring/vmware_keys#vmware.eventlog), but cannot be less then 5 seconds.
zh-cn	#### 数据采集 虚拟机的监控包含两个步骤： 1. Zabbix *vmware collector*（vmware 采集器）进程完成对虚拟机的数据采集 - 这些进程通过SOAP协议收集包括必要的VMware web服务信息，对这些信息进行预处理并且存储于Zabbix Server的共享内存。 2. Zabbix *poller* （轮询）进程通过[VMware monitoring item keys](/manual/vm_monitoring/vmware_keys)完成对数据的检索。 Zabbix将采集的数据分为两种，分别是VMware 配置数据和VMware性能计算数据。这两种类型的数据都由*vmware collector*独自完成采集。 下列所统计的参数都是可查看的VMware 性能计算信息： - Datastore（数据存储） - Disk device（磁盘设备） - CPU - Power（电源） - Network interface（网络接口） - Custom performance counter items（自定义性能计算参数） 用户若对完整的VMware 性能计算参数有查阅需求，请查看[*VMware monitoring item keys*](/manual/vm_monitoring/vmware_keys#footnotes)。 请注意，Vmware事项的检索频率依赖于[vmware.eventlog](/manual/vm_monitoring/vmware_keys#vmware.eventlog)的轮询间隔，且该间隔不能小于5秒钟。

en	#### Configuration If Zabbix server is compiled from [sources](/manual/installation/install#configure_the_sources), it must be compiled with the `--with-libcurl --with-libxml2` configuration options to enable virtual machine monitoring. Zabbix packages are compiled with these options already enabled. The following Zabbix server configuration file parameters can be modified for virtual machine monitoring: - [`StartVMwareCollectors`](/manual/appendix/config/zabbix_server#startvmwarecollectors) ::: noteclassic It is recommended to enable more collectors than the number of monitored VMware services; otherwise, the retrieval of VMware performance counter statistics might be delayed by the retrieval of VMware configuration data (which takes a while for large installations). <br><br> Generally, the value of `StartVMwareCollectors` should not dip below `2` and should not exceed twice the amount of monitored VMware services: Amount of services < `StartVMwareCollectors` < (Amount of services \* 2). For example, when monitoring one VMware service, set `StartVMwareCollectors` to `2`; when monitoring three services, set `StartVMwareCollectors` to `5`. <br><br> Note that the required number of collectors also depends on the scope of the VMware environment, and the `VMwareFrequency` and `VMwarePerfFrequency` configuration parameters. ::: - [`VMwareCacheSize`](/manual/appendix/config/zabbix_server#vmwarecachesize) - [`VMwareFrequency`](/manual/appendix/config/zabbix_server#vmwarefrequency) - [`VMwarePerfFrequency`](/manual/appendix/config/zabbix_server#vmwareperffrequency) - [`VMwareTimeout`](/manual/appendix/config/zabbix_server#vmwaretimeout) ::: noteimportant To support datastore capacity metrics, ensure that the value of the VMware `vpxd.stats.maxQueryMetrics` key is set to at least `64`. For more information, see the [*VMware Knowledge Base* article](https://kb.vmware.com/s/article/2107096). :::
zh-cn	#### 配置 如果Zabbix server采用基于编译的方式由[sources](/manual/installation/install#configure_the_sources)安装，那么用户必须在编译安装添加`--with-libcurl --with-libxml2` 配置选项来使能虚拟机的监控。而用户若采用 Zabbix安装包的方式，那么相关的配置选项已集成于安装包中。 以下的Zabbix Server配置文档参数可用于调整虚拟机监控： - [`StartVMwareCollectors`](/manual/appendix/config/zabbix_server#startvmwarecollectors) ::: noteclassic 强烈建议相较用于被监控的Vmware服务的采集器数量，用户可以使能更多的采集器数量；否则，对于VMware性能计算数据的检索会由于VMware配置数据的检索而造成延迟（尤其是大型的安装会需要更多的时间）。 <br><br> 通常情况下，`StartVMwareCollectors`的值不会低于`2`而且也不应大于监控VMware服务总数的两倍：服务数量< `StartVMwareCollectors` < (服务数量 \* 2)。 举例来说，当监控一个VMware服务时，设定`StartVMwareCollectors`的值为`2`；当监控三个服务时，则需要用户设定`StartVMwareCollectors`的值为`5`。 <br><br> 请注意，系统所需的采集器数量同样也依赖于VMware环境的大小，同时用户还需考虑`VMwareFrequency`和`VMwarePerfFrequency`两个配置参数。 ::: - [`VMwareCacheSize`](/manual/appendix/config/zabbix_server#vmwarecachesize) - [`VMwareFrequency`](/manual/appendix/config/zabbix_server#vmwarefrequency) - [`VMwarePerfFrequency`](/manual/appendix/config/zabbix_server#vmwareperffrequency) - [`VMwareTimeout`](/manual/appendix/config/zabbix_server#vmwareperffrequency) ::: noteimportant 为了能够支持数据存储容量指标，请确保VMware `vpxd.stats.maxQueryMetrics`参数的键值至少设定为`64`。 若需要更多资讯，请查阅[*VMware Knowledge Base* article](https://kb.vmware.com/s/article/2107096)。 :::

en	##### Discovery Zabbix can use low-level discovery rules (for example, *vmware.hv.discovery\[{$VMWARE.URL}\]*) to automatically discover VMware hypervisors and virtual machines. Moreover, Zabbix can use host prototypes to automatically generate real hosts for the discovered entities. For more information, see [*Host prototypes*](/manual/discovery/low_level_discovery/host_prototypes).
zh-cn	##### 自动发现规则 Zabbix可以使用low-level discovery rules（低级别发现规则，例如*vmware.hv.discovery\[{$VMWARE.URL}\]*）来实现 VMware hypervisors（宿主机）和虚拟机的自动发现。 除此之外，Zabbix可以使用host prototypes（主机原型）来实现对发现的实体进行自动生成监控主机的功能。 更多信息，请参考[*Host prototypes*](/manual/discovery/low_level_discovery/host_prototypes)。

en	##### Configuration examples For a basic example of how to set up Zabbix for monitoring VMware using the *VMware FQDN* template, see [*Monitor VMware with Zabbix*](/manual/guides/monitor_vmware). For a more detailed example of how to create a host, a low-level discovery rule, and a host prototype for monitoring VMware, see [*Setup example*](/manual/vm_monitoring/example).

en	#### Extended logging The data collected by the *vmware collector* processes can be logged for detailed debugging using debug level 5. The debug level can be configured in the [server](/manual/appendix/config/zabbix_server#debuglevel) and [proxy](/manual/appendix/config/zabbix_proxy#debuglevel) configuration files or using the runtime control option `-R log_level_increase="vmware collector,N"`, where "N" is the process number. For example, to increase the debug level from 4 to 5 for all *vmware collector* processes, run the following command: zabbix_server -R log_level_increase="vmware collector" To increase the debug level from 4 to 5 for the second *vmware collector* process, run the following command: zabbix_server -R log_level_increase="vmware collector,2" When extended logging of VMware collector data is no longer required, it is recommended to decrease the debug level to default (3) by running the `-R log_level_decrease` command.
zh-cn	#### 日志扩展 用户可以使用“debug level 5”来对*vmware collector*进程所收集的数据进行详细调试。用户可以在[server](/manual/appendix/config/zabbix_server#debuglevel) 和[proxy](/manual/appendix/config/zabbix_proxy#debuglevel) 配置文档中对调试等级进行配置或者使用运行时间控制选项 `-R log_level_increase="vmware collector,N"`来实现，“N”在这里指的是进程号。 举例来说，若想要提升所有的*vmware collector*进程等级由4升到5, 请运行如下命令： zabbix_server -R log_level_increase="vmware collector" 若想要提升第二个*vmware collector*进程的调试等级由4升到5，则运行如下命令： zabbix_server -R log_level_increase="vmware collector,2" 若用户不再需要开启VMware采集器数据的日志扩展，则可以应用 `-R log_level_decrease` 命令来恢复其调试等级（缺省等级3）。

en	#### Troubleshooting - In case of unavailable metrics, please ensure that they are not made unavailable or turned off by default in recent VMware vSphere versions, or if some limits are not placed on performance-metric database queries. For more information, see [ZBX-12094](https://support.zabbix.com/browse/ZBX-12094). - If `config.vpxd.stats.maxQueryMetrics` is invalid or exceeds the maximum number of characters permitted error, add a `config.vpxd.stats.maxQueryMetrics` parameter to the vCenter Server settings. The value of this parameter should be the same as the value of `maxQuerysize` in VMware's *web.xml* file. For more information, see [*VMware Knowledge Base* article](https://kb.vmware.com/s/article/2107096). - If you suspect your Zabbix installation is using too much memory, see [Profiling excessive memory usage with tcmalloc](/manual/installation/known_issues#profiling-excessive-memory-usage-with-tcmalloc).
zh-cn	#### 故障排除 - 若指标不可用，请确保在当前的 VMware vSphere 版本中出于不可用或默认关闭状态，又或者是否未对数据库性能指标未设置限制。若想了解更多信息，请查阅 [ZBX-12094](https://support.zabbix.com/browse/ZBX-12094)。 - 若`config.vpxd.stats.maxQueryMetrics`无效或者超出了允许字符错误的最大阈值，那么用户可以通过添加一个`config.vpxd.stats.maxQueryMetrics`参数到vCenter Server 配置中来解决这个问题。该参数的值应于VMware *web.xml*文档中`maxQuerysize`的值相同。更多的信息，请查阅[*VMware Knowledge Base* article](https://kb.vmware.com/s/article/2107096)。