]> granicus.if.org Git - pdns/commitdiff
hook up complete latency to html, cleanup html
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 31 Mar 2015 14:03:12 +0000 (16:03 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 31 Mar 2015 14:03:12 +0000 (16:03 +0200)
pdns/dnsdist-web.cc
pdns/dnsdist.cc
pdns/dnsdist.hh
pdns/dnsdistdist/html/index.html
pdns/dnsdistdist/html/local.js

index 2d1213aefd400dbe73e098160b68da1a56580fe7..61e2de6e31229f8dbfcb175c23cdb1b9b81f22ad 100644 (file)
@@ -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<<g_stats.latency<<endl;
     resp.headers["Content-Type"] = "application/json";
     resp.body=my_json.dump();
   }
@@ -117,25 +117,43 @@ static void connectionThread(int sock, ComboAddress remote, string password)
        status = "DOWN";
       else 
        status = (a->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();
index da6914cc2939f0bedf8d1ff80629b89235c350f5..23178c3364ca35368695f474199bf39c67e228b4 100644 (file)
@@ -142,6 +142,8 @@ void* responderThread(std::shared_ptr<DownstreamState> 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;
 
index 3598041c2b883f930a5d40543858ea94c1ce8e54..e465c1198c3db7a4f17e52386134f7cd36f2cf7f 100644 (file)
@@ -23,6 +23,7 @@ struct DNSDistStats
   stat_t selfAnswered{0};
   stat_t downstreamTimeouts{0};
   stat_t downstreamSendErrors{0};
+  double latency{0};
   
 };
 
index 2389f25216ac8be639896938c9b93cb85a83a408..82530da3f4e3f7933cbb1c20e0e12404ae906c36 100644 (file)
@@ -13,7 +13,7 @@
 
 <script src="local.js"></script>
 <body>                                                                  
-<a href="https://github.com/ahuPowerDNS/recuweb"><img style="position: absolute; top: 0;
+<a href="https://github.com/ahuPowerDNS/pdns"><img style="position: absolute; top: 0;
 right: 0; border: 0;"
 src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png"
 alt="Fork me on GitHub"></a>
@@ -51,8 +51,6 @@ alt="Fork me on GitHub"></a>
 </tr></table>
 <p>
 Version: <span id="version"></span>, uptime: <span id="uptime"></span>, Number of queries: <span id="questions"></span> (<span id="qps"></span> qps)<br/>
-Over-capacity-drops: <span id="over-capacity-drops"></span>, too old: <span id="too-old"></span><br/>
-Packet cache hitrate: <span id="phitrate"></span>%, 
 Average response time: <span id="latency"></span> ms, CPU Usage: <span id="cpu"></span>% <br/>
 </p>
 <table width="100%" cellpadding="20">
@@ -80,11 +78,6 @@ Average response time: <span id="latency"></span> ms, CPU Usage: <span id="cpu">
     <td>
       <table cellpadding="15">
        <tr>
-         <td><form>Public filtered: <input id="filter1" type="checkbox"></input></form></td>
-         <td><form>Public filtered: <input id="filter2" type="checkbox"></input></form></td>
-       </tr>
-       <tr>
-       
          <td><div id="queryring"></div> </td>
          <td><div id="servfailqueryring"></div></td>
        </tr>
index 210bb98960eb01afe36307d44bf87f3b337246f9..68089027bf939695d6c8bd54d47ed0a808e68ad7 100644 (file)
@@ -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="<table><tr align=right><th>#</th><th align=left>Address</th><th>Status</th><th>Queries</th><th>QPS</th><th>Outstanding</th><th>Weight</th><th>Order</th></tr>";
+                    var bouw="<table><tr align=right><th>#</th><th align=left>Address</th><th>Status</th><th>Queries</th><th>Drops</th><th>QPS</th><th>Out</th><th>Weight</th><th>Order</th><th align=left>Pools</th></tr>";
                     $.each(data["servers"], function(a,b) {
                         bouw = bouw + ("<tr align=right><td>"+b["id"]+"</td><td align=left>"+b["address"]+"</td><td>"+b["state"]+"</td>");
-                         bouw = bouw + ("<td>"+b["queries"]+"</td><td>"+b["qps"]+"</td><td>"+b["outstanding"]+"</td>");
-                         bouw = bouw + ("<td>"+b["weight"]+"</td><td>"+b["order"]+"</td></tr>");
+                         bouw = bouw + ("<td>"+b["queries"]+"</td><td>"+b["reuseds"]+"</td><td>"+b["qps"]+"</td><td>"+b["outstanding"]+"</td>");
+                         bouw = bouw + ("<td>"+b["weight"]+"</td><td>"+b["order"]+"</td><td align=left>"+b["pools"]+"</td></tr>");
                         }); 
                      bouw = bouw + "</table>";
                      $("#queryring").html(bouw);
+
+                    bouw="<table><tr align=left><th>#</th><th align=left>Rule</th><th>Action</th><th>Matches</th></tr>";
+                    $.each(data["rules"], function(a,b) {
+                        bouw = bouw + ("<tr align=left><td>"+b["id"]+"</td><td align=left>"+b["rule"]+"</td><td>"+b["action"]+"</td>");
+                         bouw = bouw + ("<td>"+b["matches"]+"</td></tr>");
+                        }); 
+                     bouw = bouw + "</table>";
+                     $("#remotering").html(bouw);
+
                      
                 }
               });