]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/controllers/telemetry.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / controllers / telemetry.py
1 # -*- coding: utf-8 -*-
2
3 from .. import mgr
4 from ..exceptions import DashboardException
5 from ..security import Scope
6 from . import APIDoc, APIRouter, EndpointDoc, RESTController
7
8 REPORT_SCHEMA = {
9 "report": ({
10 "leaderboard": (bool, ""),
11 "report_version": (int, ""),
12 "report_timestamp": (str, ""),
13 "report_id": (str, ""),
14 "channels": ([str], ""),
15 "channels_available": ([str], ""),
16 "license": (str, ""),
17 "created": (str, ""),
18 "mon": ({
19 "count": (int, ""),
20 "features": ({
21 "persistent": ([str], ""),
22 "optional": ([int], "")
23 }, ""),
24 "min_mon_release": (int, ""),
25 "v1_addr_mons": (int, ""),
26 "v2_addr_mons": (int, ""),
27 "ipv4_addr_mons": (int, ""),
28 "ipv6_addr_mons": (int, ""),
29 }, ""),
30 "config": ({
31 "cluster_changed": ([str], ""),
32 "active_changed": ([str], "")
33 }, ""),
34 "rbd": ({
35 "num_pools": (int, ""),
36 "num_images_by_pool": ([int], ""),
37 "mirroring_by_pool": ([bool], ""),
38 }, ""),
39 "pools": ([{
40 "pool": (int, ""),
41 "type": (str, ""),
42 "pg_num": (int, ""),
43 "pgp_num": (int, ""),
44 "size": (int, ""),
45 "min_size": (int, ""),
46 "pg_autoscale_mode": (str, ""),
47 "target_max_bytes": (int, ""),
48 "target_max_objects": (int, ""),
49 "erasure_code_profile": (str, ""),
50 "cache_mode": (str, ""),
51 }], ""),
52 "osd": ({
53 "count": (int, ""),
54 "require_osd_release": (str, ""),
55 "require_min_compat_client": (str, ""),
56 "cluster_network": (bool, ""),
57 }, ""),
58 "crush": ({
59 "num_devices": (int, ""),
60 "num_types": (int, ""),
61 "num_buckets": (int, ""),
62 "num_rules": (int, ""),
63 "device_classes": ([int], ""),
64 "tunables": ({
65 "choose_local_tries": (int, ""),
66 "choose_local_fallback_tries": (int, ""),
67 "choose_total_tries": (int, ""),
68 "chooseleaf_descend_once": (int, ""),
69 "chooseleaf_vary_r": (int, ""),
70 "chooseleaf_stable": (int, ""),
71 "straw_calc_version": (int, ""),
72 "allowed_bucket_algs": (int, ""),
73 "profile": (str, ""),
74 "optimal_tunables": (int, ""),
75 "legacy_tunables": (int, ""),
76 "minimum_required_version": (str, ""),
77 "require_feature_tunables": (int, ""),
78 "require_feature_tunables2": (int, ""),
79 "has_v2_rules": (int, ""),
80 "require_feature_tunables3": (int, ""),
81 "has_v3_rules": (int, ""),
82 "has_v4_buckets": (int, ""),
83 "require_feature_tunables5": (int, ""),
84 "has_v5_rules": (int, ""),
85 }, ""),
86 "compat_weight_set": (bool, ""),
87 "num_weight_sets": (int, ""),
88 "bucket_algs": ({
89 "straw2": (int, ""),
90 }, ""),
91 "bucket_sizes": ({
92 "1": (int, ""),
93 "3": (int, ""),
94 }, ""),
95 "bucket_types": ({
96 "1": (int, ""),
97 "11": (int, ""),
98 }, ""),
99 }, ""),
100 "fs": ({
101 "count": (int, ""),
102 "feature_flags": ({
103 "enable_multiple": (bool, ""),
104 "ever_enabled_multiple": (bool, ""),
105 }, ""),
106 "num_standby_mds": (int, ""),
107 "filesystems": ([int], ""),
108 "total_num_mds": (int, ""),
109 }, ""),
110 "metadata": ({
111 "osd": ({
112 "osd_objectstore": ({
113 "bluestore": (int, ""),
114 }, ""),
115 "rotational": ({
116 "1": (int, ""),
117 }, ""),
118 "arch": ({
119 "x86_64": (int, ""),
120 }, ""),
121 "ceph_version": ({
122 "ceph version 16.0.0-3151-gf202994fcf": (int, ""),
123 }, ""),
124 "os": ({
125 "Linux": (int, ""),
126 }, ""),
127 "cpu": ({
128 "Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz": (int, ""),
129 }, ""),
130 "kernel_description": ({
131 "#1 SMP Wed Jul 1 19:53:01 UTC 2020": (int, ""),
132 }, ""),
133 "kernel_version": ({
134 "5.7.7-200.fc32.x86_64": (int, ""),
135 }, ""),
136 "distro_description": ({
137 "CentOS Linux 8 (Core)": (int, ""),
138 }, ""),
139 "distro": ({
140 "centos": (int, ""),
141 }, ""),
142 }, ""),
143 "mon": ({
144 "arch": ({
145 "x86_64": (int, ""),
146 }, ""),
147 "ceph_version": ({
148 "ceph version 16.0.0-3151-gf202994fcf": (int, ""),
149 }, ""),
150 "os": ({
151 "Linux": (int, ""),
152 }, ""),
153 "cpu": ({
154 "Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz": (int, ""),
155 }, ""),
156 "kernel_description": ({
157 "#1 SMP Wed Jul 1 19:53:01 UTC 2020": (int, ""),
158 }, ""),
159 "kernel_version": ({
160 "5.7.7-200.fc32.x86_64": (int, ""),
161 }, ""),
162 "distro_description": ({
163 "CentOS Linux 8 (Core)": (int, ""),
164 }, ""),
165 "distro": ({
166 "centos": (int, ""),
167 }, ""),
168 }, ""),
169 }, ""),
170 "hosts": ({
171 "num": (int, ""),
172 "num_with_mon": (int, ""),
173 "num_with_mds": (int, ""),
174 "num_with_osd": (int, ""),
175 "num_with_mgr": (int, ""),
176 }, ""),
177 "usage": ({
178 "pools": (int, ""),
179 "pg_num": (int, ""),
180 "total_used_bytes": (int, ""),
181 "total_bytes": (int, ""),
182 "total_avail_bytes": (int, ""),
183 }, ""),
184 "services": ({
185 "rgw": (int, ""),
186 }, ""),
187 "rgw": ({
188 "count": (int, ""),
189 "zones": (int, ""),
190 "zonegroups": (int, ""),
191 "frontends": ([str], "")
192 }, ""),
193 "balancer": ({
194 "active": (bool, ""),
195 "mode": (str, ""),
196 }, ""),
197 "crashes": ([int], "")
198 }, ""),
199 "device_report": (str, "")
200 }
201
202
203 @APIRouter('/telemetry', Scope.CONFIG_OPT)
204 @APIDoc("Display Telemetry Report", "Telemetry")
205 class Telemetry(RESTController):
206
207 @RESTController.Collection('GET')
208 @EndpointDoc("Get Detailed Telemetry report",
209 responses={200: REPORT_SCHEMA})
210 def report(self):
211 """
212 Get Ceph and device report data
213 :return: Ceph and device report data
214 :rtype: dict
215 """
216 return mgr.remote('telemetry', 'get_report_locked', 'all')
217
218 def singleton_set(self, enable=True, license_name=None):
219 """
220 Enables or disables sending data collected by the Telemetry
221 module.
222 :param enable: Enable or disable sending data
223 :type enable: bool
224 :param license_name: License string e.g. 'sharing-1-0' to
225 make sure the user is aware of and accepts the license
226 for sharing Telemetry data.
227 :type license_name: string
228 """
229 if enable:
230 if not license_name or (license_name != 'sharing-1-0'):
231 raise DashboardException(
232 code='telemetry_enable_license_missing',
233 msg='Telemetry data is licensed under the Community Data License Agreement - '
234 'Sharing - Version 1.0 (https://cdla.io/sharing-1-0/). To enable, add '
235 '{"license": "sharing-1-0"} to the request payload.'
236 )
237 mgr.remote('telemetry', 'on', license_name)
238 else:
239 mgr.remote('telemetry', 'off')