Whamcloud - gitweb
LU-448 add lst stat --count
authorWally Wang <wang@cray.com>
Thu, 22 Sep 2011 23:19:28 +0000 (16:19 -0700)
committerOleg Drokin <green@whamcloud.com>
Sun, 23 Oct 2011 03:02:24 +0000 (23:02 -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: I46aa1de12ea8e6c2d5eafff8ce5c31d7d618c06f
Signed-off-by: Wally Wang <wang@cray.com>
Reviewed-on: http://review.whamcloud.com/1004
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: Oleg Drokin <green@whamcloud.com>
lnet/utils/lst.c

index 94cf02a..30428db 100644 (file)
@@ -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,