---
date_published: 2026-08-13
date_modified: 2026-08-13
canonical_url: https://metricshub.org/community-connectors/connectors/virsh.html
---

 [Supported Platforms](../supported-platforms.html)   [Connectors Directory](../connectors-directory.html)

# libvirt (virsh)

## Description

This connector enables hardware monitoring for VMs through the virsh command. The libvirt API must be installed on the host.

[community](tags/community.html) [hardware](tags/hardware.html) [linux](tags/linux.html)

[Source](https://github.com/metricshub/community-connectors/tree/main/src/main/connector/hardware/Virsh/Virsh.yaml)

## Target

Typical platforms: **[Linux](platforms/linux.html), [Microsoft Windows](platforms/microsoft-windows.html), [QEMU/KVM](platforms/qemu-kvm.html), [VMware](platforms/vmware.html), [VirtualBox](platforms/virtual-box.html), [Xen](platforms/xen.html)**

Operating system: **Linux**

## Prerequisites

Leverages: **libvirt API**

Technology and protocols: **Commands**

## Examples

### CLI

```batch
metricshub HOSTNAME -t linux -c +Virsh --ssh -u USER
```

### metricshub.yaml

```yaml
resourceGroups:
  <RESOURCE_GROUP>:
    resources:
      <HOSTNAME-ID>:
        attributes:
          host.name: <HOSTNAME> # Change with actual host name
          host.type: linux
        connectors: [ +Virsh ] # Optional, to load only this connector
        protocols:
          ssh:
            username: <USERNAME> # Change with actual credentials
            password: <PASSWORD> # Encrypted using metricshub-encrypt
```

## Connector Activation Criteria

The **libvirt (virsh)** connector will be automatically activated, and its status will be reported as OK if all the below criteria are met:

- The command below succeeds on the monitored host 
  
    - Command: `virsh list`
    - Output contains: `Name` (regex)

## Metrics

| Type | Collected Metrics | Specific Attributes |
| --- | --- | --- |
| **vm** | - `hw.power_state{hw.type="vm", state="off\|on\|suspended"}` - `hw.vm.power_ratio` | - `hw.parent.type` - `id` - `info` - `name` - `vm.host.name` |
