Bug 643893

Summary: RFE: "virt-top -b" should be more like "top -b"
Product: Red Hat Enterprise Linux 6 Reporter: Sadique Puthen <sputhenp>
Component: virt-topAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: dallan, kxiong, llim, ltroan, moshiro
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: virt-top-1.0.4-3.7.el6 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 14:10:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 700575    

Description Sadique Puthen 2010-10-18 12:51:52 UTC
Description of problem:

Option "-b" as documented in man page of virt-top doesn't work as expected. It's expected to work like "top -b". There doesn't seem to be difference of the behavior between "virt-top -b" and its normal mode (virt-top).

Version-Release number of selected component (if applicable):

Red Hat Enterprise Linux Version Number: 6
Release Number: RC1
Architecture: x86_64
Kernel Version: kernel-2.6.32-71.el6.x86_64
Related Package Version: virt-top-1.0.4-3.1.el6.x86_64

How reproducible:

Always.

Steps to Reproduce:

1. Just run the virt-top with -b option and without -b option. There seems to be no difference.
  
Actual results:

"virt-top -b" doesn't work with batch mode. 

Expected results:

"virt-top -b" works with batch mode. 

Additional info:

Comment 6 Richard W.M. Jones 2011-01-06 10:47:01 UTC
This appears to work for me, both upstream and in RHEL 6.0.

The difference between virt-top and virt-top -b is that with
the -b option keypresses are ignored (except for ^C).

Try:

  virt-top -c test:///default

and hit the 'q' key.  virt-top quits immediately.

Then try:

  virt-top -c test:///default -b

and hit keys like 'q', 's' etc.  virt-top will ignore keypresses.
It still responds to ^C so you can exit, and when you exit you will
see the keys you pressed in the shell.

As I said, I have done this with both virt-top upstream (Fedora 15)
and virt-top in RHEL 6.0, and it works as expected in both.

Comment 10 Richard W.M. Jones 2011-01-24 14:45:15 UTC
I really think the best solution to this is to use:

  virt-top -b --script --csv /dev/stdout

The reason is that the output of 'top -b' is hard to parse accurately.
CSV is much better in this respect (see also:
https://bugzilla.redhat.com/show_bug.cgi?id=665817#c4
https://bugzilla.redhat.com/show_bug.cgi?id=665817#c5 )

With this option they'll get the following output:

# virt-top -b --script --csv /dev/stdout
Hostname,Time,Arch,Physical CPUs,Count,Running,Blocked,Paused,Shutdown,Shutoff,Crashed,Active,Inactive,%CPU,Total hardware memory (KB),Total memory (KB),Total guest memory (KB),Total CPU time (ns),Domain ID,Domain name,CPU (ns),%CPU,Block RDRQ,Block WRRQ,Net RXBY,Net TXBY
spin.home.annexia.org,14:44:09,x86_64,4,37,1,0,0,0,0,0,1,36,0.0,3832252,1048576,1048576,0,13,RHEL60x64,0.,0.,,,,
spin.home.annexia.org,14:44:12,x86_64,4,37,1,0,0,0,0,0,1,36,0.2,3832252,1048576,1048576,30000000,13,RHEL60x64,30000000.,0.244652070164,0,0,1418,2256
spin.home.annexia.org,14:44:15,x86_64,4,37,1,0,0,0,0,0,1,36,0.4,3832252,1048576,1048576,50000000,13,RHEL60x64,50000000.,0.41470537961,0,0,2002,2486
spin.home.annexia.org,14:44:18,x86_64,4,37,1,0,0,0,0,0,1,36,0.3,3832252,1048576,1048576,40000000,13,RHEL60x64,40000000.,0.324061824413,0,1,1974,2582
spin.home.annexia.org,14:44:21,x86_64,4,37,1,0,0,0,0,0,1,36,0.3,3832252,1048576,1048576,40000000,13,RHEL60x64,40000000.,0.331830683363,0,0,1272,2448
^C

Note that this already works with RHEL 6.0.

Comment 11 Richard W.M. Jones 2011-02-04 18:43:56 UTC
Fujitsu's Hiroyuki Kamezawa supplied the final patch
which adds --stream and --block-in-bytes options.

Upstream:
http://git.annexia.org/?p=virt-top.git;a=commitdiff;h=daf79631f3eff904ba89297148c4125ac7dfee39
http://git.annexia.org/?p=virt-top.git;a=commitdiff;h=dbef8dd3bf00417e75a12c851b053e49c9e1a79e

I have backported both of these to the virt-top-1.0.4-3.7.el6
package and we agree that this fixes the bug, although not
in exactly the way described.

To test use:

virt-top --stream
# output should go to stdout

virt-top --stream --block-in-bytes
# block I/O shown in bytes instead of requests

Also run virt-top normally and with the --block-in-bytes
options and try toggling using the 'b' key.

Brew build:
http://brewweb.devel.redhat.com/brew/taskinfo?taskID=3090650

Comment 14 koka xiong 2011-02-22 06:30:13 UTC
Verified with virt-top-1.0.4-3.7.el6.x86_64
1. virt-top --stream
virt-top time  13:02:44 Host kxiong x86_64 4/4CPU 3000MHz 7868MB 
   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM   TIME    NAME
    2 R    0    0    0    0  0.0 13.0   0:10.52 test
qqvirt-top time  13:02:47 Host kxiong x86_64 4/4CPU 3000MHz 7868MB 
   ID S RDRQ WRRQ RXBY TXBY %CPU %MEM   TIME    NAME
    2 R    0    0   52    0  0.2 13.0   0:10.55 test
2. virt-top --stream --block-in-bytes
virt-top time  13:01:36 Host kxiong x86_64 4/4CPU 800MHz 7868MB 
   ID S RDBY WRBY RXBY TXBY %CPU %MEM   TIME    NAME
    2 R    0    0    0    0  0.0 13.0   0:08.70 test
virt-top time  13:01:39 Host kxiong x86_64 4/4CPU 800MHz 7868MB 
   ID S RDBY WRBY RXBY TXBY %CPU %MEM   TIME    NAME
    2 R    0    0   52    0  0.3 13.0   0:08.74 test
3. virt-top -b --block-in-bytes
virt-top 13:12:06 - x86_64 4/4CPU 1800MHz 7868MB 1.3%
2 domains, 1 active, 1 running, 0 sleeping, 0 paused, 1 inactive D:0 O:0 X:0
CPU: 1.3%  Mem: 1024 MB (1024 MB by guests)

    ID S RDBY WRBY RXBY TXBY %CPU %MEM    TIME NAME  
    2 R    0    0   52    0  1.3 13.0   0:20.98 test

Comment 17 errata-xmlrpc 2011-05-19 14:10:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0720.html