Skip to content

Commit

Permalink
Merge pull request ceph#27885 from b-ranto/wip-restful-perf-counters
Browse files Browse the repository at this point in the history
restful: Expose perf counters

Reviewed-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov authored May 4, 2019
2 parents 382a3ef + aaaef91 commit ba97031
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qa/workunits/rest/test_mgr_rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@
('get', '/request?page=0', {}),
('delete', '/request', {}),
('get', '/request', {}),
('patch', '/pool/1', {'pg_num': 128}),
('patch', '/pool/1', {'pgp_num': 128}),
('patch', '/pool/1', {'pg_num': 128}),
('patch', '/pool/1', {'pgp_num': 128}),
('get', '/perf?daemon=.*', {}),
]

for method, endpoint, args in screenplay:
Expand Down
2 changes: 2 additions & 0 deletions src/pybind/mgr/restful/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .mon import Mon
from .osd import Osd
from .pool import Pool
from .perf import Perf
from .request import Request
from .server import Server

Expand All @@ -17,6 +18,7 @@ class Root(RestController):
doc = Doc()
mon = Mon()
osd = Osd()
perf = Perf()
pool = Pool()
request = Request()
server = Server()
Expand Down
27 changes: 27 additions & 0 deletions src/pybind/mgr/restful/api/perf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pecan import expose, request, response
from pecan.rest import RestController

from restful import context
from restful.decorators import auth, lock, paginate

import re

class Perf(RestController):
@expose(template='json')
@paginate
@auth
def get(self, **kwargs):
"""
List all the available performance counters
Options:
- 'daemon' -- filter by daemon, accepts Python regexp
"""

counters = context.instance.get_all_perf_counters()

if 'daemon' in kwargs:
_re = re.compile(kwargs['daemon'])
counters = {k: v for k, v in counters.items() if _re.match(k)}

return counters

0 comments on commit ba97031

Please sign in to comment.