Home Command line utilities Display Virtualization Systems Stats With Virt-top In Linux

Display Virtualization Systems Stats With Virt-top In Linux

By sk
3.8K views

Virt-top is a top-like utility for displaying the stats of virtualized domains in Linux. Just like the top command line utility, Virt-top shows the stats of CPU, memory, virtual disks and network of virtual machines and the hypervisor. Since Virt-top uses libvert, it can be able to show stats across different virtualization systems such as KVM, XEN and QEMU. In this brief guide, we will see how to display virtualization systems stats with Virt-top in Linux.

Install Virt-top

Virt-top is available for many Debian-based and RPM-based mainstream Linux distributions.

To install Virt-top on CentOS, RHEL, run the following command:

$ sudo yum install virt-top

To install Virt-top on Debian, Ubuntu, run:

$ sudo apt install virt-top

On Fedora:

 $ sudo dnf install virt-top

On openSUSE:

$ sudo zypper install virt-top

Display Virtualization Systems Stats With Virt-top In Linux

Virt-top's command line options and keys are almost same as ordinary top command.

When running virt-top without any options, you will see an output like below:

Display virtualization systems stats with virt-top

As you can see in the above output, the top first column in the Virt-top interface shows the following details of your host system:

  • the current system time,
  • CPU architecture,
  • No CPU cores,
  • CPU clock speed,
  • Total Memory etc.

The second column shows the following stats:

  • Total no of domains (VMs),
  • No of active/inactive domains,
  • No of running domains,
  • No of sleeping domains,
  • No of paused domains.

The third column displays:

  • Total CPU usage by guests,
  • Total memory usage by guests.

The last column shows the actual stats of the running virtual machines (domains). In my case, Virt-top is showing the stats of CentOS 8 KVM guest.

Press q to exit Virt-top.

Display Physical CPUs

Like I already said, the keyboard shortcuts of Virt-top is same as ordinary top utility.

By default Virt-top will show you stats of of domains. When virt-top is running, press 1 (number 1) to toggle between physical CPUs and domains display:

Display physical CPUs in Virt-top output

Now Virt-top will display physical CPUs instead of domains. As you can see from the left hand column, there are 4 physical CPUs in my system. To display domains again, press 0 (zero).

Display Network Interfaces

When Virt-top is running, press 2 to toggle between domains and network interfaces.

Display network interfaces in Virt-top output

Display Virtual Disks (Block devices)

When Virt-top is running, press 3 to toggle between domains and virtual disks.

Display virtual disks in Virt-top output

Sort stats by CPU usage

By default, the stats will be sorted by CPU. If you've sorted by memory or some others, press P to show stats sorted by CPU.

Sort stats by CPU, Memory, Time, domain ID

When Virt-top is running, you can change the sort order of the stats by pressing the following keys:

  • Press uppercase P (shift+p) to sort by cpu,
  • Press uppercase M (shift+m) to sort stats by memory,
  • Press uppercase T (shift+t) to sort by total time,
  • Press uppercase N (shift+n) to sort by domain ID.

To interactively select the sort field, press uppercase F (shift+f) and the choose your preferred order by pressing the relevant key:

Interactively select the sort field in Virt-top interface

Set update interval

The default delay interval between screen updates is 3.0 seconds. You can change this delay interval by pressing "s" or "d" key while Virt-top is running.

Set the number of iterations

You know that the top command will keep running until you manually exit it. Virt-top is same as top utility. Virt-top will keep running and showing the stats continuously.

You can change this behavior by explicitly mentioning the number of iterations to run.

For example, the following command will set the number of iterations to run as 5 and close the Virt-top command after 5 iterations:

$ virt-top -n 5

Display help

When Virt-top is running, press "h" to display help.

Display Virt-top help section

Press any key to close the help window.

For more details, refer man pages:

$ man virt-top

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More