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