From: Dan Mick Date: Tue, 25 Apr 2017 22:44:46 +0000 (-0700) Subject: ceph.in, pybind/ceph_daemon.py: add 'daemonperf list' X-Git-Tag: v12.0.3~71^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3fa8bb1219052429cf0c4fe56dfc7baf39ba1d5c;p=ceph.git ceph.in, pybind/ceph_daemon.py: add 'daemonperf list' respect statpats and priority; display as a PrettyTable Signed-off-by: Dan Mick --- diff --git a/src/ceph.in b/src/ceph.in index 62a8562aed81..11f044412f9d 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -276,10 +276,12 @@ ping Send simple presence/life test to a mon daemon {type.id|path} Same as --admin-daemon, but auto-find admin socket daemonperf {type.id | path} [stat-pats] [priority] [] [] +daemonperf {type.id | path} list [stat-pats] [priority] Get selected perf stats from daemon/admin socket Optional shell-glob comma-delim match string stat-pats Optional selection priority (can abbreviate name): critical, interesting, useful, noninteresting, debug + List shows a table of all available stats Run times (default forever), once per seconds (default 1) """, file=sys.stdout) @@ -636,12 +638,14 @@ def daemonperf(childargs, sockpath): Handle daemonperf command; returns errno or 0 daemonperf [priority string] [statpats] [interval] [count] + daemonperf list [statpats] """ interval = 1 count = None statpats = None priority = None + do_list = False def prio_from_name(arg): @@ -664,6 +668,10 @@ def daemonperf(childargs, sockpath): # consume and analyze non-numeric args while len(childargs) and not isnum(childargs[0]): arg = childargs.pop(0) + # 'list'? + if arg == 'list': + do_list = True; + continue; # prio? priority = prio_from_name(arg) if priority is not None: @@ -690,7 +698,11 @@ def daemonperf(childargs, sockpath): return errno.EINVAL count = int(arg) - DaemonWatcher(sockpath, statpats, priority).run(interval, count) + watcher = DaemonWatcher(sockpath, statpats, priority) + if do_list: + watcher.list() + else: + watcher.run(interval, count) return 0 diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index 827f7abf22a2..ae0ba8334eae 100755 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -18,6 +18,7 @@ import time from collections import OrderedDict from fcntl import ioctl from fnmatch import fnmatch +from prettytable import PrettyTable, HEADER from signal import signal, SIGWINCH from termios import TIOCGWINSZ @@ -89,6 +90,7 @@ def admin_socket(asok_path, cmd, format=''): def _gettermsize(): return struct.unpack('hhhh', ioctl(0, TIOCGWINSZ, 8*'\x00'))[0:2] + class Termsize(object): def __init__(self): @@ -381,3 +383,19 @@ class DaemonWatcher(object): except KeyboardInterrupt: return + + def list(self, ostr=sys.stdout): + """ + Show all selected stats with section, full name, nick, and prio + """ + table = PrettyTable(('section', 'name', 'nick', 'prio')) + table.align['section'] = 'l' + table.align['name'] = 'l' + table.align['nick'] = 'l' + table.align['prio'] = 'r' + self._load_schema() + for section_name, section_stats in self._stats.items(): + for name, nick in section_stats.items(): + prio = self._schema[section_name][name].get('priority') or 0 + table.add_row((section_name, name, nick, prio)) + ostr.write(table.get_string(hrules=HEADER) + '\n')