Pular para o conteúdo

XCP-ng / XenServer

Este conteúdo não está disponível em sua língua ainda.

An XCP-ng or XenServer (Citrix Hypervisor) pool, read through XAPI, the management API every host already runs. No Xen Orchestra is needed.

From the DumbMonit server (or its relay agent) to the device:

PortProtocolPurpose
443TCPXAPI (HTTPS, default)

Every minute DumbMonit posts JSON-RPC calls to https://<coordinator>/jsonrpc: one session.login_with_password (the session is then kept from one poll to the next, and reopened once if the pool invalidates it), and one get_all_records per class: host, host_metrics, VM, VM_metrics, SR and pool. Nothing is ever changed: the account has the built-in read-only role, which XAPI enforces on every call.

Add the pool once, by the address of its coordinator: it reports every host, VM and storage repository. If the address you entered is a pool member, it answers HOST_IS_SLAVE with the coordinator’s address; DumbMonit follows it once, same protocol and port, so a coordinator change does not need you to edit the monitor.

All metrics are prefixed dumbmonit_xcpng_.

MetricLabelsMeaning
hosts, hosts_enabledHosts in the pool, and how many accept new VMs.
host_infohost, versionValue 1: the product version of each host.
host_enabledhost0 when the host is disabled (maintenance, or evacuated).
host_livehost1 when the host’s heartbeat reaches the coordinator, 0 when it is offline.
host_cpu_cores, host_memory_total_bytes, host_memory_used_byteshostCapacity and memory in use.
vms, vms_runningVMs, without templates, snapshots and control domains.
vm_power_state_infovm, stateValue 1: running, halted, paused or suspended.
vm_runningvm1 when the VM runs.
vm_vcpus, vm_memory_bytesvmvCPUs at start; memory in use for a running VM, its configured maximum otherwise.
vm_ha_protected_downvmOnly for VMs with a restart priority, in a pool with high availability on: 1 when the VM is halted.
srsStorage repositories.
sr_size_bytes, sr_used_bytes, sr_used_percentsrFill level (ISO libraries are counted, not detailed).
sr_sharedsr1 for a shared repository (NFS, iSCSI…).
pool_infopool, masterValue 1: the pool and its current coordinator.
pool_ha_enabledpool1 when high availability is on.
pool_ha_overcommittedpoolWith HA on: 1 when the pool can no longer restart its protected VMs after the host failures it is set to tolerate.
pool_ha_host_failures_to_toleratepoolThe number of host failures HA is set to survive.

XenAPI has no “crashed” power state. A protected VM found halted is the closest signal the API gives of a VM that stopped against your will; if you shut down a protected VM on purpose, clear its restart priority first.

The built-in rules that apply:

  • XCP-ng host offline: a host’s heartbeat has not reached the coordinator for five minutes (Warning).
  • XCP-ng SR almost full: a storage repository is 90% full for fifteen minutes (Advisory).
  • XCP-ng HA-protected VM down: a VM protected by high availability is halted for two minutes (Warning).
  • XCP-ng pool HA overcommitted: the pool is overcommitted for five minutes (Advisory).
  1. On every host of the pool, create a local account with a long random password.

    useradd -M -s /sbin/nologin dumbmonit
    passwd dumbmonit
  2. On the pool coordinator, turn on PAM authentication once.

    xe pool-enable-external-auth auth-type=PAM service-name=pam
  3. Register the account as a subject and note the UUID it prints.

    xe subject-add subject-name=dumbmonit
  4. Give that subject the built-in read-only role, with the UUID.

    xe subject-role-add uuid=SUBJECT_UUID role-name=read-only
  5. In DumbMonit, enter the address of the pool coordinator (for example xcp01.lan) with that user name and password.

  • read-only role (XAPI): Sees hosts, VMs, storage repositories and HA

Vendor documentation: XenServer RBAC with the CLI

XAPI has no screen for this: its role-based access control is managed with the xe command line, so the commands above are the way (Xen Orchestra manages its own users, not XAPI subjects).

XAPI only accepts accounts other than its built-in superuser once the pool uses external authentication, which is why PAM is turned on. Until a role is given, the account can call nothing; with read-only, a leaked password cannot change anything. Never give DumbMonit the superuser password of the hosts.

Add the pool once: the coordinator reports every host, VM and storage repository. A pool member answers with the coordinator’s address, which DumbMonit then follows.

DumbMonit only reads, through XAPI’s JSON-RPC interface (/jsonrpc): it never starts, stops or migrates a VM and never changes a storage repository or the pool’s high availability.

CredentialFields
User name and passwordThe dumbmonit account, registered as a subject with the read-only role.

Address: the host name or IP of the pool coordinator, host:port, or a URL. Options:

  • Port (443).
  • Accept an unverifiable certificate: the hosts’ own certificate is self-signed.
  • Timeout per request (15 s).

“XCP-ng refused the user name or password”: wrong password, or the account is not registered as a subject (xe subject-list).

“XCP-ng accepted the account but refused the call”: the subject has no role, or a role without read access; give it read-only.

“This host is a pool member, not the coordinator”: DumbMonit could not reach the coordinator the member named; enter the coordinator’s address yourself.