summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/controllers/telemetry.py
blob: b1f714bc38e0ad5915add11ed01ab29448324e2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# -*- coding: utf-8 -*-
from __future__ import absolute_import

from .. import mgr
from ..exceptions import DashboardException
from ..security import Scope
from . import APIDoc, APIRouter, EndpointDoc, RESTController

REPORT_SCHEMA = {
    "report": ({
        "leaderboard": (bool, ""),
        "report_version": (int, ""),
        "report_timestamp": (str, ""),
        "report_id": (str, ""),
        "channels": ([str], ""),
        "channels_available": ([str], ""),
        "license": (str, ""),
        "created": (str, ""),
        "mon": ({
            "count": (int, ""),
            "features": ({
                "persistent": ([str], ""),
                "optional": ([int], "")
            }, ""),
            "min_mon_release": (int, ""),
            "v1_addr_mons": (int, ""),
            "v2_addr_mons": (int, ""),
            "ipv4_addr_mons": (int, ""),
            "ipv6_addr_mons": (int, ""),
        }, ""),
        "config": ({
            "cluster_changed": ([str], ""),
            "active_changed": ([str], "")
        }, ""),
        "rbd": ({
            "num_pools": (int, ""),
            "num_images_by_pool": ([int], ""),
            "mirroring_by_pool": ([bool], ""),
        }, ""),
        "pools": ([{
            "pool": (int, ""),
            "type": (str, ""),
            "pg_num": (int, ""),
            "pgp_num": (int, ""),
            "size": (int, ""),
            "min_size": (int, ""),
            "pg_autoscale_mode": (str, ""),
            "target_max_bytes": (int, ""),
            "target_max_objects": (int, ""),
            "erasure_code_profile": (str, ""),
            "cache_mode": (str, ""),
        }], ""),
        "osd": ({
            "count": (int, ""),
            "require_osd_release": (str, ""),
            "require_min_compat_client": (str, ""),
            "cluster_network": (bool, ""),
        }, ""),
        "crush": ({
            "num_devices": (int, ""),
            "num_types": (int, ""),
            "num_buckets": (int, ""),
            "num_rules": (int, ""),
            "device_classes": ([int], ""),
            "tunables": ({
                "choose_local_tries": (int, ""),
                "choose_local_fallback_tries": (int, ""),
                "choose_total_tries": (int, ""),
                "chooseleaf_descend_once": (int, ""),
                "chooseleaf_vary_r": (int, ""),
                "chooseleaf_stable": (int, ""),
                "straw_calc_version": (int, ""),
                "allowed_bucket_algs": (int, ""),
                "profile": (str, ""),
                "optimal_tunables": (int, ""),
                "legacy_tunables": (int, ""),
                "minimum_required_version": (str, ""),
                "require_feature_tunables": (int, ""),
                "require_feature_tunables2": (int, ""),
                "has_v2_rules": (int, ""),
                "require_feature_tunables3": (int, ""),
                "has_v3_rules": (int, ""),
                "has_v4_buckets": (int, ""),
                "require_feature_tunables5": (int, ""),
                "has_v5_rules": (int, ""),
            }, ""),
            "compat_weight_set": (bool, ""),
            "num_weight_sets": (int, ""),
            "bucket_algs": ({
                "straw2": (int, ""),
            }, ""),
            "bucket_sizes": ({
                "1": (int, ""),
                "3": (int, ""),
            }, ""),
            "bucket_types": ({
                "1": (int, ""),
                "11": (int, ""),
            }, ""),
        }, ""),
        "fs": ({
            "count": (int, ""),
            "feature_flags": ({
                "enable_multiple": (bool, ""),
                "ever_enabled_multiple": (bool, ""),
            }, ""),
            "num_standby_mds": (int, ""),
            "filesystems": ([int], ""),
            "total_num_mds": (int, ""),
        }, ""),
        "metadata": ({
            "osd": ({
                "osd_objectstore": ({
                    "bluestore": (int, ""),
                }, ""),
                "rotational": ({
                    "1": (int, ""),
                }, ""),
                "arch": ({
                    "x86_64": (int, ""),
                }, ""),
                "ceph_version": ({
                    "ceph version 16.0.0-3151-gf202994fcf": (int, ""),
                }, ""),
                "os": ({
                    "Linux": (int, ""),
                }, ""),
                "cpu": ({
                    "Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz": (int, ""),
                }, ""),
                "kernel_description": ({
                    "#1 SMP Wed Jul 1 19:53:01 UTC 2020": (int, ""),
                }, ""),
                "kernel_version": ({
                    "5.7.7-200.fc32.x86_64": (int, ""),
                }, ""),
                "distro_description": ({
                    "CentOS Linux 8 (Core)": (int, ""),
                }, ""),
                "distro": ({
                    "centos": (int, ""),
                }, ""),
            }, ""),
            "mon": ({
                "arch": ({
                    "x86_64": (int, ""),
                }, ""),
                "ceph_version": ({
                    "ceph version 16.0.0-3151-gf202994fcf": (int, ""),
                }, ""),
                "os": ({
                    "Linux": (int, ""),
                }, ""),
                "cpu": ({
                    "Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz": (int, ""),
                }, ""),
                "kernel_description": ({
                    "#1 SMP Wed Jul 1 19:53:01 UTC 2020": (int, ""),
                }, ""),
                "kernel_version": ({
                    "5.7.7-200.fc32.x86_64": (int, ""),
                }, ""),
                "distro_description": ({
                    "CentOS Linux 8 (Core)": (int, ""),
                }, ""),
                "distro": ({
                    "centos": (int, ""),
                }, ""),
            }, ""),
        }, ""),
        "hosts": ({
            "num": (int, ""),
            "num_with_mon": (int, ""),
            "num_with_mds": (int, ""),
            "num_with_osd": (int, ""),
            "num_with_mgr": (int, ""),
        }, ""),
        "usage": ({
            "pools": (int, ""),
            "pg_num": (int, ""),
            "total_used_bytes": (int, ""),
            "total_bytes": (int, ""),
            "total_avail_bytes": (int, ""),
        }, ""),
        "services": ({
            "rgw": (int, ""),
        }, ""),
        "rgw": ({
            "count": (int, ""),
            "zones": (int, ""),
            "zonegroups": (int, ""),
            "frontends": ([str], "")
        }, ""),
        "balancer": ({
            "active": (bool, ""),
            "mode": (str, ""),
        }, ""),
        "crashes": ([int], "")
    }, ""),
    "device_report": (str, "")
}


@APIRouter('/telemetry', Scope.CONFIG_OPT)
@APIDoc("Display Telemetry Report", "Telemetry")
class Telemetry(RESTController):

    @RESTController.Collection('GET')
    @EndpointDoc("Get Detailed Telemetry report",
                 responses={200: REPORT_SCHEMA})
    def report(self):
        """
        Get Ceph and device report data
        :return: Ceph and device report data
        :rtype: dict
        """
        return mgr.remote('telemetry', 'get_report', 'all')

    def singleton_set(self, enable=True, license_name=None):
        """
        Enables or disables sending data collected by the Telemetry
        module.
        :param enable: Enable or disable sending data
        :type enable: bool
        :param license_name: License string e.g. 'sharing-1-0' to
        make sure the user is aware of and accepts the license
        for sharing Telemetry data.
        :type license_name: string
        """
        if enable:
            if not license_name or (license_name != 'sharing-1-0'):
                raise DashboardException(
                    code='telemetry_enable_license_missing',
                    msg='Telemetry data is licensed under the Community Data License Agreement - '
                        'Sharing - Version 1.0 (https://cdla.io/sharing-1-0/). To enable, add '
                        '{"license": "sharing-1-0"} to the request payload.'
                )
            mgr.remote('telemetry', 'on')
        else:
            mgr.remote('telemetry', 'off')