From 97f64c2e4e193a949deb77acb53eef2b81d3a0b0 Mon Sep 17 00:00:00 2001 From: Wally Wang Date: Thu, 22 Sep 2011 16:19:28 -0700 Subject: [PATCH] LU-448 add lst stat --count This adds lst stat --count, making it easier to script up data collection for performance tests. The patch is from Oracle bug 22638 attachment 33001 Change-Id: I46aa1de12ea8e6c2d5eafff8ce5c31d7d618c06f Signed-off-by: Wally Wang Reviewed-on: http://review.whamcloud.com/1004 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Liang Zhen Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lnet/utils/lst.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lnet/utils/lst.c b/lnet/utils/lst.c index 94cf02a..30428db 100644 --- a/lnet/utils/lst.c +++ b/lnet/utils/lst.c @@ -1785,6 +1785,7 @@ jt_lst_stat(int argc, char **argv) int optidx = 0; int timeout = 5; /* default timeout, 5 sec */ int delay = 5; /* default delay, 5 sec */ + int count = -1; /* run forever */ int lnet = 1; /* lnet stat by default */ int bwrt = 0; int rdwr = 0; @@ -1797,6 +1798,7 @@ jt_lst_stat(int argc, char **argv) { {"timeout", required_argument, 0, 't' }, {"delay" , required_argument, 0, 'd' }, + {"count" , required_argument, 0, 'o' }, {"lnet" , no_argument, 0, 'l' }, {"rpc" , no_argument, 0, 'c' }, {"bw" , no_argument, 0, 'b' }, @@ -1828,6 +1830,9 @@ jt_lst_stat(int argc, char **argv) case 'd': delay = atoi(optarg); break; + case 'o': + count = atoi(optarg); + break; case 'l': lnet = 1; break; @@ -1883,6 +1888,15 @@ jt_lst_stat(int argc, char **argv) return -1; } + if (count < -1) { + fprintf(stderr, "Invalid count value\n"); + return -1; + } + + /* extra count to get first data point */ + if (count != -1) + count++; + CFS_INIT_LIST_HEAD(&head); while (optind < argc) { @@ -1893,7 +1907,7 @@ jt_lst_stat(int argc, char **argv) cfs_list_add_tail(&srp->srp_link, &head); } - while (1) { + do { time_t now = time(NULL); if (now - last < delay) { @@ -1921,7 +1935,10 @@ jt_lst_stat(int argc, char **argv) } idx = 1 - idx; - } + + if (count > 0) + count--; + } while (count == -1 || count > 0); out: while (!cfs_list_empty(&head)) { @@ -3139,7 +3156,7 @@ static command_t lst_cmdlist[] = { "Usage: lst list_group [--active] [--busy] [--down] [--unknown] GROUP ..." }, {"stat", jt_lst_stat, NULL, "Usage: lst stat [--bw] [--rate] [--read] [--write] [--max] [--min] [--avg] " - " [--timeout #] [--delay #] GROUP [GROUP]" }, + " [--timeout #] [--delay #] [--count #] GROUP [GROUP]" }, {"show_error", jt_lst_show_error, NULL, "Usage: lst show_error NAME | IDS ..." }, {"add_batch", jt_lst_add_batch, NULL, -- 1.8.3.1