Skip to content

VMware vSphere (vmware_host, vmware_vm, vmware_datastore) ​

Three sensors that read a VMware vSphere server through its Web Services API (SOAP over HTTPS, /sdk) with a read-only account. The same sensors work against an ESXi host directly, including the free edition, and against vCenter:

  • vmware_host: an ESXi host's connection state, the health vSphere gives it, CPU, memory, uptime.
  • vmware_vm: one virtual machine's power state, CPU, memory, disk space and the disk and network rates.
  • vmware_datastore: a datastore's capacity, free space and whether it is accessible.

Nothing is installed on the hosts. The sensors only read. Each poll logs in, reads and logs out again, so a poll leaves no session behind; the server's own log shows a login and a logout for it.

What these sensors do not cover: hardware sensors of the host (use Redfish on its management controller, or SNMP), vSAN and cluster resource pools, snapshots, alarms and events, and the contents of a guest (use the sensors for Windows or Linux on the guest itself).

The account ​

Create a user with the read-only role. On an ESXi host, from its shell or over SSH:

sh
esxcli system account add -i monitor -p '<password>' -c '<password>' -d 'Probeward'
esxcli system permission set -i monitor -r ReadOnly

The account needs no shell access and no other privilege. In vCenter give a user or a group the Read-only role on the root object of the inventory with Propagate to children ticked, so the sensors see every host, datastore and machine below it. The disk and network rates of a machine are performance data: the ESXi read-only role allows reading them, and an account that may not leaves the rates unknown while the sensor says why.

In Probeward create a credential of kind vsphere with the user name and the password (for vCenter, user@domain). Assign it as the vSphere credential of the device that stands for the ESXi host or vCenter, or of a group above it. The password is stored encrypted, is only sent in the login request, and never appears in parameters, messages or logs.

The device's address is the server's, and its API port is 443.

Discovery ​

Discovery recognises an ESXi host or vCenter by the vSphere API on port 443, which answers with its product name before any login. Without a credential it proposes a TCP check and a certificate check for that port and says that a credential would find more. Offer the vsphere credential (Discovery, step Credentials) and discovery reads the inventory with it, and proposes:

  • vmware_host for each connected host. Against an ESXi host the sensor is not tied to the host's name, so renaming the host does not break it; against vCenter each sensor names its host.
  • vmware_datastore for each datastore (one per name). A datastore that is not accessible is listed, not selected.
  • vmware_vm for each virtual machine. Machines that are powered on are selected. Machines that are off, and templates, are listed but not selected, so that a parked machine does not page; tick them in the results if you want them. A template is proposed with expect_running off.

Every proposed sensor pins the certificate that discovery saw (its fingerprint is in the sensor's tls_fingerprint and in the check line of the results), and the credential that worked is stored as the device's vSphere credential. Discovery trusts that certificate for the scan because you asked it to look at this address; compare the fingerprint with the one on the host if the network between is not yours. A second run proposes nothing new. A refused account is reported with the reason, and the next credential offered is tried. At most 512 machines are listed.

The certificate ​

ESXi installs a certificate that its own authority signed, which no system trusts. With the defaults (verify_tls on, no pin) a sensor therefore fails with a collection failure that says why. The message shows the fingerprint the server presented, to pin. Pin the certificate (recommended for a self-signed host): read the fingerprint on a machine you trust, ideally on the host itself,

sh
openssl s_client -connect esxi.example.org:443 </dev/null 2>/dev/null | openssl x509 -noout -fingerprint -sha256

and put it in the sensor's tls_fingerprint parameter, with or without colons, in either case. The connection is then accepted if and only if the certificate has that fingerprint. After the host renews its certificate the sensors fail the same way until you update the pin. See pinning a certificate.

The other ways: install a certificate the probe host trusts (vCenter and ESXi can both use one from your own authority) and keep verify_tls on; or turn verify_tls off, which still encrypts the connection and still needs the account, but no longer proves that the server is the one you meant. The TLS certificate sensor reads the dates of an untrusted certificate, so a self-signed host can still be watched for expiry.

Names ​

A sensor finds its host, machine or datastore by name, as the vSphere inventory shows it, wherever it is. A machine that is migrated, or a datastore that is remounted, keeps its sensor. The sensor remembers the identifier vSphere gave the object, so most polls read it directly; it checks the name every time, so an identifier that now belongs to something else is not trusted, and a renamed object is reported as not found.

Names are not unique in vSphere. If two machines (or two datastores) have the same name the sensor fails and says so, rather than choose one. Rename one of them.

Failures ​

Every message names the cause and none contains the password. A collection failure keeps the last reading and counts towards an incident; a Down is a reading.

MessageKindMeaning
vSphere refused the user name or password (InvalidLogin)auth_failedThe account or its password is wrong, or the account is locked.
the account lacks a privilege it needs on vSphere: ...auth_failedThe role does not let the account read what the sensor needs.
vSphere ended the session during the poll (NotAuthenticated) ...auth_failedThe account was disabled during the poll, or the server's session limit was reached.
this sensor needs a vsphere credential and none is assigned to it or inheritedconfigNo vSphere credential is set.
this sensor needs a vsphere credential but the one assigned is ...configThe inherited credential is of another kind.
vSphere lists no host named "x" (it has "a", "b")protocolThe name is wrong. The message shows up to five names there are. The same for vm and datastore.
this vSphere server has 3 hosts; set host to the name of the one to watchconfigA vmware_host sensor without a name against vCenter.
2 vms are named "x"; rename one of them, the sensor cannot tell them apartconfigTwo objects of the same name.
the server has no vSphere API at /sdk (HTTP 404) ...protocolThe port answers, but it is not an ESXi host or vCenter.
TLS error: the certificate is not trusted ...protocolSee the certificate.
TLS error: the server presented a certificate with the SHA-256 fingerprint A, which is not the pinned BprotocolThe pin does not match: the certificate was renewed, or something else answers.
cannot connect: connection refused, cannot connect: no route to hostunreachableNothing listens on the port, or the host is not there.
no complete HTTP response within N mstimeoutThe server did not answer in time.

Verification ​

Checked against an ESXi 8.0 Update 3 host (the free edition, a single host with a VMFS-6 datastore and two virtual machines made for the purpose, one powered on and one off): the tests replay scrubbed recordings of its answers, and run live against it, with the root account and with a local user that has only the read-only role. The figures were compared with what the host's own tools report (esxcli storage filesystem list for the datastore). The tests also run against the vSphere simulator vcsim 0.56.2 in a container, started by the tests, both as a vCenter (several hosts, a cluster, datastores and machines) and as a single ESXi host, including discovery.

Not seen: a real vCenter, a cluster, NFS, vSAN or iSCSI datastores, a host in maintenance mode or one that vCenter lost, a machine on a host that went away, vSphere 6.7 and 7. Those answers are written by hand in the tests, and marked so there where they are. Please report any difference.

AGPL-3.0-only