Skip to content

Commit

Permalink
Merge pull request ceph#4265 from trociny/wip-11319
Browse files Browse the repository at this point in the history
ceph daemonperf: add watch interval and count parameters

Reviewed-by: John Spray <[email protected]>
  • Loading branch information
jcsp committed Apr 7, 2015
2 parents 3f75cbc + c0c55c9 commit 4d921ee
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
28 changes: 28 additions & 0 deletions man/8/ceph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Synopsis
| **ceph** **config-key** [ *del* | *exists* | *get* | *list* | *put* ] ...
| **ceph** **daemon** *<name>* \| *<path>* *<command>* ...
| **ceph** **daemonperf** *<name>* \| *<path>* [ *interval* [ *count* ] ]
| **ceph** **df** *{detail}*
| **ceph** **fs** [ *ls* \| *new* \| *reset* \| *rm* ] ...
Expand Down Expand Up @@ -202,6 +206,30 @@ Usage::
ceph config-key put <key> {<val>}


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
--

Expand Down
20 changes: 18 additions & 2 deletions src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions src/pybind/ceph_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

0 comments on commit 4d921ee

Please sign in to comment.