I want to know if there is a command virsh to display the cpu and memory consumption of each machine virtual. I created the virtual machine using KVM in ubuntu system.
-
At a given time or for a period of time? – dawud May 31 '16 at 18:20
-
Something like [virt-top](https://people.redhat.com/~rjones/virt-top/) ? – Martian Jun 01 '16 at 08:19
-
for a period of time – Nadya Nux Jun 01 '16 at 19:37
2 Answers
The command dommemstat
can give you memory stats for a specific domain and with domstats
you can get plenty of stats for all domains or just the specified. You can pass the parameter --cpu-total
to see the total in the moment.
First get a virsh interactive console by typing virsh
on your command line and then, once inside virsh's console, issue the following command:
virsh # domstats --cpu-total
The previous command will give you the CPU stats for all domains. If you have virt-manager you can see live some graphs and other nice stats, and if you want to collect them for a time you would need some other tool, I would recommend collectd and its 'virt' plugin
- 103
- 4
- 2,326
- 16
- 13
-
i tried `domstats --cpu-total` and ` dommenstat `, i got an error such as unknown command for ` domstats ` and and empty line for `dommenstat ` I'm not sure what is the problem – Nadya Nux Jun 01 '16 at 19:33
-
dont forget to always check the shell/program from which the command has been run... meaning that the command as per the answer was run from within virsh interactive interface. From bash, you would need to call `virsh domstats --cpu-total
` for specific domain or the simpler, without any specifics – OldFart Apr 02 '19 at 22:03
Nadya Nux: The command 'domstat --cpu-total' is executed within 'virsh' console, not from bash. So you have basicly two ways to do it.
First:
user@yourserver:~# virsh domstats --cpu-total
Second:
user@yourserver:~# virsh
virsh # domstats --cpu-total
Hope it helps better copy&paste to new readers as well :)