Using KVM virt-top – top command for VMs

The virt-top is a command-line performance monitoring tool for virtual machines, similar to the top utility for processes. It uses the libvirt API to query for the information about virtual machines (VMs) running on a KVM host and provides details about CPU, memory, disk, and network usage.

The virt-top displays real-time performance metrics and supports user interaction. The data available can be exported for further analysis.

🌐 Brought to you by CloudSpinx – this excerpt is from Mastering KVM Virtualization. Read the entire guide online or download. View the full eBook.

Installing virt-top

On RHEL-Based Distributions:

sudo dnf install epel-release -y

sudo dnf install virt-top -y

On Debian-Based Distributions:

sudo apt update

sudo apt install virt-top -y

Verify installation by checking the software version:

virt-top --version

Launching virt-top requires sufficient privileges to access libvirt.

sudo virt-top

By default it connects to the default hypervisor (qemu:///system) unless specified.

To monitor VMs on a remote host, specify by connection URI:

sudo virt-top -c qemu+ssh://user@remote-host/system

Here is an output from virt-top command:

virt-top 22:43:42 - x86_64 12/12CPU 3000MHz 64015MB

4 domains, 4 active, 4 running, 0 sleeping, 0 paused, 0 inactive D:0 O:0 X:0

CPU: 12.4% Mem: 65536 MB (65536 MB by guests)



ID S RDRQ WRRQ RXBY TXBY %CPU %MEM TIME NAME

20 R 1901 134 503K 1M 10.5 51.0 877:32:13 dbmaster01

19 R 0 3 887K 1M 1.6 25.0 414:30:50 app-server01

3 R 0 7 36K 46K 0.2 12.0 286:56:27 vpn-server01

4 R 0 0 36K 43K 0.2 12.0 232:24:59 radius01

Key information from the ouptut are;

  • Header: Shows general system metrics, including host CPU, memory, and the number of VMs.
  • Columns:
ColumnDescription
IDThe ID assigned to the VM by the hypervisor.
SThe state of the VM (R = Running, S = Sleeping, P = Paused).
RDRQThe number of read requests issued by the VM.
WRRQThe number of write requests issued by the VM.
RXBYNetwork bytes received (e.g., 503K = 503 KB).
TXBYNetwork bytes transmitted (e.g., 1M = 1 MB).
%CPUPercentage of host CPU used by the VM.
%MEMPercentage of host memory used by the VM.
TIMETotal CPU time used by the VM (HH:MM:SS format).
NAMEName of the VM.

Filter to display specific VMs by name or ID:

sudo virt-top --domain

Run virt-top for one minute and save output in csv file.

sudo virt-top --csv report.csv --end-time +60

For more usage example run:

virt-top --help

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Unlock the Right Solutions with Confidence

At CloudSpinx, we don’t just offer services - we deliver clarity, direction, and results. Whether you're navigating cloud adoption, scaling infrastructure, or solving DevOps challenges, our seasoned experts help you make smart, strategic decisions with total confidence. Let us turn complexity into opportunity and bring your vision to life.

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

qemu-img is a powerful command-line tool that lets you create, convert, and inspect virtual machine disk images with ease. It […]

To effectively manage KVM KVM (Kernel-based Virtual Machine) environments, you require a set of powerful tools to monitor, modify, and […]

There are several initial configurations that you should consider when setting up KVM environment and network configurations is one of […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.