Hello
I thought it would be cool if virsh list behaves a bit more like
virt-manager or xm list because as a system-administrator i want to know
with one look what VMs are active, how much memory they commit and what
their runtime is.
I implemented this with the following patch which give such an sample
output.
What is your opinion and/or have i missed something?
[root@rr016 ~]# virsh list --all
Id Name Status Mem(kB) VCPUs Time(s)
---------------------------------------------------------------
1 rr019v3 laufend 1572864 2 15,3
2 rr019v4 laufend 1572864 2 11,7
- OpenSolaris08.11 ausschalten
- Win7b_64 ausschalten
--- a/src/virsh.c 2009-04-15 21:43:26.000000000 +0200
+++ b/src/virsh.c 2009-05-15 21:35:53.000000000 +0200
@@ -658,14 +658,16 @@
qsort(&names[0], maxname, sizeof(char*), namesorter);
}
}
- vshPrintExtra(ctl, "%3s %-20s %s\n", _("Id"),
_("Name"), _("State"));
- vshPrintExtra(ctl, "----------------------------------\n");
+ vshPrintExtra(ctl, "%3s %-20s %-15s %-8s %-5s %-7s\n", _("Id"),
_("Name"), _("State"),
+ _("Mem(kB)"), _("VCPUs"),
_("Time(s)"));
+ vshPrintExtra(ctl,
"---------------------------------------------------------------\n");
for (i = 0; i < maxid; i++) {
virDomainInfo info;
virDomainPtr dom = virDomainLookupByID(ctl->conn, ids[i]);
const char *state;
-
+ double cpuUsed = 0;
+
/* this kind of work with domains is not atomic operation */
if (!dom)
continue;
@@ -675,10 +677,19 @@
else
state = N_(vshDomainStateToString(info.state));
- vshPrint(ctl, "%3d %-20s %s\n",
+ if (info.cpuTime != 0) {
+ cpuUsed = info.cpuTime;
+
+ cpuUsed /= 1000000000.0;
+ }
+
+ vshPrint(ctl, "%3d %-20s %-15s %-8d %-5d %7.1f\n",
virDomainGetID(dom),
virDomainGetName(dom),
- state);
+ state,
+ virDomainGetMaxMemory(dom),
+ info.nrVirtCpu,
+ cpuUsed);
virDomainFree(dom);
}
for (i = 0; i < maxname; i++) {
Show replies by date
Daniel P. Berrange schrieb:
If you want a virt-manager like display of VMs, 'virt-top' is
the tool
to use
http://et.redhat.com/~rjones/virt-top/
Regards,
Daniel
Okay that gives the "xm top" but needs another tool to be installed.
Since it comes from epel one could install it though.
I gather extended info in virsh list is not wanted upstream then? I
would find it handy when being in virsh to issue a "list" and find the
commited memory, cpus of running VMs before firing up an additional VM.
This is a little help to prevent overcommiting on a host and no-one
could say he wasn't warned.
Gerrit