]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: block iSCSI frontend tweaks
authorJason Dillaman <dillaman@redhat.com>
Fri, 16 Mar 2018 14:53:43 +0000 (10:53 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 16 Mar 2018 18:16:39 +0000 (14:16 -0400)
Label rates w/ "/s" suffix and switch throughput back to the
sparkline graph from dashboard v1.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts
src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py

index 068fa84374694f7afc539beff860d323588eab17..eb54718f67fd470d64896f710bd82a718ecbbdb4 100644 (file)
@@ -15,8 +15,16 @@ class TcmuIscsi(RESTController):
         data = mgr.get_counter(daemon_type, daemon_name, stat)[stat]
 
         if data and len(data) > 1:
-            return (data[-1][1] - data[-2][1]) / float(data[-1][0] - data[-2][0])
-        return 0
+            last_value = data[0][1]
+            last_time = data[0][0]
+            rates = []
+            for datum in data[1:]:
+                rates.append([datum[0], ((datum[1] - last_value) /
+                                         float(datum[0] - last_time))])
+                last_value = datum[1]
+                last_time = datum[0]
+            return rates
+        return [[0, 0]]
 
     # pylint: disable=too-many-locals,too-many-nested-blocks
     def list(self):  # pylint: disable=unused-argument
@@ -70,9 +78,9 @@ class TcmuIscsi(RESTController):
                     for s in ['rd', 'wr', 'rd_bytes', 'wr_bytes']:
                         perf_key = "{}{}".format(perf_key_prefix, s)
                         image['stats'][s] = self._get_rate(
+                            'tcmu-runner', service_id, perf_key)[-1][1]
+                        image['stats_history'][s] = self._get_rate(
                             'tcmu-runner', service_id, perf_key)
-                        image['stats_history'][s] = mgr.get_counter(
-                            'tcmu-runner', service_id, perf_key)[perf_key]
             else:
                 daemon['non_optimized_paths'] += 1
                 image['non_optimized_paths'].append(hostname)
index 9d700f44ed20575c76db2c69df2a2736e1d5661f..00416a27e0b7a134b3d9c4a432480d6ddae46de6 100644 (file)
@@ -1,7 +1,7 @@
 import { Component } from '@angular/core';
 
+import { CellTemplate } from '../../../shared/enum/cell-template.enum';
 import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
-import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';
 import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';
 import { ListPipe } from '../../../shared/pipes/list.pipe';
 import { RelativeDatePipe } from '../../../shared/pipes/relative-date.pipe';
@@ -21,7 +21,6 @@ export class IscsiComponent {
 
   constructor(private tcmuIscsiService: TcmuIscsiService,
               cephShortVersionPipe: CephShortVersionPipe,
-              dimlessBinaryPipe: DimlessBinaryPipe,
               dimlessPipe: DimlessPipe,
               relativeDatePipe: RelativeDatePipe,
               listPipe: ListPipe) {
@@ -65,23 +64,25 @@ export class IscsiComponent {
       },
       {
         name: 'Read Bytes',
-        prop: 'stats.rd_bytes',
-        pipe: dimlessBinaryPipe
+        prop: 'stats_history.rd_bytes',
+        cellTransformation: CellTemplate.sparkline
       },
       {
         name: 'Write Bytes',
-        prop: 'stats.wr_bytes',
-        pipe: dimlessBinaryPipe
+        prop: 'stats_history.wr_bytes',
+        cellTransformation: CellTemplate.sparkline
       },
       {
         name: 'Read Ops',
         prop: 'stats.rd',
-        pipe: dimlessPipe
+        pipe: dimlessPipe,
+        cellTransformation: CellTemplate.perSecond
       },
       {
         name: 'Write Ops',
         prop: 'stats.wr',
-        pipe: dimlessPipe
+        pipe: dimlessPipe,
+        cellTransformation: CellTemplate.perSecond
       },
       {
         name: 'A/O Since',
@@ -96,6 +97,11 @@ export class IscsiComponent {
     this.tcmuIscsiService.tcmuiscsi().then((resp) => {
       this.daemons = resp.daemons;
       this.images = resp.images;
+      this.images.map((image) => {
+        image.stats_history.rd_bytes = image.stats_history.rd_bytes.map(i => i[1]);
+        image.stats_history.wr_bytes = image.stats_history.wr_bytes.map(i => i[1]);
+        return image;
+      });
     });
   }
 
index 84cd7eccc47043f687b7fc8794255b94fe6cbbf4..93b97d2509cf44ef5ffa3583381274fbcb240160 100644 (file)
@@ -67,9 +67,9 @@ class TcmuIscsiControllerTest(ControllerTestCase):
                     'rd_bytes': 45.0,
                     'wr_bytes': 46.0},
                 'stats_history': {
-                    'rd': [[0, 0], [1, 43]],
-                    'wr': [[0, 0], [1, 44]],
-                    'rd_bytes': [[0, 0], [1, 45]],
-                    'wr_bytes': [[0, 0], [1, 46]]}
+                    'rd': [[1, 43]],
+                    'wr': [[1, 44]],
+                    'rd_bytes': [[1, 45]],
+                    'wr_bytes': [[1, 46]]}
             }]
         })