]>
Commit | Line | Data |
---|---|---|
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 APIDoc, APIRouter, 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 | @APIRouter('perf_counters/mds', Scope.CEPHFS) | |
36 | @APIDoc("Mds Perf Counters Management API", "MdsPerfCounter") | |
37 | class MdsPerfCounter(PerfCounter): | |
38 | service_type = 'mds' | |
39 | ||
40 | ||
41 | @APIRouter('perf_counters/mon', Scope.MONITOR) | |
42 | @APIDoc("Mon Perf Counters Management API", "MonPerfCounter") | |
43 | class MonPerfCounter(PerfCounter): | |
44 | service_type = 'mon' | |
45 | ||
46 | ||
47 | @APIRouter('perf_counters/osd', Scope.OSD) | |
48 | @APIDoc("OSD Perf Counters Management API", "OsdPerfCounter") | |
49 | class OsdPerfCounter(PerfCounter): | |
50 | service_type = 'osd' | |
51 | ||
52 | ||
53 | @APIRouter('perf_counters/rgw', Scope.RGW) | |
54 | @APIDoc("Rgw Perf Counters Management API", "RgwPerfCounter") | |
55 | class RgwPerfCounter(PerfCounter): | |
56 | service_type = 'rgw' | |
57 | ||
58 | ||
59 | @APIRouter('perf_counters/rbd-mirror', Scope.RBD_MIRRORING) | |
60 | @APIDoc("Rgw Mirroring Perf Counters Management API", "RgwMirrorPerfCounter") | |
61 | class RbdMirrorPerfCounter(PerfCounter): | |
62 | service_type = 'rbd-mirror' | |
63 | ||
64 | ||
65 | @APIRouter('perf_counters/mgr', Scope.MANAGER) | |
66 | @APIDoc("Mgr Perf Counters Management API", "MgrPerfCounter") | |
67 | class MgrPerfCounter(PerfCounter): | |
68 | service_type = 'mgr' | |
69 | ||
70 | ||
71 | @APIRouter('perf_counters/tcmu-runner', Scope.ISCSI) | |
72 | @APIDoc("Tcmu Runner Perf Counters Management API", "TcmuRunnerPerfCounter") | |
73 | class TcmuRunnerPerfCounter(PerfCounter): | |
74 | service_type = 'tcmu-runner' | |
75 | ||
76 | ||
77 | @APIRouter('perf_counters') | |
78 | @APIDoc("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() |