Whamcloud - gitweb
LU-448 add lst stat --count
authorWally Wang <wang@cray.com>
Wed, 31 Aug 2011 00:53:52 +0000 (17:53 -0700)
committerJohann Lombardi <johann@whamcloud.com>
Wed, 21 Sep 2011 12:59:47 +0000 (08:59 -0400)
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: Ic60e6226ce85ebbc2d314e41c7e85ba5879ea64e
Signed-off-by: Wally Wang <wang@cray.com>
Reviewed-on: http://review.whamcloud.com/1312
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Liang Zhen <liang@whamcloud.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lnet/utils/lst.c

index fb30521..38ca68b 100644 (file)
@@ -1786,6 +1786,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;
@@ -1798,6 +1799,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' },
@@ -1829,6 +1831,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;
@@ -1884,6 +1889,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) {
@@ -1894,7 +1908,7 @@ jt_lst_stat(int argc, char **argv)
                 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 (!list_empty(&head)) {
@@ -3136,7 +3153,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,