From fcadd56e6bc0dd56f385b1c6b0faca3b4e691d39 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 31 Mar 2015 16:03:12 +0200 Subject: [PATCH] hook up complete latency to html, cleanup html --- pdns/dnsdist-web.cc | 38 +++++++++++++++++++++++--------- pdns/dnsdist.cc | 5 ++++- pdns/dnsdist.hh | 1 + pdns/dnsdistdist/html/index.html | 9 +------- pdns/dnsdistdist/html/local.js | 15 ++++++++++--- 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 2d1213aef..61e2de6e3 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -96,10 +96,10 @@ static void connectionThread(int sock, ComboAddress remote, string password) { "over-capacity-drops", 0 }, { "too-old-drops", 0 }, { "uptime", uptimeOfProcess()}, - { "qa-latency", 1234}, + { "qa-latency", (int)g_stats.latency}, { "something", Json::array { 1, 2, 3 } }, }; - + cout<upStatus ? "up" : "down"); - + string pools; + for(const auto& p: a->pools) + pools+=p+" "; Json::object server{ {"id", num++}, {"address", a->remote.toStringWithPort()}, {"state", status}, - {"qps", (int)a->queryLoad}, - {"qpsLimit", (int)a->qps.getRate()}, - {"outstanding", (int)a->outstanding}, - {"weight", (int)a->weight}, - {"order", (int)a->order}, - {"queries", (int)a->queries}}; + {"qps", (int)a->queryLoad}, + {"qpsLimit", (int)a->qps.getRate()}, + {"outstanding", (int)a->outstanding}, + {"reuseds", (int)a->reuseds}, + {"weight", (int)a->weight}, + {"order", (int)a->order}, + {"pools", pools}, + {"queries", (int)a->queries}}; servers.push_back(server); } + + Json::array rules; + auto localRules = g_rulactions.getCopy(); + num=0; + for(const auto& a : localRules) { + Json::object rule{ + {"id", num++}, + {"matches", (int)a.first->d_matches}, + {"rule", a.first->toString()}, + {"action", a.second->toString()} }; + rules.push_back(rule); + } + Json my_json = Json::object { { "daemon_type", "dnsdist" }, { "version", "0.1"}, - { "servers", servers} + { "servers", servers}, + { "rules", rules}, }; resp.headers["Content-Type"] = "application/json"; resp.body=my_json.dump(); diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index da6914cc2..23178c336 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -142,6 +142,8 @@ void* responderThread(std::shared_ptr state) g_stats.servfailResponses++; state->latencyUsec = (127.0 * state->latencyUsec / 128.0) + udiff/128.0; + g_stats.latency = (1023.0*g_stats.latency/1024.0) + udiff/1024.0; + ids->origFD = -1; } return 0; @@ -696,7 +698,7 @@ catch(...) void* maintThread() { - int interval = 2; + int interval = 1; for(;;) { sleep(interval); @@ -1040,6 +1042,7 @@ struct int main(int argc, char** argv) try { + g_stats.latency=0; rl_attempted_completion_function = my_completion; rl_completion_append_character = 0; diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 3598041c2..e465c1198 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -23,6 +23,7 @@ struct DNSDistStats stat_t selfAnswered{0}; stat_t downstreamTimeouts{0}; stat_t downstreamSendErrors{0}; + double latency{0}; }; diff --git a/pdns/dnsdistdist/html/index.html b/pdns/dnsdistdist/html/index.html index 2389f2521..82530da3f 100644 --- a/pdns/dnsdistdist/html/index.html +++ b/pdns/dnsdistdist/html/index.html @@ -13,7 +13,7 @@ -Fork me on GitHub @@ -51,8 +51,6 @@ alt="Fork me on GitHub">

Version: , uptime: , Number of queries: ( qps)
-Over-capacity-drops: , too old:
-Packet cache hitrate: %, Average response time: ms, CPU Usage: %

@@ -80,11 +78,6 @@ Average response time: ms, CPU Usage:
- - - - - diff --git a/pdns/dnsdistdist/html/local.js b/pdns/dnsdistdist/html/local.js index 210bb9896..68089027b 100644 --- a/pdns/dnsdistdist/html/local.js +++ b/pdns/dnsdistdist/html/local.js @@ -186,14 +186,23 @@ $(document).ready(function() { $.ajax({ url: '/servers/localhost', type: 'GET', dataType: 'json', success: function(data) { $("#version").text("PowerDNS "+data["daemon_type"]+" "+data["version"]); - var bouw="
Public filtered:
Public filtered:
"; + var bouw="
#AddressStatusQueriesQPSOutstandingWeightOrder
"; $.each(data["servers"], function(a,b) { bouw = bouw + (""); - bouw = bouw + (""); - bouw = bouw + (""); + bouw = bouw + (""); + bouw = bouw + (""); }); bouw = bouw + "
#AddressStatusQueriesDropsQPSOutWeightOrderPools
"+b["id"]+""+b["address"]+""+b["state"]+""+b["queries"]+""+b["qps"]+""+b["outstanding"]+""+b["weight"]+""+b["order"]+"
"+b["queries"]+""+b["reuseds"]+""+b["qps"]+""+b["outstanding"]+""+b["weight"]+""+b["order"]+""+b["pools"]+"
"; $("#queryring").html(bouw); + + bouw=""; + $.each(data["rules"], function(a,b) { + bouw = bouw + (""); + bouw = bouw + (""); + }); + bouw = bouw + "
#RuleActionMatches
"+b["id"]+""+b["rule"]+""+b["action"]+""+b["matches"]+"
"; + $("#remotering").html(bouw); + } }); -- 2.49.0