56b61a11099bf225cccaeefc55dd7eaef4b2d83c
[virt-top.git] / virt-top / virt-top.pod
1 =head1 NAME
2
3 virt-top - 'top'-like utility for virtualization stats
4
5 =head1 SUMMARY
6
7 virt-top [-options]
8
9 =head1 DESCRIPTION
10
11 virt-top is a L<top(1)>-like utility for showing stats of virtualized
12 domains.  Many keys and command line options are the same as for
13 ordinary I<top>.
14
15 It uses libvirt so it is capable of showing stats across a variety of
16 different virtualization systems.
17
18 =head1 OPTIONS
19
20 =over 4
21
22 =item B<-1>
23
24 Display physical CPUs by default (instead of domains).
25 When virt-top is running, use the I<1> key to toggle
26 between physical CPUs and domains display.
27
28 =item B<-2>
29
30 Display network interfaces by default (instead of domains).
31 When virt-top is running, use the I<2> key to toggle
32 between network interfaces and domains display.
33
34 =item B<-3>
35
36 Display block devices (virtual disks) by default (instead of domains).
37 When virt-top is running, use the I<3> key to toggle
38 between block devices and domains display.
39
40 =item B<-b>
41
42 Batch mode.  In this mode keypresses are ignored.
43
44 =item B<-c uri> or B<--connect uri>
45
46 Connect to the libvirt URI given.
47
48 To connect to QEMU/KVM you would normally do I<-c qemu:///system>
49
50 To connect to Xen on the same host, do I<-c xen:///>
51
52 To connect to libvirtd on a remote machine you would normally do
53 I<-c qemu://host/system>
54
55 If this option is not given then virt-top connects by default
56 to whatever is the default hypervisor for libvirt, although
57 this can be overridden by setting environment variables.
58
59 See the libvirt documentation at L<http://libvirt.org/uri.html>
60 for further information.
61
62 =item B<-d delay>
63
64 Set the delay between screen updates in seconds.
65 The default is 3.0 seconds.  You can change this
66 while virt-top is running by pressing either I<s> or I<d> key.
67
68 =item B<-n iterations>
69
70 Set the number of iterations to run.  The default
71 is to run continuously.
72
73 =item B<-o sort>
74
75 Set the sort order to one of:
76 B<cpu> (sort by %CPU used),
77 B<mem> (sort by total memory),
78 B<time> (sort by total time),
79 B<id> (sort by domain ID),
80 B<name> (sort by domain name),
81 B<netrx> (sort by network received bytes),
82 B<nettx> (sort by network transmitted bytes),
83 B<blockrdrq> (sort by block device [disk] read requests),
84 B<blockwrrq> (sort by block device [disk] write requests).
85
86 While virt-top is running you can change the sort
87 order using keys I<P> (cpu), I<M> (memory),
88 I<T> (total time), I<N> (domain ID),
89 I<F> (interactively select the sort field).
90
91 =item B<-s>
92
93 Secure mode.  Currently this does nothing.
94
95 =item B<--hist-cpu secs>
96
97 Set the time in seconds between updates of the historical
98 %CPU at the top right of the display.
99
100 =item B<--csv file.csv>
101
102 Write the statistics to file I<file.csv>.  First a header is written
103 showing the statistics being recorded in each column, then one line is
104 written for each screen update.  The CSV file can be loaded directly
105 by most spreadsheet programs.
106
107 Currently the statistics which this records vary between releases of
108 virt-top (but the column headers will stay the same, so you can use
109 those to process the CSV file).
110
111 Not every version of virt-top supports CSV output - it depends how the
112 program was compiled (see I<README> file in the source distribution
113 for details).
114
115 To save space you can compress your CSV files (if your shell supports
116 this feature, eg. I<bash>):
117
118  virt-top --csv >(gzip -9 > output.csv.gz)
119
120 You can use a similar trick to split the CSV file up.  In this example
121 the CSV file is split every 1000 lines into files called
122 I<output.csv.00>, I<output.csv.01> etc.
123
124  virt-top --csv >(split -d -l 1000 - output.csv.)
125
126 =item B<--no-csv-cpu>
127
128 Disable domain CPU stats in CSV output.
129
130 =item B<--no-csv-mem>
131
132 Disable domain memory stats in CSV output.
133
134 =item B<--no-csv-block>
135
136 Disable domain block device stats in CSV output.
137
138 =item B<--no-csv-net>
139
140 Disable domain network interface stats in CSV output.
141
142 =item B<--debug filename>
143
144 Send debug and error messages to I<filename>.
145 To send error messages to syslog you can do:
146
147  virt-top --debug >(logger -t virt-top)
148
149 See also REPORTING BUGS below.
150
151 =item B<--init-file filename>
152
153 Read I<filename> as the init file instead of the default which is
154 I<$HOME/.virt-toprc>.  See also INIT FILE below.
155
156 =item B<--no-init-file>
157
158 Do not read any init file.
159
160 =item B<--script>
161
162 Script mode.  There will be no user interface.  This is most useful
163 when used together with the I<--csv> and I<-n> options.
164
165 =item B<--stream>
166
167 Stream mode.  All output is sent to stdout.  This can be used from
168 shell scripts etc.  There is no user interface.
169
170 =item B<--block-in-bytes>
171
172 Show I/O statistics in Bytes. Default is shown in the number of Requests.
173
174 =item B<--end-time time>
175
176 The program will exit at the I<time> given.
177
178 The time may be given in one of the following formats:
179
180 =over 4
181
182 =item I<YYYY-MM-DD HH:MM:SS>
183
184 End time is the date and time given.
185
186 =item I<HH:MM:SS>
187
188 End time is the time given, today.
189
190 =item I<+HH:MM:SS>
191
192 End time is HH hours, MM minutes, SS seconds in the future (counted
193 from the moment that program starts).
194
195 =item I<+secs>
196
197 End time is I<secs> seconds in the future.
198
199 =back
200
201 For example to run the program for 3 minutes you could do:
202
203  virt-top --end-time +00:03:00
204
205 or:
206
207  virt-top --end-time +180
208
209 Not every version of virt-top supports this option - it depends how the
210 program was compiled (see I<README> file in the source distribution
211 for details).
212
213 =item B<--help>
214
215 Display usage summary.
216
217 =item B<--version>
218
219 Display version number and exit.
220
221 =back
222
223 =head1 KEYS
224
225 Note that keys are case sensitive.  For example use upper-case I<P>
226 (shift P) to sort by %CPU.  I<^> before a key means a Ctrl key, so
227 I<^L> is Ctrl L.
228
229 =over 4
230
231 =item I<space> or I<^L>
232
233 Updates the display.
234
235 =item I<q>
236
237 Quits the program.
238
239 =item I<h>
240
241 Displays help.
242
243 =item I<s> or I<d>
244
245 Change the delay between screen updates.
246
247 =item I<B>
248
249 Toggle Block I/O statistics so they are shown in either bytes or requests.
250
251 =item I<0> (number 0)
252
253 Show the normal list of domains display.
254
255 =item I<1> (number 1)
256
257 Toggle into showing physical CPUs.  If pressed
258 again toggles back to showing domains (the normal
259 display).
260
261 =item I<2>
262
263 Toggle into showing network interfaces.  If pressed
264 again toggles back to showing domains.
265
266 =item I<3>
267
268 Toggle into showing block devices (virtual disks).  If pressed again
269 toggles back to showing domains.
270
271 =item I<P>
272
273 Sort by %CPU.
274
275 =item I<M>
276
277 Sort by total memory.  Note that this shows the total memory
278 allocated to the guest, not the memory being used.
279
280 =item I<T>
281
282 Sort by total time.
283
284 =item I<N>
285
286 Sort by domain ID.
287
288 =item I<F>
289
290 Select the sort field interactively (there are other
291 sort fields you can choose using this key).
292
293 =item I<W>
294
295 This creates or overwrites the init file with the current settings.
296
297 This key is disabled if I<--no-init-file> was specified on the
298 command line or if I<overwrite-init-file false> is given in
299 the init file.
300
301 =back
302
303 =head1 INIT FILE
304
305 When virt-top starts up, it reads initial settings from the
306 file I<.virt-toprc> in the user's home directory.
307
308 The name of this file may be overridden using the I<--init-file
309 filename> command line option or may be disabled entirely using
310 I<--no-init-file>.
311
312 The init file has a simple format.  Blank lines and comments
313 beginning with I<#> are ignored.  Everything else is a set of
314 I<key value> pairs, described below.
315
316 =over 4
317
318 =item B<display> I<task|pcpu|block|net>
319
320 Sets the major display mode to one of I<task> (tasks, the
321 default), I<pcpu> (physical CPUs), I<block> (block devices),
322 or I<net> (network interfaces).
323
324 =item B<delay> I<secs>
325
326 Sets the delay between display updates in seconds.
327
328 =item B<hist-cpu> I<secs>
329
330 Sets the historical CPU delay in seconds.
331
332 =item B<iterations> I<n>
333
334 Sets the number of iterations to run before we exit.  Setting
335 this to I<-1> means to run continuously.
336
337 =item B<sort> I<cpu|mem|time|id|name|...>
338
339 Sets the sort order.  The option names are the same as for
340 the command line I<-o> option.
341
342 =item B<connect> I<uri>
343
344 Sets the default connection URI.
345
346 =item B<debug> I<filename>
347
348 Sets the default filename to use for debug and error messages.
349
350 =item B<csv> I<filename>
351
352 Enables CSV output to the named file.
353
354 =item B<csv-cpu> I<true|false>
355
356 Enable or disable domain CPU stats in CSV output.
357
358 =item B<csv-mem> I<true|false>
359
360 Enable or disable domain memory stats in CSV output.
361
362 =item B<csv-block> I<true|false>
363
364 Enable or disable domain block device stats in CSV output.
365
366 =item B<csv-net> I<true|false>
367
368 Enable or disable domain network interface stats in CSV output.
369
370 =item B<batch> I<true|false>
371
372 Sets batch mode.
373
374 =item B<secure> I<true|false>
375
376 Sets secure mode.
377
378 =item B<script> I<true|false>
379
380 Sets script mode.
381
382 =item B<stream> I<true|false>
383
384 Sets stream mode.
385
386 =item B<block-in-bytes> I<true|false>
387
388 Show block device statistics in bytes.
389
390 =item B<end-time> I<time>
391
392 Set the time at which the program exits.  See above for the
393 time formats supported.
394
395 =item B<overwrite-init-file> I<false>
396
397 If set to I<false> then the I<W> key will not overwrite the
398 init file.
399
400 =back
401
402 Note that in the current implementation, options specified in
403 the init file override options specified on the command line.
404 This is a bug and this behaviour may change in the future.
405
406 =head1 COLUMN HEADINGS
407
408 =over 4
409
410 =item B<%CPU>
411
412 Percentage of CPU used.  As with L<top(1)>, 100% means that
413 all physical CPUs are being fully used.
414
415 =item B<DEVICE>
416
417 The block device name.
418
419 =item B<DOMAIN>
420
421 =item B<NAME>
422
423 The name of the libvirt domain.
424
425 =item B<ID>
426
427 The libvirt domain ID.
428
429 =item B<INTERFACE>
430
431 The network interface name.
432
433 =item B<%MEM>
434
435 The percentage of host memory assigned to the guest.
436
437 =item B<PHYCPU>
438
439 The physical CPU.
440
441 =item B<RDBY>
442
443 Disk bytes read since last displayed.
444
445 =item B<RDRQ>
446
447 Disk read requests since last displayed.
448
449 =item B<RXBY>
450
451 Network bytes received since last displayed.
452
453 =item B<RXPK>
454
455 Network packets received since last displayed.
456
457 =item B<S>
458
459 The state of the domain, one of:
460
461 =over 4
462
463 =item B<?>
464
465 Unknown.
466
467 =item B<R>
468
469 Running.
470
471 =item B<S>
472
473 Blocked.
474
475 =item B<P>
476
477 Paused.
478
479 =item B<D>
480
481 =item B<O>
482
483 Shutdown.
484
485 =item B<X>
486
487 Crashed.
488
489 =back
490
491 =item B<TIME>
492
493 Total CPU time used.
494
495 =item B<TXBY>
496
497 Network bytes transmitted since last displayed.
498
499 =item B<TXPK>
500
501 Network packets transmitted since last displayed.
502
503 =item B<WRBY>
504
505 Disk bytes written since last displayed.
506
507 =item B<WRRQ>
508
509 Disk write requests since last displayed.
510
511 =back
512
513 =head1 NOTES
514
515 =head2 Block I/O statistics
516
517 This I/O value is the amount of I/O since the previous iteration
518 of virt-top. To calculate speed of I/O, you should divide
519 the number by delay secs.
520
521 =head2 NETWORK RX BYTES AND PACKETS
522
523 Libvirt/virt-top has no way to know that a packet transmitted to a
524 guest was received (eg. if the guest is not listening).  In the
525 network RX stats, virt-top reports the packets transmitted to the
526 guest, on the basis that the guest might receive them.
527
528 In particular this includes broadcast packets.  Because of the way
529 that Linux bridges work, if the guest is connected to a bridge, it
530 will probably see a steady "background noise" of RX packets even when
531 the network interface is idle or down.  These are caused by STP
532 packets generated by the bridge.
533
534 =head2 DEBUGGING LIBVIRT ISSUES
535
536 virt-top tries to turn libvirt errors into informative messages.
537 However if libvirt initialization fails then this is not possible.
538 Instead you will get an obscure error like:
539
540  libvir: error : Unknown failure
541  Fatal error: exception Libvirt.Virterror(...)
542
543 To see the cause of libvirt errors in more detail, enable libvirt
544 debugging by setting this environment variable:
545
546  export LIBVIRT_DEBUG=1
547
548 =head1 SEE ALSO
549
550 L<top(1)>,
551 L<virsh(1)>,
552 L<http://www.libvirt.org/ocaml/>,
553 L<http://www.libvirt.org/>,
554 L<http://people.redhat.com/~rjones/>,
555 L<http://caml.inria.fr/>
556
557 =head1 AUTHORS
558
559 Richard W.M. Jones <rjones @ redhat . com>
560
561 =head1 COPYRIGHT
562
563 (C) Copyright 2007-2012 Red Hat Inc., Richard W.M. Jones
564 http://libvirt.org/
565
566 This program is free software; you can redistribute it and/or modify
567 it under the terms of the GNU General Public License as published by
568 the Free Software Foundation; either version 2 of the License, or
569 (at your option) any later version.
570
571 This program is distributed in the hope that it will be useful,
572 but WITHOUT ANY WARRANTY; without even the implied warranty of
573 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
574 GNU General Public License for more details.
575
576 You should have received a copy of the GNU General Public License
577 along with this program; if not, write to the Free Software
578 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
579
580 =head1 REPORTING BUGS
581
582 Bugs can be viewed on the Red Hat Bugzilla page:
583 L<https://bugzilla.redhat.com/>.
584
585 If you find a bug in virt-top, please follow these steps to report it:
586
587 =over 4
588
589 =item 1. Check for existing bug reports
590
591 Go to L<https://bugzilla.redhat.com/> and search for similar bugs.
592 Someone may already have reported the same bug, and they may even
593 have fixed it.
594
595 =item 2. Capture debug and error messages
596
597 Run
598
599  virt-top --debug virt-top.log
600
601 and keep I<virt-top.log>.  It contains error messages which you
602 should submit with your bug report.
603
604 =item 3. Get version of virt-top and version of libvirt.
605
606 Use:
607
608  virt-top --version
609
610 If you can get the precise version of libvirt you are using
611 then that too is helpful.
612
613 =item 4. Submit a bug report.
614
615 Go to L<https://bugzilla.redhat.com/> and enter a new bug.
616 Please describe the problem in as much detail as possible.
617
618 Remember to include the version numbers (step 3) and the debug
619 messages file (step 2).
620
621 =item 5. Assign the bug to rjones @ redhat.com
622
623 Assign or reassign the bug to B<rjones @ redhat.com> (without the
624 spaces).  You can also send me an email with the bug number if you
625 want a faster response.
626
627 =back