summaryrefslogtreecommitdiffstats
path: root/src/tools/cephfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/cephfs')
-rwxr-xr-xsrc/tools/cephfs/shell/cephfs-shell15
-rwxr-xr-xsrc/tools/cephfs/top/cephfs-top27
2 files changed, 31 insertions, 11 deletions
diff --git a/src/tools/cephfs/shell/cephfs-shell b/src/tools/cephfs/shell/cephfs-shell
index 58884a275..9df4f71d8 100755
--- a/src/tools/cephfs/shell/cephfs-shell
+++ b/src/tools/cephfs/shell/cephfs-shell
@@ -16,13 +16,14 @@ import shlex
import stat
import errno
-from distutils.version import LooseVersion
+from pkg_resources import packaging # type: ignore
from cmd2 import Cmd
from cmd2 import __version__ as cmd2_version
# XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
# Cmd2ArgparseError
-if LooseVersion(cmd2_version) >= LooseVersion("1.0.1"):
+Version = packaging.version.Version
+if Version(cmd2_version) >= Version("1.0.1"):
from cmd2.exceptions import Cmd2ArgparseError
else:
# HACK: so that we don't have check for version everywhere
@@ -1699,11 +1700,11 @@ def read_shell_conf(shell, shell_conf_file):
sec = 'cephfs-shell'
opts = []
- if LooseVersion(cmd2_version) >= LooseVersion("0.10.0"):
+ if Version(cmd2_version) >= Version("0.10.0"):
for attr in shell.settables.keys():
opts.append(attr)
else:
- if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
+ if Version(cmd2_version) <= Version("0.9.13"):
# hardcoding options for 0.7.9 because -
# 1. we use cmd2 v0.7.9 with teuthology and
# 2. there's no way distinguish between a shell setting and shell
@@ -1712,7 +1713,7 @@ def read_shell_conf(shell, shell_conf_file):
'continuation_prompt', 'debug', 'echo', 'editor',
'feedback_to_output', 'locals_in_py', 'prompt', 'quiet',
'timing']
- elif LooseVersion(cmd2_version) >= LooseVersion("0.9.23"):
+ elif Version(cmd2_version) >= Version("0.9.23"):
opts.append('allow_style')
# no equivalent option was defined by cmd2.
else:
@@ -1767,7 +1768,7 @@ def manage_args():
args.exe_and_quit = False # Execute and quit, don't launch the shell.
if args.batch:
- if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
+ if Version(cmd2_version) <= Version("0.9.13"):
args.commands = ['load ' + args.batch, ',quit']
else:
args.commands = ['run_script ' + args.batch, ',quit']
@@ -1812,7 +1813,7 @@ def execute_cmds_and_quit(args):
# value to indicate whether the execution of the commands should stop, but
# since 0.9.7 it returns the return value of do_* methods only if it's
# not None. When it is None it returns False instead of None.
- if LooseVersion(cmd2_version) <= LooseVersion("0.9.6"):
+ if Version(cmd2_version) <= Version("0.9.6"):
stop_exec_val = None
else:
stop_exec_val = False
diff --git a/src/tools/cephfs/top/cephfs-top b/src/tools/cephfs/top/cephfs-top
index b39e815fa..ff02e2dd4 100755
--- a/src/tools/cephfs/top/cephfs-top
+++ b/src/tools/cephfs/top/cephfs-top
@@ -168,8 +168,8 @@ class FSTopBase(object):
return False
return True
- def __build_clients(self, fs):
- fs_meta = self.dump_json.setdefault(fs, {})
+ def __build_clients(self, fs, clients_json):
+ fs_meta = clients_json.setdefault(fs, {})
fs_key = self.stats_json[GLOBAL_METRICS_KEY].get(fs, {})
clients = fs_key.keys()
for client_id in clients:
@@ -249,13 +249,32 @@ class FSTopBase(object):
self.stats_json = self.perf_stats_query()
if fs_name: # --dumpfs
if fs_name in fs_list:
- self.__build_clients(fs_name)
+ self.__build_clients(fs_name, clients_json=self.dump_json)
else:
sys.stdout.write(f"Filesystem {fs_name} not available\n")
return
else: # --dump
+ num_clients = num_mounts = num_kclients = num_libs = 0
+ for fs_name in fs_list:
+ client_metadata = self.stats_json[CLIENT_METADATA_KEY].get(fs_name, {})
+ client_cnt = len(client_metadata)
+ if client_cnt:
+ num_clients = num_clients + client_cnt
+ num_mounts = num_mounts + len(
+ [client for client, metadata in client_metadata.items() if
+ CLIENT_METADATA_MOUNT_POINT_KEY in metadata
+ and metadata[CLIENT_METADATA_MOUNT_POINT_KEY] != 'N/A'])
+ num_kclients = num_kclients + len(
+ [client for client, metadata in client_metadata.items() if
+ "kernel_version" in metadata])
+ num_libs = num_clients - (num_mounts + num_kclients)
+ self.dump_json.update({'date': datetime.now().ctime()})
+ client_count = self.dump_json.setdefault("client_count", {})
+ client_count.update({'total_clients': num_clients, 'fuse': num_mounts,
+ 'kclient': num_kclients, 'libcephfs': num_libs})
+ clients_json = self.dump_json.setdefault("filesystems", {})
for fs in fs_list:
- self.__build_clients(fs)
+ self.__build_clients(fs, clients_json)
sys.stdout.write(json.dumps(self.dump_json))
sys.stdout.write("\n")