How to Monitor the Performance of Virtual Machines on Debian 12 Bookworm System

Learn how to monitor the performance of virtual machines on Debian 12 Bookworm system.

Monitoring virtual machines (VMs) is critical for maintaining system stability, identifying performance bottlenecks, and ensuring optimal resource utilization. On Debian 12 Bookworm, several tools and techniques can help you gain visibility into your virtual environment. Whether you’re using KVM, QEMU, libvirt, or other virtualization platforms, Debian provides a robust ecosystem for VM performance monitoring.

In this guide, we’ll explore how to monitor VM performance using command-line tools, graphical utilities, and advanced monitoring solutions tailored for Debian 12.


Why VM Performance Monitoring Matters

Virtual machines can behave like black boxes if you don’t have the proper visibility into their resource usage. Some key reasons to monitor VM performance include:

  • Detecting CPU or memory overcommitment
  • Diagnosing slow disk or network I/O
  • Ensuring VMs get fair access to host resources
  • Tracking system health and uptime
  • Supporting capacity planning and scaling

Debian 12 ships with a modern Linux kernel (6.1.x series) and systemd, offering up-to-date features and improved performance tools for managing VMs.


Prerequisites

Before diving into the monitoring tools, ensure your virtualization environment is set up. The most common stack on Debian includes:

  • KVM/QEMU: Kernel-based Virtual Machine for virtualization
  • libvirt: Toolkit to interact with virtualization platforms
  • virt-manager: GUI tool to manage VMs
  • virsh: Command-line utility for libvirt

You can install these packages with:

sudo apt update
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients virt-manager bridge-utils

Make sure your user is added to the libvirt and kvm groups:

sudo usermod -aG libvirt,kvm $USER

Log out and back in for group changes to take effect.


1. Using virt-top: Live Resource Monitoring for VMs

virt-top is a top-like utility for virtual machines that provides a real-time view of resource usage.

Installing virt-top

sudo apt install virt-top

Running virt-top

virt-top

By default, virt-top shows:

  • CPU usage per VM
  • Memory consumption
  • Disk I/O
  • Network traffic

You can toggle between display modes using keyboard shortcuts (c for CPU, m for memory, etc.).

Benefits

  • Lightweight and interactive
  • Specifically designed for libvirt-managed VMs
  • No need to log into the VM guest

2. Using virsh domstats: Get VM-Specific Metrics

virsh is a command-line interface for managing VMs via libvirt. The domstats command provides detailed statistics per VM.

Example

virsh list --all
virsh domstats vmname

This command shows:

  • CPU time
  • Memory usage
  • Block I/O statistics
  • Network interface stats

To make it more readable, try:

virsh domstats --domain vmname --vcpu --block --interface --balloon --perf

Benefits

  • Scriptable for automation
  • Great for ad-hoc checks
  • Works well with custom monitoring scripts

3. Using top, htop, and glances on the Host

Sometimes the simplest tools provide the most insight. Host-level monitoring tools like top, htop, and glances allow you to monitor the system resources used by VM processes.

Installing htop and glances

sudo apt install htop glances

VMs appear as qemu-system-x86_64 processes. With htop, you can press F5 (Tree view) to see which threads belong to which VMs.

Benefits

  • Quick snapshot of host resource load
  • Easy to identify high CPU or RAM usage
  • Doesn’t require libvirt integration

4. Monitoring Disk and I/O: iostat, iotop, and pidstat

Disk I/O is one of the most common performance bottlenecks in virtual environments. These tools can help:

Install the tools

sudo apt install sysstat iotop

iostat

iostat -xz 1

Shows per-device I/O stats every second, including:

  • Read/write throughput
  • IOPS (transactions per second)
  • Utilization percentage

iotop

sudo iotop

Interactive tool to monitor real-time I/O usage by process. Look for qemu-system processes with high I/O.

pidstat

pidstat -d 1

Shows per-process disk activity.


5. Monitoring Network Performance: nload, iftop, and vnstat

VMs can consume significant network resources. You can monitor this using host-level tools.

Install the tools

sudo apt install nload iftop vnstat

nload

sudo nload

Real-time visualization of incoming and outgoing traffic.

iftop

sudo iftop -i br0

Shows bandwidth usage per connection on your network bridge interface (br0 or virbr0).

vnstat

vnstat -l -i br0

Displays live and historical bandwidth usage.


6. Using collectd with libvirt Plugin for Long-Term Metrics

For long-term performance tracking, use collectd with a libvirt plugin.

Install collectd

sudo apt install collectd collectd-utils libvirt-dev

Enable libvirt plugin

Edit the config file:

sudo nano /etc/collectd/collectd.conf

Add:

LoadPlugin libvirt
<Plugin "libvirt">
  Connection "qemu:///system"
  RefreshInterval 60
</Plugin>

Restart collectd:

sudo systemctl restart collectd

You can integrate collectd with visualization tools like Grafana or InfluxDB for dashboards.


7. Using Cockpit for Web-Based Monitoring

If you prefer a GUI-based monitoring experience, Cockpit provides an excellent web interface for VM and host monitoring.

Install Cockpit and libvirt plugin

sudo apt install cockpit cockpit-machines

Enable and start the service:

sudo systemctl enable --now cockpit.socket

Access Cockpit via https://localhost:9090 in your browser.

Features

  • Real-time performance graphs
  • VM management (start, stop, configure)
  • Disk and memory stats

8. Guest-Level Monitoring (Inside the VM)

In addition to host-based monitoring, you may also want to monitor performance from inside the VM.

Tools to use

  • htop, glances – for live performance data
  • df -h, du -sh – for disk space usage
  • free -m, vmstat – for memory insights
  • systemd-analyze – for boot performance

For automated monitoring inside VMs, consider setting up Prometheus Node Exporter or Zabbix Agent.


9. Monitoring with Prometheus and Grafana (Advanced)

If you’re managing many VMs, you may want a centralized monitoring solution. Prometheus with Grafana is a powerful combination.

  • Prometheus scrapes metrics from exporters (e.g., node_exporter, libvirt_exporter)
  • Grafana visualizes metrics in dashboards

Basic Prometheus stack setup includes

  • prometheus server
  • node_exporter on host and guests
  • libvirt_exporter for VM-level stats

Installers and pre-built dashboards are available on Grafana’s dashboard repository.


Best Practices for VM Performance Monitoring

  1. Set thresholds: Define CPU, memory, and disk usage thresholds.
  2. Monitor both host and guest: Don’t rely solely on host-level stats.
  3. Use alerts: Integrate email or webhook alerts for performance anomalies.
  4. Visualize trends: Use dashboards to monitor patterns over time.
  5. Automate reports: Generate daily or weekly reports to review performance.
  6. Balance loads: Distribute VMs across CPU cores and disks for better efficiency.

Conclusion

Debian 12 Bookworm provides a solid foundation for virtualization, and it offers an array of tools to monitor VM performance effectively. From real-time command-line utilities like virt-top and iotop to full-fledged monitoring stacks with Prometheus and Cockpit, you have many options to suit your environment and skill level.

Start with the basics—use virt-top, virsh, and htop—and gradually adopt more sophisticated tools as your needs evolve. Proper monitoring ensures your VMs stay responsive, your host remains stable, and your users stay happy.