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

LEAVE A REPLY

Please enter your comment!
Please enter your name here