direct-io.hg
changeset 10512:e5cf18c05e8b
[XENTOP] Adds batch mode processing option (output to stdout)
to the xentop utility. It also adds the ability to specify the
number of iterations xentop should produce before exiting.
a) xentop -b
will output to stdout.
b) xentop -i <number>
will iterate <number> times and exit (option "n" is already used by
xentop. Hence the choice of "i"). This option can be used for both the
curses and batch modes.
From: Hariprasad Nellitheertha <mlisthari@gmail.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
to the xentop utility. It also adds the ability to specify the
number of iterations xentop should produce before exiting.
a) xentop -b
will output to stdout.
b) xentop -i <number>
will iterate <number> times and exit (option "n" is already used by
xentop. Hence the choice of "i"). This option can be used for both the
curses and batch modes.
From: Hariprasad Nellitheertha <mlisthari@gmail.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Wed Jun 28 10:22:13 2006 +0100 (2006-06-28) |
parents | 3c09a6b27b14 |
children | 7a7066ae2e77 |
files | tools/xenstat/xentop/xentop.1 tools/xenstat/xentop/xentop.c |
line diff
1.1 --- a/tools/xenstat/xentop/xentop.1 Wed Jun 28 10:03:24 2006 +0100 1.2 +++ b/tools/xenstat/xentop/xentop.1 Wed Jun 28 10:22:13 2006 +0100 1.3 @@ -25,6 +25,8 @@ 1.4 [\fB\-n\fR] 1.5 [\fB\-r\fR] 1.6 [\fB\-v\fR] 1.7 +[\fB\-b\fR] 1.8 +[\fB\-i\fRITERATIONS] 1.9 1.10 .SH DESCRIPTION 1.11 \fBxentop\fR displays information about the Xen system and domains, in a 1.12 @@ -50,6 +52,13 @@ repeat table header before each domain 1.13 .TP 1.14 \fB\-v\fR, \fB\-\-vcpus\fR 1.15 output VCPU data 1.16 +.TP 1.17 +\fB\-b\fR, \fB\-\-batch\fR 1.18 +output data in batch mode (to stdout) 1.19 +.TP 1.20 +\fB\-i\fR, \fB\-\-iterations\fR=\fIITERATIONS\fR 1.21 +maximum number of iterations xentop should produce before ending 1.22 + 1.23 1.24 .SH "INTERACTIVE COMMANDS" 1.25 All interactive commands are case-insensitive.
2.1 --- a/tools/xenstat/xentop/xentop.c Wed Jun 28 10:03:24 2006 +0100 2.2 +++ b/tools/xenstat/xentop/xentop.c Wed Jun 28 10:22:13 2006 +0100 2.3 @@ -153,6 +153,9 @@ xenstat_node *cur_node = NULL; 2.4 field_id sort_field = FIELD_DOMID; 2.5 unsigned int first_domain_index = 0; 2.6 unsigned int delay = 3; 2.7 +unsigned int batch = 0; 2.8 +unsigned int loop = 1; 2.9 +unsigned int iterations = 0; 2.10 int show_vcpus = 0; 2.11 int show_networks = 0; 2.12 int repeat_header = 0; 2.13 @@ -179,6 +182,8 @@ static void usage(const char *program) 2.14 "-n, --networks output vif network data\n" 2.15 "-r, --repeat-header repeat table header before each domain\n" 2.16 "-v, --vcpus output vcpu data\n" 2.17 + "-b, --batch output in batch mode, no user input accepted\n" 2.18 + "-i, --iterations number of iterations before exiting\n" 2.19 "\n" XENTOP_BUGSTO, 2.20 program); 2.21 return; 2.22 @@ -236,9 +241,15 @@ static void print(const char *fmt, ...) 2.23 { 2.24 va_list args; 2.25 2.26 - if(current_row() < lines()-1) { 2.27 + if (!batch) { 2.28 + if((current_row() < lines()-1)) { 2.29 + va_start(args, fmt); 2.30 + vw_printw(stdscr, fmt, args); 2.31 + va_end(args); 2.32 + } 2.33 + } else { 2.34 va_start(args, fmt); 2.35 - vw_printw(stdscr, fmt, args); 2.36 + vprintf(fmt, args); 2.37 va_end(args); 2.38 } 2.39 } 2.40 @@ -803,6 +814,7 @@ static void top(void) 2.41 do_network(domains[i]); 2.42 } 2.43 2.44 + if(!batch) 2.45 do_bottom_line(); 2.46 } 2.47 2.48 @@ -818,9 +830,11 @@ int main(int argc, char **argv) 2.49 { "repeat-header", no_argument, NULL, 'r' }, 2.50 { "vcpus", no_argument, NULL, 'v' }, 2.51 { "delay", required_argument, NULL, 'd' }, 2.52 + { "batch", no_argument, NULL, 'b' }, 2.53 + { "iterations", required_argument, NULL, 'i' }, 2.54 { 0, 0, 0, 0 }, 2.55 }; 2.56 - const char *sopts = "hVbnvd:"; 2.57 + const char *sopts = "hVbnvd:bi:"; 2.58 2.59 if (atexit(cleanup) != 0) 2.60 fail("Failed to install cleanup handler.\n"); 2.61 @@ -847,6 +861,13 @@ int main(int argc, char **argv) 2.62 case 'd': 2.63 delay = atoi(optarg); 2.64 break; 2.65 + case 'b': 2.66 + batch = 1; 2.67 + break; 2.68 + case 'i': 2.69 + iterations = atoi(optarg); 2.70 + loop = 0; 2.71 + break; 2.72 } 2.73 } 2.74 2.75 @@ -855,28 +876,40 @@ int main(int argc, char **argv) 2.76 if (xhandle == NULL) 2.77 fail("Failed to initialize xenstat library\n"); 2.78 2.79 - /* Begin curses stuff */ 2.80 - initscr(); 2.81 - start_color(); 2.82 - cbreak(); 2.83 - noecho(); 2.84 - nonl(); 2.85 - keypad(stdscr, TRUE); 2.86 - halfdelay(5); 2.87 - use_default_colors(); 2.88 - init_pair(1, -1, COLOR_YELLOW); 2.89 + if (!batch) { 2.90 + /* Begin curses stuff */ 2.91 + initscr(); 2.92 + start_color(); 2.93 + cbreak(); 2.94 + noecho(); 2.95 + nonl(); 2.96 + keypad(stdscr, TRUE); 2.97 + halfdelay(5); 2.98 + use_default_colors(); 2.99 + init_pair(1, -1, COLOR_YELLOW); 2.100 2.101 - do { 2.102 - gettimeofday(&curtime, NULL); 2.103 - if(ch != ERR || (curtime.tv_sec - oldtime.tv_sec) >= delay) { 2.104 - clear(); 2.105 - top(); 2.106 - oldtime = curtime; 2.107 - refresh(); 2.108 - } 2.109 - ch = getch(); 2.110 - } while (handle_key(ch)); 2.111 - 2.112 + do { 2.113 + gettimeofday(&curtime, NULL); 2.114 + if(ch != ERR || (curtime.tv_sec - oldtime.tv_sec) >= delay) { 2.115 + clear(); 2.116 + top(); 2.117 + oldtime = curtime; 2.118 + refresh(); 2.119 + if ((!loop) && !(--iterations)) 2.120 + break; 2.121 + } 2.122 + ch = getch(); 2.123 + } while (handle_key(ch)); 2.124 + } else { 2.125 + do { 2.126 + gettimeofday(&curtime, NULL); 2.127 + top(); 2.128 + sleep(delay); 2.129 + if ((!loop) && !(--iterations)) 2.130 + break; 2.131 + } while (1); 2.132 + } 2.133 + 2.134 /* Cleanup occurs in cleanup(), so no work to do here. */ 2.135 2.136 return 0;