[virt-tools-list] [PATCH 0/3] virt-top stream mode

KAMEZAWA Hiroyuki kamezawa.hiroyu at jp.fujitsu.com
Thu Jan 27 00:11:55 UTC 2011


On Wed, 26 Jan 2011 11:39:19 +0000
"Richard W.M. Jones" <rjones at redhat.com> wrote:

> On Wed, Jan 26, 2011 at 01:41:31PM +0900, KAMEZAWA Hiroyuki wrote:
> > 
> > Now, virt-top has no option to dump information to stdout.
> > 
> > Considering usual top, I know some admins tend to do
> > 
> >  top -b | awk.... or his own script
> > 
> > to check his system.
> > 
> > I wondered --csv + --script + pipe by mknod may be able to give us
> > the same behavior but I think it can't, finally. Because
> > preparing pipe and delete it for each script is not good and
> > csv file format doesn't much enough for usual scripts which
> > use regular expressions and check lines one by one.
> > 
> > This patch adds --stream mode.
> > 
> > [Output example]
> > ==
> > [root at bluextal virt-top-1.0.5]# ./virt-top/virt-top --stream
> > virt-top time  13:40:40 Host bluextal x86_64 8/8CPU 1999MHz 24033MB
> >    ID S RDRQ WRRQ RXBY TXBY %CPU %MEM   TIME    NAME
> >     5 R    0    0    0    0  0.0 34.0 503:52.43 RHEL6
> > virt-top time  13:40:43 Host bluextal x86_64 8/8CPU 1999MHz 24033MB
> >    ID S RDRQ WRRQ RXBY TXBY %CPU %MEM   TIME    NAME
> >     5 R    0    0  104    0  0.7 34.0 503:52.60 RHEL6
> > ==
> > 
> > In this version, only supports "show domain" and "sort by ID".
> > 
> > To be honest, this is the 1st time for me to write program in ocaml.
> > I'm sorry if my code seems ugly or I misunderstand something.
> > 
> > Patches are divided into 3 patches.
> > 1/3 .... add --stream mode. with dummy function.
> > 2/3 .... fill dummy function to show domain data to stdout.
> > 3/3 .... documentation.
> 
> There's nothing wrong with the patch, but I wonder in general
> if you could use --csv /dev/stdout to do this instead:
> 
>   virt-top -b --script --csv /dev/stdout
> 
> See:
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=643893#c10
> 
> CSV is much more predictable to parse than plain text.  For an example
> of parsing the CSV output of virt-top, see:
> 
>   https://bugzilla.redhat.com/attachment.cgi?id=472065
> 
> Anyway let me know which is more suitable, because the patch does look
> OK and would be acceptable if there's a pressing reason for it.
> 

Thank you. my main motivation was description as I posted but there are
some other motivatons/reasons to write this patch, personally.

At first, I like 'top -b' or 'iotop -b' output and filter it by grep to
see change of data in console. I found virt-top's -b mode doesn't provide
such mode for pipe, so, I tries to add it.
csv data isn't easy for parse in eyes.

Next, --csv mode does show header only once, at the start of it. So, if
the number of domain increases, there will be domains which have no
header. But considering csv file format, it seems it's right behvaior
and the user will have to adjust header by himself.
So, I felt it seems natual to add a mode one-line-for-one-domain mode.

And, usual system admins, my customers, tends not to be good at parsing csv
because they did parsing 'top -b' or 'ps -elf' output by grep and awk or perl
for long time since SunOS age. This patch's mode will be easier for them.

Thank you for review.

Regards,
-Kame













> Rich.
> 
> -- 
> Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
> virt-top is 'top' for virtual machines.  Tiny program with many
> powerful monitoring features, net stats, disk stats, logging, etc.
> http://et.redhat.com/~rjones/virt-top
> 




More information about the virt-tools-list mailing list