From 61d1b966ea128f176f19d26ac30affe387921240 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 31 Oct 2015 19:26:25 +0100 Subject: [PATCH] teach dnsdist about uptime metric --- pdns/dnsdist-carbon.cc | 5 +++++ pdns/dnsdist.hh | 2 ++ 2 files changed, 7 insertions(+) diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index e9fc295db..69ab9521a 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -10,6 +10,11 @@ #include "dnsdist.hh" GlobalStateHolder g_carbon; +static time_t s_start=time(0); +uint64_t uptimeOfProcess(const std::string& str) +{ + return time(0) - s_start; +} void* carbonDumpThread() try diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 09f8aefd9..c1e743745 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -11,6 +11,7 @@ #include #include "sholder.hh" void* carbonDumpThread(); +uint64_t uptimeOfProcess(const std::string& str); struct DNSDistStats { using stat_t=std::atomic; // aww yiss ;-) @@ -43,6 +44,7 @@ struct DNSDistStats {"latency100-1000", &latency100_1000}, {"latency-slow", &latencySlow}, {"latency-avg100", &latencyAvg100}, {"latency-avg1000", &latencyAvg1000}, {"latency-avg10000", &latencyAvg10000}, {"latency-avg1000000", &latencyAvg1000000}, + {"uptime", uptimeOfProcess}, {"real-memory-usage", getRealMemoryUsage} }; }; -- 2.40.0