]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/perf_counters.py
import ceph 16.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / perf_counters.py
1 # -*- coding: utf-8 -*-
2 from __future__ import absolute_import
3
4 import cherrypy
5
6 from .. import mgr
7 from ..security import Scope
8 from ..services.ceph_service import CephService
9 from . import ApiController, ControllerDoc, EndpointDoc, RESTController
10
11 PERF_SCHEMA = {
12 "mon.a": ({
13 ".cache_bytes": ({
14 "description": (str, ""),
15 "nick": (str, ""),
16 "type": (int, ""),
17 "priority": (int, ""),
18 "units": (int, ""),
19 "value": (int, "")
20 }, ""),
21 }, "Service ID"),
22 }
23
24
25 class PerfCounter(RESTController):
26 service_type = None # type: str
27
28 def get(self, service_id):
29 try:
30 return CephService.get_service_perf_counters(self.service_type, str(service_id))
31 except KeyError as error:
32 raise cherrypy.HTTPError(404, "{0} not found".format(error))
33
34
35 @ApiController('perf_counters/mds', Scope.CEPHFS)
36 @ControllerDoc("Mds Perf Counters Management API", "MdsPerfCounter")
37 class MdsPerfCounter(PerfCounter):
38 service_type = 'mds'
39
40
41 @ApiController('perf_counters/mon', Scope.MONITOR)
42 @ControllerDoc("Mon Perf Counters Management API", "MonPerfCounter")
43 class MonPerfCounter(PerfCounter):
44 service_type = 'mon'
45
46
47 @ApiController('perf_counters/osd', Scope.OSD)
48 @ControllerDoc("OSD Perf Counters Management API", "OsdPerfCounter")
49 class OsdPerfCounter(PerfCounter):
50 service_type = 'osd'
51
52
53 @ApiController('perf_counters/rgw', Scope.RGW)
54 @ControllerDoc("Rgw Perf Counters Management API", "RgwPerfCounter")
55 class RgwPerfCounter(PerfCounter):
56 service_type = 'rgw'
57
58
59 @ApiController('perf_counters/rbd-mirror', Scope.RBD_MIRRORING)
60 @ControllerDoc("Rgw Mirroring Perf Counters Management API", "RgwMirrorPerfCounter")
61 class RbdMirrorPerfCounter(PerfCounter):
62 service_type = 'rbd-mirror'
63
64
65 @ApiController('perf_counters/mgr', Scope.MANAGER)
66 @ControllerDoc("Mgr Perf Counters Management API", "MgrPerfCounter")
67 class MgrPerfCounter(PerfCounter):
68 service_type = 'mgr'
69
70
71 @ApiController('perf_counters/tcmu-runner', Scope.ISCSI)
72 @ControllerDoc("Tcmu Runner Perf Counters Management API", "TcmuRunnerPerfCounter")
73 class TcmuRunnerPerfCounter(PerfCounter):
74 service_type = 'tcmu-runner'
75
76
77 @ApiController('perf_counters')
78 @ControllerDoc("Perf Counters Management API", "PerfCounters")
79 class PerfCounters(RESTController):
80 @EndpointDoc("Display Perf Counters",
81 responses={200: PERF_SCHEMA})
82 def list(self):
83 return mgr.get_all_perf_counters()