]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard/api: move/create OSD histogram in separate endpoint 37192/head
authorAashish Sharma <aashishsharma@localhost.localdomain>
Wed, 16 Sep 2020 13:43:04 +0000 (19:13 +0530)
committerAashish Sharma <aashishsharma@localhost.localdomain>
Fri, 18 Sep 2020 10:41:04 +0000 (16:11 +0530)
Added a separate endpoint for osd/histogram - api/osd/{svc_id}/histogram

Fixes:https://tracker.ceph.com/issues/46898
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
qa/tasks/mgr/dashboard/test_osd.py
src/pybind/mgr/dashboard/controllers/osd.py

index 5eea93a9eff1e3c721c2948d4b03bab1729d3e44..8fc84964795030ba55de31cbad340bc05c1bbb82 100644 (file)
@@ -51,6 +51,12 @@ class OsdTest(DashboardTestCase):
         self.assertStatus(200)
         self.assert_in_and_not_none(data, ['osd_metadata'])
 
+    def test_histogram(self):
+        data = self._get('/api/osd/0/histogram')
+        self.assertStatus(200)
+        self.assert_in_and_not_none(data['osd'], ['op_w_latency_in_bytes_histogram',
+                                                               'op_r_latency_out_bytes_histogram'])    
+
     def test_scrub(self):
         self._post('/api/osd/0/scrub?deep=False')
         self.assertStatus(200)
index 75e0d565b72f9156256967b2596f0c5c2797467f..0b8555da4a0dd032eccbad115042f61110f981fc 100644 (file)
@@ -120,6 +120,22 @@ class Osd(RESTController):
             'osd_metadata': mgr.get_metadata('osd', svc_id),
         }
 
+    @RESTController.Resource('GET')
+    @handle_send_command_error('osd')
+    def histogram(self, svc_id):
+        # type: (int) -> Dict[str, Any]
+        """
+        :return: Returns the histogram data.
+        """
+        try:
+            histogram = CephService.send_command(
+                'osd', srv_spec=svc_id, prefix='perf histogram dump')
+        except SendCommandError as e:  # pragma: no cover - the handling is too obvious
+            raise DashboardException(
+                component='osd', http_status_code=400, msg=str(e))
+
+        return histogram
+
     def set(self, svc_id, device_class):  # pragma: no cover
         old_device_class = CephService.send_command('mon', 'osd crush get-device-class',
                                                     ids=[svc_id])