10 Virtual machine monitoring

Overview

Zabbix can use low-level discovery rules to automatically discover VMware hypervisors and virtual machines, and create hosts to monitor them based on pre-defined host prototypes.

Zabbix also includes templates for monitoring VMware vCenter or ESXi hypervisors.

The minimum required VMware vCenter or vSphere version is 5.1.

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.

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.

Configuration

If Zabbix server is compiled from 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:

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).

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.

Note that the required number of collectors also depends on the scope of the VMware environment, and the VMwareFrequency and VMwarePerfFrequency configuration parameters.

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.

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.

Ready-to-use templates

Zabbix includes a range of ready-to-use templates designed for monitoring VMware vCenter or ESXi hypervisors. These templates contain pre-configured low-level discovery rules, along with various built-in checks for monitoring virtual installations.

The following templates can be used for monitoring VMware vCenter or ESXi hypervisors:

  • VMware - uses UUID data for corresponding macros
  • VMware FQDN - uses FQDN data for corresponding macros

For the correct functioning of the VMware FQDN template, each monitored virtual machine should have a unique OS name adhering to FQDN rules. Additionally, VMware Tools must be installed on every machine. If these prerequisites are met, using the VMware FQDN template is recommended. The VMware FQDN template has been available since Zabbix 5.2 with the introduction of the ability to create hosts with custom interfaces.

A classic VMware template is also available and can be used if FQDN requirements are unmet. However, the VMware template has a known issue. Hosts for discovered virtual machines are created with names that are saved in vCenter (for example, "VM1", "VM2", etc.). If Zabbix agent is installed on these hosts, and active Zabbix agent autoregistration is enabled, the autoregistration process will read host names as they were registered during launch (for example, "vm1.example.com", "vm2.example.com", etc.). This can lead to the creation of new hosts for existing virtual machines (since no name matches have been found), resulting in duplicate hosts with different names.

The following templates are used for discovered entities and, typically, should not be manually linked to a host:

  • VMware Hypervisor
  • VMware Guest
Host macros configuration

To use VMware simple checks, the host must have the following user macros defined:

  • {$VMWARE.URL} - VMware service (vCenter or ESXi hypervisor) SDK URL (https://servername/sdk)
  • {$VMWARE.USERNAME} - VMware service user name
  • {$VMWARE.PASSWORD} - VMware service {$VMWARE.USERNAME} user password
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.

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.

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 and proxy 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.

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.
  • 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.