From c1ee088aca96e8d3eb65dce416d7cdf47a48b01d Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Thu, 22 Apr 2021 12:59:02 +0800 Subject: [PATCH] cephfs-top: add read/write average io sizes support Fixes: https://tracker.ceph.com/issues/49811 Signed-off-by: Xiubo Li --- doc/man/8/cephfs-top.rst | 8 ++++++ src/tools/cephfs/top/cephfs-top | 44 +++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/doc/man/8/cephfs-top.rst b/doc/man/8/cephfs-top.rst index 936e02e201a27..654633c756803 100644 --- a/doc/man/8/cephfs-top.rst +++ b/doc/man/8/cephfs-top.rst @@ -79,6 +79,14 @@ Descriptions of fields total size of write IOs +.. describe:: raio + + average size of read IOs + +.. describe:: waio + + average size of write IOs + .. describe:: rsp speed of read IOs compared with the last refresh diff --git a/src/tools/cephfs/top/cephfs-top b/src/tools/cephfs/top/cephfs-top index 73bb411b7bed5..7ca3d284199bf 100755 --- a/src/tools/cephfs/top/cephfs-top +++ b/src/tools/cephfs/top/cephfs-top @@ -103,6 +103,13 @@ def calc_size(c): return round(c[1] / (1024 * 1024), 2) +# in MB +def calc_avg_size(c): + if c[0] == 0: + return 0.0 + return round(c[1] / (c[0] * 1024 * 1024), 2) + + # in MB/s def calc_speed(size, duration): if duration == 0: @@ -236,6 +243,15 @@ class FSTop(object): # return empty string for none type return '' + def avg_items(self, item): + if item == "READ_IO_SIZES": + return "raio" + if item == "WRITE_IO_SIZES": + return "waio" + else: + # return empty string for none type + return '' + def speed_items(self, item): if item == "READ_IO_SIZES": return "rsp" @@ -274,6 +290,17 @@ class FSTop(object): xp += nlen if item == "READ_IO_SIZES" or item == "WRITE_IO_SIZES": + # average io sizes + it = f'{self.avg_items(item)}{self.mtype(typ)}' + heading.append(it) + nlen = len(it) + len(ITEMS_PAD) + if item == "READ_IO_SIZES": + x_coord_map["READ_IO_AVG"] = (xp, nlen) + if item == "WRITE_IO_SIZES": + x_coord_map["WRITE_IO_AVG"] = (xp, nlen) + xp += nlen + + # io speeds it = f'{self.speed_items(item)}{self.speed_mtype(typ)}' heading.append(it) nlen = len(it) + len(ITEMS_PAD) @@ -354,6 +381,23 @@ class FSTop(object): self.mainw.addnstr(y_coord, coord[0], f'{calc_lat(m)}', hlen) elif typ == MetricType.METRIC_TYPE_SIZE: self.mainw.addnstr(y_coord, coord[0], f'{calc_size(m)}', hlen) + + # average io sizes + if remaining_hlen == 0: + return + if key == "READ_IO_SIZES": + coord = x_coord_map["READ_IO_AVG"] + elif key == "WRITE_IO_SIZES": + coord = x_coord_map["WRITE_IO_AVG"] + hlen = coord[1] - len(ITEMS_PAD) + hlen = min(hlen, remaining_hlen) + if remaining_hlen < coord[1]: + remaining_hlen = 0 + else: + remaining_hlen -= coord[1] + self.mainw.addnstr(y_coord, coord[0], f'{calc_avg_size(m)}', hlen) + + # io speeds if remaining_hlen == 0: return if key == "READ_IO_SIZES": -- 2.39.5