How To

Using KVM virt-top – top command for VMs

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

Original content from computingforgeeks.com - post 161453

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

Related Articles

Openstack How To Add RHEL 8 qcow2 Image To OpenStack Glance AlmaLinux Install Xen Orchestra on Rocky / CentOS / AlmaLinux Automation How To Install VMware PowerCLI Tools on macOS Cloud Install Proxmox VE 7 on Hetzner root server

Leave a Comment

Press ESC to close