From e0dedf173f0e6667474ca369d6934006e0dae113 Mon Sep 17 00:00:00 2001 From: lvshanchun Date: Tue, 13 Mar 2018 14:42:17 +0800 Subject: [PATCH] mon: send health_metrics to mgr Signed-off-by: lvshanchun --- src/mon/Monitor.cc | 27 +++++++++++++++++++++++++++ src/mon/Monitor.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 0b3993773d3f5..c8b00a840980c 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -5439,9 +5439,36 @@ void Monitor::tick() paxos->trigger_propose(); } + mgr_client.update_daemon_health(get_health_metrics()); new_tick(); } +vector Monitor::get_health_metrics() +{ + vector metrics; + + utime_t oldest_secs; + const utime_t now = ceph_clock_now(); + auto too_old = now; + too_old -= g_conf->get_val("mon_op_complaint_time"); + int slow = 0; + + auto count_slow_ops = [&](TrackedOp& op) { + if (op.get_initiated() < too_old) { + slow++; + return true; + } else { + return false; + } + }; + if (op_tracker.visit_ops_in_flight(&oldest_secs, count_slow_ops)) { + metrics.emplace_back(daemon_metric::SLOW_OPS, slow, oldest_secs); + } else { + metrics.emplace_back(daemon_metric::SLOW_OPS, 0, 0); + } + return metrics; +} + void Monitor::prepare_new_fingerprint(MonitorDBStore::TransactionRef t) { uuid_d nf; diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 5c6269056747e..1acf69cc31a85 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -216,6 +216,8 @@ public: void prepare_new_fingerprint(MonitorDBStore::TransactionRef t); + std::vector get_health_metrics(); + // -- elector -- private: Paxos *paxos; -- 2.39.5