[comment]: # ({3ca85094-3ca85094})
# 10 Virtual machine monitoring

[comment]: # ({/3ca85094-3ca85094})

[comment]: # ({9629b83b-621e23e6})
#### 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.

[comment]: # ({/9629b83b-621e23e6})

[comment]: # ({7c4732bd-4c2e8939})
#### 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.

[comment]: # ({/7c4732bd-4c2e8939})

[comment]: # ({927369fb-68c3f7d5})
#### 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).
:::

[comment]: # ({/927369fb-68c3f7d5})

[comment]: # ({dc05cb06-e5966479})
##### 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).

[comment]: # ({/dc05cb06-e5966479})

[comment]: # ({b1610a0a-38145b5c})
##### 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).

[comment]: # ({/b1610a0a-38145b5c})

[comment]: # ({6f6ab067-44948bb1})
#### 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.

[comment]: # ({/6f6ab067-44948bb1})

[comment]: # ({cc21c6f6-f6f9d3ef})
#### 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).

[comment]: # ({/cc21c6f6-f6f9d3ef})
