]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-top: allow configurable stats refresh interval
authorRachana Patel <racpatel@redhat.com>
Tue, 23 Mar 2021 04:40:56 +0000 (04:40 +0000)
committerRachana Patel <racpatel@redhat.com>
Thu, 25 Mar 2021 17:39:54 +0000 (17:39 +0000)
Signed-off-by: Rachana Patel <racpatel@redhat.com>
(cherry picked from commit abd4ae9f9b1bdf1f4d7ee7b10baa9c8ec03303fc)

doc/cephfs/cephfs-top.rst
src/tools/cephfs/top/cephfs-top

index 200ca1504f8b1559b2ac910476b686fdcc7c3571..47e80df9d2f14a4062628cc012557a337cb553f7 100644 (file)
@@ -70,6 +70,12 @@ By default, `cephfs-top` connects to cluster name `ceph`. To use a non-default c
 
   $ cephfs-top --cluster <cluster>
 
+`cephfs-top` refreshes stats every second by default. To chose a different refresh interval use::
+
+  $ cephfs-top -d <seconds>
+
+Interval should be greater or equal to 0.5 second. Fractional seconds are honoured.
+
 Sample screenshot running `cephfs-top` with 2 clients:
 
 .. image:: cephfs-top.png
index f5a74b8264544045b0f419ce6909acac8d925743..917057cd873e9b3c3482678b0fb32690827bd86d 100755 (executable)
@@ -37,6 +37,9 @@ FS_TOP_SUPPORTED_VER = 1
 
 ITEMS_PAD_LEN = 1
 ITEMS_PAD = "  " * ITEMS_PAD_LEN
+DEFAULT_REFRESH_INTERVAL = 1
+# min refresh interval allowed
+MIN_REFRESH_INTERVAL = 0.5
 
 # metadata provided by mgr/stats
 FS_TOP_MAIN_WINDOW_COL_CLIENT_ID = "CLIENT_ID"
@@ -98,6 +101,7 @@ class FSTop(object):
         self.client_name = args.id
         self.cluster_name = args.cluster
         self.conffile = args.conffile
+        self.refresh_interval_secs = args.delay
 
     def handle_signal(self, signum, _):
         self.stop = True
@@ -279,10 +283,17 @@ class FSTop(object):
                 self.refresh_main_window(x_coord_map, stats_json)
             self.header.refresh()
             self.mainw.refresh()
-            time.sleep(1)
+            time.sleep(self.refresh_interval_secs)
 
 
 if __name__ == '__main__':
+    def float_greater_than(x):
+        value = float(x)
+        if value < MIN_REFRESH_INTERVAL:
+            raise argparse.ArgumentTypeError(f'{value} should be greater than '
+                                             f'{MIN_REFRESH_INTERVAL}')
+        return value
+
     parser = argparse.ArgumentParser(description='Ceph Filesystem top utility')
     parser.add_argument('--cluster', nargs='?', const='ceph', default='ceph',
                         help='Ceph cluster to connect (defualt: ceph)')
@@ -292,6 +303,10 @@ if __name__ == '__main__':
                         help='Path to cluster configuration file')
     parser.add_argument('--selftest', dest='selftest', action='store_true',
                         help='run in selftest mode')
+    parser.add_argument('-d', '--delay', nargs='?', default=DEFAULT_REFRESH_INTERVAL,
+                        type=float_greater_than, help='Interval to refresh data '
+                        f'(default: {DEFAULT_REFRESH_INTERVAL})')
+
     args = parser.parse_args()
     err = False
     ft = FSTop(args)