Git Product home page Git Product logo

vmtop's Introduction

vmtop

Monitor various metrics for KVM/qemu guests and output in a top-like fashion. Also aggregate the usage/allocation metrics at the NUMA node and host-level.

Main features

It can output as text on the console and write CSV files. The graph-vmtop.py script generates graphs from those CSV files (record with --csv <dir>).

This script can also be ran with a Prometheus exporter enabled, like so:

sudo ./vmtop.py --prometheus [host:port]

The host and port are optional, and will default to localhost:8000 if not specified.

Example output

Example output for the top 10 VMs experiencing the most vcpu steal per node:

$ sudo ./vmtop.py --vm --limit 10 --sort vcpu_steal
[...]
Node 0:
Name     PID     vcpu util   vcpu steal  vhost util  vhost steal emu util  emu steal disk read    disk write   rx           tx
Guest01  48642   141.73 %    32.86 %     0.30 %      0.06 %      0.57 %    0.48 %    0.00 MB/s    0.00 MB/s    0.00 MB/s    0.00 MB/s
Guest02  16830   219.07 %    29.74 %     28.45 %     22.13 %     0.54 %    1.30 %    0.00 MB/s    0.01 MB/s    2.49 MB/s    2.43 MB/s
Guest03  17152   119.61 %    27.87 %     13.89 %     16.31 %     0.48 %    0.12 %    0.00 MB/s    0.00 MB/s    1.45 MB/s    1.39 MB/s
Guest04  60782   52.90 %     16.70 %     0.79 %      0.75 %      0.61 %    0.19 %    0.00 MB/s    0.01 MB/s    0.02 MB/s    0.03 MB/s
Guest05  33077   46.47 %     12.69 %     2.02 %      1.82 %      3.11 %    0.97 %    0.00 MB/s    2.06 MB/s    0.24 MB/s    0.14 MB/s
Guest06  39435   41.70 %     10.01 %     17.36 %     12.85 %     0.98 %    0.08 %    0.00 MB/s    0.00 MB/s    0.27 MB/s    0.30 MB/s
Guest07  5196    26.49 %     9.28 %      0.03 %      0.00 %      0.51 %    0.09 %    0.00 MB/s    0.00 MB/s    0.00 MB/s    0.00 MB/s
Guest08  56822   55.63 %     8.77 %      9.33 %      5.61 %      0.53 %    0.17 %    0.00 MB/s    0.00 MB/s    0.30 MB/s    0.30 MB/s
Guest09  65751   36.59 %     8.54 %      6.26 %      3.42 %      0.76 %    0.06 %    0.08 MB/s    0.04 MB/s    0.18 MB/s    0.18 MB/s
Guest10  25320   26.61 %     8.44 %      0.06 %      0.00 %      5.30 %    2.72 %    0.00 MB/s    0.06 MB/s    0.00 MB/s    0.00 MB/s
  Node 0: vcpu util: 80.85%, vcpu steal: 6.49%, emulators util: 1.71%, emulators steal: 0.89%
  Node 0: 79 VMs (168 vcpus, 306.00 GB mem allocated, 231.98 GB mem used)
Node 1:
Name     PID     vcpu util   vcpu steal  vhost util  vhost steal emu util  emu steal disk read    disk write   rx           tx
Guest11  14506   29.49 %     0.70 %      0.00 %      0.00 %      0.45 %    0.01 %    0.00 MB/s    0.01 MB/s    0.00 MB/s    0.00 MB/s
Guest12  52580   28.69 %     0.63 %      4.55 %      0.26 %      0.60 %    0.08 %    0.12 MB/s    0.00 MB/s    0.16 MB/s    0.15 MB/s
Guest13  60864   36.45 %     0.56 %      0.06 %      0.00 %      4.25 %    0.06 %    0.00 MB/s    0.03 MB/s    0.00 MB/s    0.00 MB/s
Guest14  69426   64.98 %     0.54 %      11.06 %     0.79 %      0.09 %    0.00 %    0.00 MB/s    0.02 MB/s    4.20 MB/s    3.87 MB/s
Guest15  52138   52.45 %     0.39 %      10.66 %     0.64 %      0.75 %    0.02 %    0.22 MB/s    0.00 MB/s    0.43 MB/s    0.38 MB/s
Guest16  38308   57.05 %     0.25 %      12.03 %     0.93 %      1.18 %    0.03 %    0.51 MB/s    0.00 MB/s    0.47 MB/s    0.56 MB/s
Guest17  7700    11.87 %     0.25 %      0.08 %      0.00 %      4.16 %    0.05 %    0.00 MB/s    0.03 MB/s    0.00 MB/s    0.00 MB/s
Guest18  39542   39.46 %     0.24 %      7.61 %      0.51 %      0.77 %    0.02 %    0.16 MB/s    0.00 MB/s    0.27 MB/s    0.27 MB/s
Guest19  1381    49.03 %     0.24 %      9.01 %      0.72 %      0.76 %    0.05 %    0.25 MB/s    0.00 MB/s    0.35 MB/s    0.43 MB/s
Guest20  6945    36.15 %     0.24 %      6.42 %      0.45 %      0.77 %    0.04 %    0.21 MB/s    0.00 MB/s    0.23 MB/s    0.36 MB/s
  Node 1: vcpu util: 41.88%, vcpu steal: 0.20%, emulators util: 1.87%, emulators steal: 0.08%
  Node 1: 131 VMs (161 vcpus, 210.00 GB mem allocated, 193.42 GB mem used)

Dependencies

The tool currently depends on numastat being in the $PATH.

Besides that dependency, one design rule of this tool is that it should be easy to just download it and run without any additional setup. We use very common Python modules and the advanced features such as Prometheus and eBPF are optional.

This tool has been mostly tested on Ubuntu Bionic 18.04, but should be easy to run on other platforms.

The optional dependencies are:

  • python3-daemon for the the --daemon option
  • python3-bcc for the --vmexit option
  • python3-prometheus-client for the --prometheus option

Assumptions

The node-level information assumes a VM mostly runs where most of its memory is allocated, if a VM can float between NUMA nodes, the node-level information may not be accurate (and a warning will be shown). The VM-level data is accurate regardless of the pinning.

Feedback

This tool is a quick script to solve the issue of live monitoring resource allocation and usage by VMs. We plan to keep improving it over time.

Extras

In the extras folder, there are other ad-hoc tools for monitoring various performance aspects of KVM. The tools are in various states of maintenance, feel free to reach out if you have questions or suggestions for improvements. The features from those scripts may end up in vmtop at some point, but for now they are tested outside.

guesttime.bt

bpftrace tool to check statistically how long a vCPU spends inside the guest when it is scheduled in.

Core-scheduling and KVM

The core-sched-stats.py script ensures that the core scheduling feature works properly and accounts for the time spent by a vCPU in various scheduling modes (co-scheduled with idle, with a compatible task, or a foreign task).

This script works with perf trace recorded:

sudo perf record -e kvm:kvm_entry -e kvm:kvm_exit -e sched:sched_switch -e sched:sched_waking -o perf.data -a sleep 60

and can be converted to CTF like so (requires perf compiled with CTF support):

perf data convert --to-ctf=./ctf -i perf.data

If you see this message and the number of chunks is greater than 1 or 2, consider writing your perf.data to a ramdisk instead of your local disk:

Processed 7378132 events and lost 1 chunks!
Check IO/CPU overload!

It depends on Babeltrace compiled with the python library and Perf compiled with the CTF support. On bionic:

apt-get install libbabeltrace-dev libbabeltrace-ctf-dev python3-babeltrace babeltrace

Then rebuild perf so it will detect the new library.

In order to run kvm_co_sched_stats.py, the siblings list must be provided in a text file with the --topology flag. To collect this data, run this on the target HV:

for i in /sys/devices/system/cpu/cpu*/topology/thread_siblings_list; do cat $i; done > out.txt

vmtop's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vmtop's Issues

Porting core-sched-stats.py to BabelTrace2

Hi Julian,

May I email you?

One of the projects I am doing is using core-sched-stats.py for a testing framework for CoreSched with Vineeth Pillai.

I noticed that BabelTrace2 was released with better python bindings and I was thinking of porting core-sched-stats.py to it.

You can reach me at jbwyatt4 at gmail.com

empty cpuset.cpus

Dear all,
I tried to fire up your program on a Debian 12 using kernel 6.1.0-6-amd64.

I have one running VM, and my
/sys/fs/cgroup//machine.slice/machine-qemu\x2d1\x2dsanyi.scope/libvirt/emulator/cpuset.cpus

contains only a "\n".

the app raises an exception at vmtop.py:63

The error msg is:
Unexpected error on VM creation: (<class 'ValueError'>, ValueError("invalid literal for int() with base 10: '\n'")

Regards,

Mitya

Failed to parse guest name

Hii,
I am trying to install vmtop but when i run the command: # sudo ./vmtop.py --vm --limit 10 --sort vcpu_steal it shown just one vm and appear this errors:
Failed to parse guest name
Unexpected error on VM creation: (<class 'subprocess.CalledProcessError'>, CalledProcessError(1, ['pgrep', '852']), <traceback object at 0x7f9e7d30e388>)
where is the issue? @nanzhong @simondeziel @jdesfossez @jbwyatt4 @diunox

identify vcpu threads with QMP

The method we currently use to identify the vpcu threads in qemu only works with libvirt's approach.
Using QMP will be more generic:

query-cpus-fast

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.