From: Mykola Golub Date: Fri, 3 Apr 2015 05:42:43 +0000 (+0300) Subject: ceph daemonperf: add watch interval and count parameters X-Git-Tag: v9.0.0~31^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=983958474b3edf29a7263b9bbfe2e20359c1d43a;p=ceph.git ceph daemonperf: add watch interval and count parameters Fixes: #11319 Signed-off-by: Mykola Golub --- diff --git a/src/ceph.in b/src/ceph.in index f9c66d350e5b..d208d96d45f7 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -550,7 +550,22 @@ def main(): 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 30c54e4b5a3d..638ef8978e03 100755 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -244,7 +244,7 @@ class DaemonWatcher(object): 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 @@ class DaemonWatcher(object): 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