diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-06-13 11:13:11 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-06-13 11:13:11 +0100 |
commit | f63ebd213eaa5eb45139cf23390d23f6743ec27b (patch) | |
tree | c0340ba01876a9253ba71d99853f1489da5f91b9 /tools/xenstat/xentop | |
parent | 599054e79261efbe3254eb4884018a22dd003ba7 (diff) | |
download | xen-f63ebd213eaa5eb45139cf23390d23f6743ec27b.tar.gz xen-f63ebd213eaa5eb45139cf23390d23f6743ec27b.tar.bz2 xen-f63ebd213eaa5eb45139cf23390d23f6743ec27b.zip |
xentop: Fix -b option (batch mode).
Some curses libraries don't work with xentop in batch mode, avoid
those calls. Avoid the over-verbose summary lines when batch mode is
requested.
Signed-off-by: Gary Pennington <gary.pennington@sun.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'tools/xenstat/xentop')
-rw-r--r-- | tools/xenstat/xentop/xentop.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c index a848420aec..92d4eb217a 100644 --- a/tools/xenstat/xentop/xentop.c +++ b/tools/xenstat/xentop/xentop.c @@ -290,12 +290,24 @@ static void print(const char *fmt, ...) } } +static void xentop_attron(int attr) +{ + if (!batch) + attron(attr); +} + +static void xentop_attroff(int attr) +{ + if (!batch) + attroff(attr); +} + /* Print a string with the given attributes set. */ static void attr_addstr(int attr, const char *str) { - attron(attr); + xentop_attron(attr); addstr((curses_str_t)str); - attroff(attr); + xentop_attroff(attr); } /* Handle setting the delay from the user-supplied value in prompt_val */ @@ -780,18 +792,18 @@ void do_header(void) field_id i; /* Turn on REVERSE highlight attribute for headings */ - attron(A_REVERSE); + xentop_attron(A_REVERSE); for(i = 0; i < NUM_FIELDS; i++) { - if(i != 0) + if (i != 0) print(" "); /* The BOLD attribute is turned on for the sort column */ - if(i == sort_field) - attron(A_BOLD); + if (i == sort_field) + xentop_attron(A_BOLD); print("%*s", fields[i].default_width, fields[i].header); - if(i == sort_field) - attroff(A_BOLD); + if (i == sort_field) + xentop_attroff(A_BOLD); } - attroff(A_REVERSE); + xentop_attroff(A_REVERSE); print("\n"); } @@ -838,14 +850,14 @@ void do_bottom_line(void) void do_domain(xenstat_domain *domain) { unsigned int i; - for(i = 0; i < NUM_FIELDS; i++) { - if(i != 0) + for (i = 0; i < NUM_FIELDS; i++) { + if (i != 0) print(" "); - if(i == sort_field) - attron(A_BOLD); + if (i == sort_field) + xentop_attron(A_BOLD); fields[i].print(domain); - if(i == sort_field) - attroff(A_BOLD); + if (i == sort_field) + xentop_attroff(A_BOLD); } print("\n"); } @@ -956,7 +968,8 @@ static void top(void) fail("Failed to retrieve statistics from libxenstat\n"); /* dump summary top information */ - do_summary(); + if (!batch) + do_summary(); /* Count the number of domains for which to report data */ num_domains = xenstat_node_num_domains(cur_node); @@ -976,7 +989,7 @@ static void top(void) first_domain_index = num_domains-1; for (i = first_domain_index; i < num_domains; i++) { - if(current_row() == lines()-1) + if(!batch && current_row() == lines()-1) break; if (i == first_domain_index || repeat_header) do_header(); @@ -989,8 +1002,8 @@ static void top(void) do_vbd(domains[i]); } - if(!batch) - do_bottom_line(); + if (!batch) + do_bottom_line(); free(domains); } |