summaryrefslogtreecommitdiffstats
path: root/src/mgr/DaemonHealthMetric.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/mgr/DaemonHealthMetric.h
parentInitial commit. (diff)
downloadceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz
ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mgr/DaemonHealthMetric.h')
-rw-r--r--src/mgr/DaemonHealthMetric.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/mgr/DaemonHealthMetric.h b/src/mgr/DaemonHealthMetric.h
new file mode 100644
index 00000000..4719fa18
--- /dev/null
+++ b/src/mgr/DaemonHealthMetric.h
@@ -0,0 +1,76 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <cstdint>
+#include <ostream>
+#include "include/denc.h"
+
+enum class daemon_metric : uint8_t {
+ SLOW_OPS,
+ PENDING_CREATING_PGS,
+ NONE,
+};
+
+static inline const char *daemon_metric_name(daemon_metric t) {
+ switch (t) {
+ case daemon_metric::SLOW_OPS: return "SLOW_OPS";
+ case daemon_metric::PENDING_CREATING_PGS: return "PENDING_CREATING_PGS";
+ case daemon_metric::NONE: return "NONE";
+ default: return "???";
+ }
+}
+
+union daemon_metric_t {
+ struct {
+ uint32_t n1;
+ uint32_t n2;
+ };
+ uint64_t n;
+ daemon_metric_t(uint32_t x, uint32_t y)
+ : n1(x), n2(y)
+ {}
+ daemon_metric_t(uint64_t x = 0)
+ : n(x)
+ {}
+};
+
+class DaemonHealthMetric
+{
+public:
+ DaemonHealthMetric() = default;
+ DaemonHealthMetric(daemon_metric type_, uint64_t n)
+ : type(type_), value(n)
+ {}
+ DaemonHealthMetric(daemon_metric type_, uint32_t n1, uint32_t n2)
+ : type(type_), value(n1, n2)
+ {}
+ daemon_metric get_type() const {
+ return type;
+ }
+ uint64_t get_n() const {
+ return value.n;
+ }
+ uint32_t get_n1() const {
+ return value.n1;
+ }
+ uint32_t get_n2() const {
+ return value.n2;
+ }
+ DENC(DaemonHealthMetric, v, p) {
+ DENC_START(1, 1, p);
+ denc(v.type, p);
+ denc(v.value.n, p);
+ DENC_FINISH(p);
+ }
+
+ friend ostream& operator<<(ostream& out, const DaemonHealthMetric& m) {
+ return out << daemon_metric_name(m.get_type()) << "("
+ << m.get_n() << "|(" << m.get_n1() << "," << m.get_n2() << "))";
+ }
+private:
+ daemon_metric type = daemon_metric::NONE;
+ daemon_metric_t value;
+};
+WRITE_CLASS_DENC(DaemonHealthMetric)