From 089920e2c7b03db9af9f79861362b1778b154125 Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 16 Mar 2018 10:53:43 -0400 Subject: [PATCH] mgr/dashboard: block iSCSI frontend tweaks Label rates w/ "/s" suffix and switch throughput back to the sparkline graph from dashboard v1. Signed-off-by: Jason Dillaman --- .../mgr/dashboard/controllers/tcmu_iscsi.py | 16 ++++++++++---- .../app/ceph/block/iscsi/iscsi.component.ts | 22 ++++++++++++------- .../mgr/dashboard/tests/test_tcmu_iscsi.py | 8 +++---- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py b/src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py index 068fa843746..eb54718f67f 100644 --- a/src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/tcmu_iscsi.py @@ -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) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts index 9d700f44ed2..00416a27e0b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi/iscsi.component.ts @@ -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; + }); }); } diff --git a/src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py b/src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py index 84cd7eccc47..93b97d2509c 100644 --- a/src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py +++ b/src/pybind/mgr/dashboard/tests/test_tcmu_iscsi.py @@ -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]]} }] }) -- 2.39.5