]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: send health_metrics to mgr
authorlvshanchun <lvshanchun@gmail.com>
Tue, 13 Mar 2018 06:42:17 +0000 (14:42 +0800)
committerlvshanchun <lvshanchun@gmail.com>
Wed, 28 Mar 2018 03:08:34 +0000 (11:08 +0800)
Signed-off-by: lvshanchun <lvshanchun@gmail.com>
src/mon/Monitor.cc
src/mon/Monitor.h

index 0b3993773d3f5458c0e127ad5d31b9218bec1a08..c8b00a840980caa554fa0d8f039518c891dba528 100644 (file)
@@ -5439,9 +5439,36 @@ void Monitor::tick()
     paxos->trigger_propose();
   }
 
+  mgr_client.update_daemon_health(get_health_metrics());
   new_tick();
 }
 
+vector<DaemonHealthMetric> Monitor::get_health_metrics() 
+{
+  vector<DaemonHealthMetric> metrics;
+
+  utime_t oldest_secs;
+  const utime_t now = ceph_clock_now();
+  auto too_old = now;
+  too_old -= g_conf->get_val<double>("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;
index 5c6269056747e0695471ab721918c4f9428b395b..1acf69cc31a85aa64d0728fc870ea46f4761a43e 100644 (file)
@@ -216,6 +216,8 @@ public:
 
   void prepare_new_fingerprint(MonitorDBStore::TransactionRef t);
 
+  std::vector<DaemonHealthMetric> get_health_metrics();
+
   // -- elector --
 private:
   Paxos *paxos;