cephfs-top: allow configurable stats refresh interval

Signed-off-by: Rachana Patel <racpatel@redhat.com>
This commit is contained in:
Rachana Patel 2021-03-23 04:40:56 +00:00
parent fe9454722a
commit abd4ae9f9b
2 changed files with 22 additions and 1 deletions

View 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

View File

@ -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)