From f5b727e595df124f010b51981834e1f356a8e374 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Thu, 22 Nov 2018 13:11:28 +0200 Subject: [PATCH] mgr: add "total" perf counter types Signed-off-by: Mykola Golub --- src/mgr/BaseMgrModule.cc | 3 +++ src/mgr/OSDPerfMetricTypes.cc | 12 ++++++++++++ src/mgr/OSDPerfMetricTypes.h | 18 ++++++++++++------ src/osd/DynamicPerfStats.h | 11 +++++++++++ src/pybind/mgr/mgr_module.py | 4 ++-- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 03103ba1b3d..5c08bb88abc 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -689,10 +689,13 @@ ceph_add_osd_perf_query(BaseMgrModule *self, PyObject *args) {"object_name", OSDPerfMetricSubKeyType::OBJECT_NAME}, }; static const std::map counter_types = { + {"ops", PerformanceCounterType::OPS}, {"write_ops", PerformanceCounterType::WRITE_OPS}, {"read_ops", PerformanceCounterType::READ_OPS}, + {"bytes", PerformanceCounterType::BYTES}, {"write_bytes", PerformanceCounterType::WRITE_BYTES}, {"read_bytes", PerformanceCounterType::READ_BYTES}, + {"latency", PerformanceCounterType::LATENCY}, {"write_latency", PerformanceCounterType::WRITE_LATENCY}, {"read_latency", PerformanceCounterType::READ_LATENCY}, }; diff --git a/src/mgr/OSDPerfMetricTypes.cc b/src/mgr/OSDPerfMetricTypes.cc index 266fc403cc5..181a1f38c7c 100644 --- a/src/mgr/OSDPerfMetricTypes.cc +++ b/src/mgr/OSDPerfMetricTypes.cc @@ -28,11 +28,14 @@ void PerformanceCounterDescriptor::pack_counter(const PerformanceCounter &c, using ceph::encode; encode(c.first, *bl); switch(type) { + case PerformanceCounterType::OPS: case PerformanceCounterType::WRITE_OPS: case PerformanceCounterType::READ_OPS: break; + case PerformanceCounterType::BYTES: case PerformanceCounterType::WRITE_BYTES: case PerformanceCounterType::READ_BYTES: + case PerformanceCounterType::LATENCY: case PerformanceCounterType::WRITE_LATENCY: case PerformanceCounterType::READ_LATENCY: encode(c.second, *bl); @@ -47,11 +50,14 @@ void PerformanceCounterDescriptor::unpack_counter( using ceph::decode; decode(c->first, bl); switch(type) { + case PerformanceCounterType::OPS: case PerformanceCounterType::WRITE_OPS: case PerformanceCounterType::READ_OPS: break; + case PerformanceCounterType::BYTES: case PerformanceCounterType::WRITE_BYTES: case PerformanceCounterType::READ_BYTES: + case PerformanceCounterType::LATENCY: case PerformanceCounterType::WRITE_LATENCY: case PerformanceCounterType::READ_LATENCY: decode(c->second, bl); @@ -64,14 +70,20 @@ void PerformanceCounterDescriptor::unpack_counter( std::ostream& operator<<(std::ostream& os, const PerformanceCounterDescriptor &d) { switch(d.type) { + case PerformanceCounterType::OPS: + return os << "ops"; case PerformanceCounterType::WRITE_OPS: return os << "write ops"; case PerformanceCounterType::READ_OPS: return os << "read ops"; + case PerformanceCounterType::BYTES: + return os << "bytes"; case PerformanceCounterType::WRITE_BYTES: return os << "write bytes"; case PerformanceCounterType::READ_BYTES: return os << "read bytes"; + case PerformanceCounterType::LATENCY: + return os << "latency"; case PerformanceCounterType::WRITE_LATENCY: return os << "write latency"; case PerformanceCounterType::READ_LATENCY: diff --git a/src/mgr/OSDPerfMetricTypes.h b/src/mgr/OSDPerfMetricTypes.h index c3d281e235a..c1777af0fa4 100644 --- a/src/mgr/OSDPerfMetricTypes.h +++ b/src/mgr/OSDPerfMetricTypes.h @@ -116,12 +116,15 @@ typedef std::pair PerformanceCounter; typedef std::vector PerformanceCounters; enum class PerformanceCounterType : uint8_t { - WRITE_OPS = 0, - READ_OPS = 1, - WRITE_BYTES = 2, - READ_BYTES = 3, - WRITE_LATENCY = 4, - READ_LATENCY = 5, + OPS = 0, + WRITE_OPS = 1, + READ_OPS = 2, + BYTES = 3, + WRITE_BYTES = 4, + READ_BYTES = 5, + LATENCY = 6, + WRITE_LATENCY = 7, + READ_LATENCY = 8, }; struct PerformanceCounterDescriptor { @@ -129,10 +132,13 @@ struct PerformanceCounterDescriptor { bool is_supported() const { switch (type) { + case PerformanceCounterType::OPS: case PerformanceCounterType::WRITE_OPS: case PerformanceCounterType::READ_OPS: + case PerformanceCounterType::BYTES: case PerformanceCounterType::WRITE_BYTES: case PerformanceCounterType::READ_BYTES: + case PerformanceCounterType::LATENCY: case PerformanceCounterType::WRITE_LATENCY: case PerformanceCounterType::READ_LATENCY: return true; diff --git a/src/osd/DynamicPerfStats.h b/src/osd/DynamicPerfStats.h index dddfb69ee87..049451575c2 100644 --- a/src/osd/DynamicPerfStats.h +++ b/src/osd/DynamicPerfStats.h @@ -61,6 +61,9 @@ public: ceph_assert(d.is_supported()); switch(d.type) { + case PerformanceCounterType::OPS: + c->first++; + return; case PerformanceCounterType::WRITE_OPS: if (op.may_write() || op.may_cache()) { c->first++; @@ -71,6 +74,10 @@ public: c->first++; } return; + case PerformanceCounterType::BYTES: + c->first += inb + outb; + c->second++; + return; case PerformanceCounterType::WRITE_BYTES: if (op.may_write() || op.may_cache()) { c->first += inb; @@ -83,6 +90,10 @@ public: c->second++; } return; + case PerformanceCounterType::LATENCY: + c->first += latency.to_nsec(); + c->second++; + return; case PerformanceCounterType::WRITE_LATENCY: if (op.may_write() || op.may_cache()) { c->first += latency.to_nsec(); diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index fbdd3f1f420..ccf763c776e 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -971,8 +971,8 @@ class MgrModule(ceph_module.BaseMgrModule): Valid subkey types: 'client_id', 'pool_id', 'object_name' Valid performance counter types: - 'write_ops', 'read_ops', 'write_bytes', 'read_bytes', - 'write_latency', 'read_latency' + 'ops', 'write_ops', 'read_ops', 'bytes', 'write_bytes', 'read_bytes', + 'latency', 'write_latency', 'read_latency' :param object query: query :rtype: int (query id) -- 2.39.5