diff --git a/man/8/ceph.rst b/man/8/ceph.rst index 872d0424f36e9..4949252016b79 100644 --- a/man/8/ceph.rst +++ b/man/8/ceph.rst @@ -13,6 +13,10 @@ Synopsis | **ceph** **config-key** [ *del* | *exists* | *get* | *list* | *put* ] ... +| **ceph** **daemon** ** \| ** ** ... + +| **ceph** **daemonperf** ** \| ** [ *interval* [ *count* ] ] + | **ceph** **df** *{detail}* | **ceph** **fs** [ *ls* \| *new* \| *reset* \| *rm* ] ... @@ -202,6 +206,30 @@ Usage:: ceph config-key put {} +daemon +------ + +Submit admin-socket commands. + +Usage:: + + ceph daemon {daemon_name|socket_path} {command} ... + +Example:: + + ceph daemon osd.0 help + + +daemonperf +---------- + +Watch performance counters from a Ceph daemon. + +Usage:: + + ceph daemonperf {daemon_name|socket_path} [{interval} [{count}]] + + df -- diff --git a/src/ceph.in b/src/ceph.in index 69dadd398e9bf..40a6fdcda30c6 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -551,11 +551,27 @@ def main(): # for both: childargs = childargs[2:] else: - print >> sys.stderr, 'daemon requires at least 3 arguments' + print >> sys.stderr, '{0} requires at least {1} arguments'.format( + childargs[0], require_args) return errno.EINVAL if sockpath and daemon_perf: - DaemonWatcher(sockpath).run() + interval = 1 + count = None + if len(childargs) > 0: + try: + interval = float(childargs[0]) + if interval < 0: + raise ValueError + except ValueError: + print >> sys.stderr, 'daemonperf: interval should be a positive number' + return errno.EINVAL + if len(childargs) > 1: + if not childargs[1].isdigit(): + print >> sys.stderr, 'daemonperf: count should be a positive integer' + return errno.EINVAL + count = int(childargs[1]) + DaemonWatcher(sockpath).run(interval, count) return 0 elif sockpath: try: diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index 30c54e4b5a3d1..638ef8978e036 100755 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -244,7 +244,7 @@ def _load_schema(self): if schema_data.get('nick'): self._stats[section_name][name] = schema_data['nick'] - def run(self, ostr=sys.stdout): + def run(self, interval, count=None, ostr=sys.stdout): """ Print output at regular intervals until interrupted. @@ -267,8 +267,12 @@ def run(self, ostr=sys.stdout): self._print_headers(ostr) rows_since_header = 0 self._print_vals(ostr, dump, last_dump) + if count is not None: + count -= 1 + if count <= 0: + break rows_since_header += 1 last_dump = dump - time.sleep(1) + time.sleep(interval) except KeyboardInterrupt: return