]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.in, pybind/ceph_daemon.py: add 'daemonperf list'
authorDan Mick <dan.mick@redhat.com>
Tue, 25 Apr 2017 22:44:46 +0000 (15:44 -0700)
committerDan Mick <dan.mick@redhat.com>
Tue, 25 Apr 2017 23:19:02 +0000 (16:19 -0700)
respect statpats and priority; display as a PrettyTable

Signed-off-by: Dan Mick <dan.mick@redhat.com>
src/ceph.in
src/pybind/ceph_daemon.py

index 62a8562aed8184b1fdaa4baee04068a89e7a1cae..11f044412f9da219cf03da2e4eb89e4dc12d2c97 100755 (executable)
@@ -276,10 +276,12 @@ ping <mon.id>           Send simple presence/life test to a mon
 daemon {type.id|path} <cmd>
                         Same as --admin-daemon, but auto-find admin socket
 daemonperf {type.id | path} [stat-pats] [priority] [<interval>] [<count>]
+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 <count> times (default forever),
                          once per <interval> seconds (default 1)
     """, file=sys.stdout)
@@ -636,12 +638,14 @@ def daemonperf(childargs, sockpath):
     Handle daemonperf command; returns errno or 0
 
     daemonperf <daemon> [priority string] [statpats] [interval] [count]
+    daemonperf <daemon> 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
 
index 827f7abf22a28eb5b661d73b86a9e618684d9130..ae0ba8334eae1655b0ddb5e48cdeb4a87d7ffeaa 100755 (executable)
@@ -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')