]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/controllers/perf_counters.py
bump version to 15.2.11-pve1
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / perf_counters.py
CommitLineData
11fdf7f2
TL
1# -*- coding: utf-8 -*-
2from __future__ import absolute_import
3
4import cherrypy
5
6from . import ApiController, RESTController
7from .. import mgr
8from ..security import Scope
9from ..services.ceph_service import CephService
10
11
12class PerfCounter(RESTController):
13 service_type = None # type: str
14
15 def get(self, service_id):
16 schema_dict = mgr.get_perf_schema(self.service_type, str(service_id))
17 try:
18 schema = schema_dict["{}.{}".format(self.service_type, service_id)]
19 except KeyError as e:
20 raise cherrypy.HTTPError(404, "{0} not found".format(e))
21 counters = []
22
23 for key, value in sorted(schema.items()):
24 counter = dict()
25 counter['name'] = str(key)
26 counter['description'] = value['description']
27 # pylint: disable=W0212
28 if mgr._stattype_to_str(value['type']) == 'counter':
29 counter['value'] = CephService.get_rate(
30 self.service_type, service_id, key)
31 counter['unit'] = mgr._unit_to_str(value['units'])
32 else:
33 counter['value'] = mgr.get_latest(
34 self.service_type, service_id, key)
35 counter['unit'] = ''
36 counters.append(counter)
37
38 return {
39 'service': {
40 'type': self.service_type,
41 'id': str(service_id)
42 },
43 'counters': counters
44 }
45
46
47@ApiController('perf_counters/mds', Scope.CEPHFS)
48class MdsPerfCounter(PerfCounter):
49 service_type = 'mds'
50
51
52@ApiController('perf_counters/mon', Scope.MONITOR)
53class MonPerfCounter(PerfCounter):
54 service_type = 'mon'
55
56
57@ApiController('perf_counters/osd', Scope.OSD)
58class OsdPerfCounter(PerfCounter):
59 service_type = 'osd'
60
61
62@ApiController('perf_counters/rgw', Scope.RGW)
63class RgwPerfCounter(PerfCounter):
64 service_type = 'rgw'
65
66
67@ApiController('perf_counters/rbd-mirror', Scope.RBD_MIRRORING)
68class RbdMirrorPerfCounter(PerfCounter):
69 service_type = 'rbd-mirror'
70
71
72@ApiController('perf_counters/mgr', Scope.MANAGER)
73class MgrPerfCounter(PerfCounter):
74 service_type = 'mgr'
75
76
81eedcae
TL
77@ApiController('perf_counters/tcmu-runner', Scope.ISCSI)
78class TcmuRunnerPerfCounter(PerfCounter):
79 service_type = 'tcmu-runner'
80
81
11fdf7f2
TL
82@ApiController('perf_counters')
83class PerfCounters(RESTController):
84 def list(self):
85 return mgr.get_all_perf_counters()