From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Charles Arnold <carnold@suse.com>, xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] xentop: Dynamically expand some columns
Date: Thu, 2 Oct 2014 17:10:20 +0100 [thread overview]
Message-ID: <542D78EC.9030505@citrix.com> (raw)
In-Reply-To: <542D21B202000091000DBE23@prv-mh.provo.novell.com>
On 02/10/14 16:58, Charles Arnold wrote:
> Allow certain xentop columns to automatically expand as the amount
> of data reported gets larger. The columns allowed to expand are:
>
> NETTX(k), NETRX(k), VBD_RD, VBD_WR, VBD_RSECT, VBD_WSECT
>
> Author: Markus Hauschild <Markus.Hauschild@rz.uni-regensburg.de>
> Signed-off-by: Charles Arnold <carnold@suse.com>
In principle, very nice. (I have wanted to see about doing this for a
while now, but very far down the todo list)
How about the NAME field? 9 characters isn't enough for some people.
~Andrew
>
> diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c
> index dd11927..d087665 100644
> --- a/tools/xenstat/xentop/xentop.c
> +++ b/tools/xenstat/xentop/xentop.c
> @@ -27,6 +27,7 @@
>
> #include <ctype.h>
> #include <errno.h>
> +#include <math.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <stdarg.h>
> @@ -127,7 +128,8 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2);
> static void print_vbd_rsect(xenstat_domain *domain);
> static int compare_vbd_wsect(xenstat_domain *domain1, xenstat_domain *domain2);
> static void print_vbd_wsect(xenstat_domain *domain);
> -
> +static void reset_field_widths(void);
> +static void adjust_field_widths(xenstat_domain *domain);
>
> /* Section printing functions */
> static void do_summary(void);
> @@ -623,7 +625,7 @@ static int compare_net_tx(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total network tx bytes statistic */
> static void print_net_tx(xenstat_domain *domain)
> {
> - print("%8llu", tot_net_bytes(domain, FALSE)/1024);
> + print("%*llu", fields[FIELD_NET_TX-1].default_width, tot_net_bytes(domain, FALSE)/1024);
> }
>
> /* Compares number of total network rx bytes of two domains, returning -1,0,1
> @@ -637,7 +639,7 @@ static int compare_net_rx(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total network rx bytes statistic */
> static void print_net_rx(xenstat_domain *domain)
> {
> - print("%8llu", tot_net_bytes(domain, TRUE)/1024);
> + print("%*llu", fields[FIELD_NET_RX-1].default_width, tot_net_bytes(domain, TRUE)/1024);
> }
>
> /* Gets number of total network bytes statistic, if rx true, then rx bytes
> @@ -705,7 +707,7 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total VBD READ requests statistic */
> static void print_vbd_rd(xenstat_domain *domain)
> {
> - print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_RD));
> + print("%*llu", fields[FIELD_VBD_RD-1].default_width, tot_vbd_reqs(domain, FIELD_VBD_RD));
> }
>
> /* Compares number of total VBD WRITE requests of two domains,
> @@ -719,7 +721,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total VBD WRITE requests statistic */
> static void print_vbd_wr(xenstat_domain *domain)
> {
> - print("%8llu", tot_vbd_reqs(domain, FIELD_VBD_WR));
> + print("%*llu", fields[FIELD_VBD_WR-1].default_width, tot_vbd_reqs(domain, FIELD_VBD_WR));
> }
>
> /* Compares number of total VBD READ sectors of two domains,
> @@ -733,7 +735,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total VBD READ sectors statistic */
> static void print_vbd_rsect(xenstat_domain *domain)
> {
> - print("%10llu", tot_vbd_reqs(domain, FIELD_VBD_RSECT));
> + print("%*llu", fields[FIELD_VBD_RSECT-1].default_width, tot_vbd_reqs(domain, FIELD_VBD_RSECT));
> }
>
> /* Compares number of total VBD WRITE sectors of two domains,
> @@ -747,7 +749,7 @@ static int compare_vbd_wsect(xenstat_domain *domain1, xenstat_domain *domain2)
> /* Prints number of total VBD WRITE sectors statistic */
> static void print_vbd_wsect(xenstat_domain *domain)
> {
> - print("%10llu", tot_vbd_reqs(domain, FIELD_VBD_WSECT));
> + print("%*llu", fields[FIELD_VBD_WSECT-1].default_width, tot_vbd_reqs(domain, FIELD_VBD_WSECT));
> }
>
>
> @@ -806,6 +808,48 @@ static void print_ssid(xenstat_domain *domain)
> print("%4u", xenstat_domain_ssid(domain));
> }
>
> +/* Resets default_width for fields with potentially large numbers */
> +void reset_field_widths(void)
> +{
> + fields[FIELD_NET_TX-1].default_width = 8;
> + fields[FIELD_NET_RX-1].default_width = 8;
> + fields[FIELD_VBD_RD-1].default_width = 8;
> + fields[FIELD_VBD_WR-1].default_width = 8;
> + fields[FIELD_VBD_RSECT-1].default_width = 10;
> + fields[FIELD_VBD_WSECT-1].default_width = 10;
> +}
> +
> +/* Adjusts default_width for fields with potentially large numbers */
> +void adjust_field_widths(xenstat_domain *domain)
> +{
> + unsigned int length;
> +
> + length = (unsigned int)(log10(tot_net_bytes(domain, FALSE)/1024) + 1);
> + if (length > fields[FIELD_NET_TX-1].default_width)
> + fields[FIELD_NET_TX-1].default_width = length;
> +
> + length = (unsigned int)(log10(tot_net_bytes(domain, TRUE)/1024) + 1);
> + if (length > fields[FIELD_NET_RX-1].default_width)
> + fields[FIELD_NET_RX-1].default_width = length;
> +
> + length = (unsigned int)(log10(tot_vbd_reqs(domain, FIELD_VBD_RD)) + 1);
> + if (length > fields[FIELD_VBD_RD-1].default_width)
> + fields[FIELD_VBD_RD-1].default_width = length;
> +
> + length = (unsigned int)(log10(tot_vbd_reqs(domain, FIELD_VBD_WR)) + 1);
> + if (length > fields[FIELD_VBD_WR-1].default_width)
> + fields[FIELD_VBD_WR-1].default_width = length;
> +
> + length = (unsigned int)(log10(tot_vbd_reqs(domain, FIELD_VBD_RSECT)) + 1);
> + if (length > fields[FIELD_VBD_RSECT-1].default_width)
> + fields[FIELD_VBD_RSECT-1].default_width = length;
> +
> + length = (unsigned int)(log10(tot_vbd_reqs(domain, FIELD_VBD_WSECT)) + 1);
> + if (length > fields[FIELD_VBD_WSECT-1].default_width)
> + fields[FIELD_VBD_WSECT-1].default_width = length;
> +}
> +
> +
> /* Section printing functions */
> /* Prints the top summary, above the domain table */
> void do_summary(void)
> @@ -1088,6 +1132,12 @@ static void top(void)
> if(first_domain_index >= num_domains)
> first_domain_index = num_domains-1;
>
> + /* Adjust default_width for fields with potentially large numbers */
> + reset_field_widths();
> + for (i = first_domain_index; i < num_domains; i++) {
> + adjust_field_widths(domains[i]);
> + }
> +
> for (i = first_domain_index; i < num_domains; i++) {
> if(!batch && current_row() == lines()-1)
> break;
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-10-02 16:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-02 15:58 [PATCH] xentop: Dynamically expand some columns Charles Arnold
2014-10-02 16:10 ` Andrew Cooper [this message]
2014-10-02 16:25 ` Charles Arnold
2014-10-02 17:05 ` Konrad Rzeszutek Wilk
2014-10-02 17:27 ` Charles Arnold
2014-10-03 9:00 ` Ian Campbell
2014-10-03 13:34 ` Konrad Rzeszutek Wilk
2014-10-13 17:12 ` Charles Arnold
2014-10-13 20:09 ` Konrad Rzeszutek Wilk
2014-10-16 13:56 ` Charles Arnold
-- strict thread matches above, loose matches on Subject: below --
2014-10-29 11:24 Markus Hauschild
2014-11-04 10:08 ` Ian Campbell
2014-11-04 17:10 ` Konrad Rzeszutek Wilk
2014-11-05 10:59 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=542D78EC.9030505@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=carnold@suse.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.