From c690dd2a34db154d410c4b48941423396ef0345f Mon Sep 17 00:00:00 2001 From: sorz Date: Mon, 19 Nov 2018 23:47:27 +0800 Subject: [PATCH] Add alive/total connections status to graphite --- src/monitor/mod.rs | 2 ++ src/proxy/mod.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/monitor/mod.rs b/src/monitor/mod.rs index afe6eae..5910395 100644 --- a/src/monitor/mod.rs +++ b/src/monitor/mod.rs @@ -154,6 +154,8 @@ fn send_metrics(monitor: Monitor, handle: Handle) server.score().map(|s| r("score", s as u64)), Some(r("tx_bytes", traffic.tx_bytes as u64)), Some(r("rx_bytes", traffic.rx_bytes as u64)), + Some(r("conns.total", server.conn_total() as u64)), + Some(r("conns.alive", server.conn_alive() as u64)), ] }).filter_map(|v| v); let mut buf = Vec::new(); diff --git a/src/proxy/mod.rs b/src/proxy/mod.rs index 0301f86..f1bff65 100644 --- a/src/proxy/mod.rs +++ b/src/proxy/mod.rs @@ -199,6 +199,14 @@ impl ProxyServer { self.status().score } + pub fn conn_alive(&self) -> u32 { + self.status().conn_alive + } + + pub fn conn_total(&self) -> u32 { + self.status().conn_total + } + pub fn set_delay(&self, delay: Option) { self.status().delay = delay; self.status().score =