From: lvshanchun Date: Tue, 13 Mar 2018 06:42:17 +0000 (+0800) Subject: mon: send health_metrics to mgr X-Git-Tag: wip-pdonnell-testing-20180329.205607~23^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=e0dedf173f0e6667474ca369d6934006e0dae113;p=ceph-ci.git mon: send health_metrics to mgr Signed-off-by: lvshanchun --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 0b3993773d3..c8b00a84098 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 5c626905674..1acf69cc31a 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;