Skip to content

Commit

Permalink
dnsdist: report distinct udp and tcp latencies both in the console an…
Browse files Browse the repository at this point in the history
…d the builtin webserver
  • Loading branch information
chbruyand committed Mar 15, 2023
1 parent f8f0911 commit cbd1725
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
21 changes: 12 additions & 9 deletions pdns/dnsdist-lua.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,14 +881,15 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
ostringstream ret;
boost::format fmt;

auto latFmt = boost::format("%5.1f");
if (showUUIDs) {
fmt = boost::format("%1$-3d %15$-36s %2$-20.20s %|62t|%3% %|107t|%4$5s %|88t|%5$7.1f %|103t|%6$7d %|106t|%7$10d %|115t|%8$10d %|117t|%9$10d %|123t|%10$7d %|128t|%11$5.1f %|146t|%12$5.1f %|152t|%13$11d %14%");
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ret << (fmt % "#" % "Name" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Outstanding" % "Pools" % "UUID") << endl;
fmt = boost::format("%1$-3d %15$-36s %2$-20.20s %|62t|%3% %|107t|%4$5s %|88t|%5$7.1f %|103t|%6$7d %|106t|%7$10d %|115t|%8$10d %|117t|%9$10d %|123t|%10$7d %|128t|%11$5.1f %|146t|%12$5s %|152t|%16$5s %|158t|%13$11d %14%");
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (tcp latency)
ret << (fmt % "#" % "Name" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Outstanding" % "Pools" % "UUID" % "TCP") << endl;
}
else {
fmt = boost::format("%1$-3d %2$-20.20s %|25t|%3% %|70t|%4$5s %|51t|%5$7.1f %|66t|%6$7d %|69t|%7$10d %|78t|%8$10d %|80t|%9$10d %|86t|%10$7d %|91t|%11$5.1f %|109t|%12$5.1f %|115t|%13$11d %14%");
ret << (fmt % "#" % "Name" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Outstanding" % "Pools") << endl;
fmt = boost::format("%1$-3d %2$-20.20s %|25t|%3% %|70t|%4$5s %|51t|%5$7.1f %|66t|%6$7d %|69t|%7$10d %|78t|%8$10d %|80t|%9$10d %|86t|%10$7d %|91t|%11$5.1f %|109t|%12$5s %|115t|%15$5s %|121t|%13$11d %14%");
ret << (fmt % "#" % "Name" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Outstanding" % "Pools" % "TCP") << endl;
}

uint64_t totQPS{0}, totQueries{0}, totDrops{0};
Expand All @@ -903,11 +904,13 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
}
pools += p;
}
const std::string latency = (s->latencyUsec == 0.0 ? "-" : boost::str(latFmt % (s->latencyUsec / 1000.0)));
const std::string latencytcp = (s->latencyUsecTCP == 0.0 ? "-" : boost::str(latFmt % (s->latencyUsecTCP / 1000.0)));
if (showUUIDs) {
ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->getRelevantLatencyUsec() / 1000.0) % s->outstanding.load() % pools % *s->d_config.id) << endl;
ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % latency % s->outstanding.load() % pools % *s->d_config.id % latencytcp) << endl;
}
else {
ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->getRelevantLatencyUsec() / 1000.0) % s->outstanding.load() % pools) << endl;
ret << (fmt % counter % s->getName() % s->d_config.remote.toStringWithPort() % status % s->queryLoad % s->qps.getRate() % s->d_config.order % s->d_config.d_weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % latency % s->outstanding.load() % pools % latencytcp) << endl;
}
totQPS += s->queryLoad;
totQueries += s->queries.load();
Expand All @@ -916,12 +919,12 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
}
if (showUUIDs) {
ret << (fmt % "All" % "" % "" % ""
% (double)totQPS % "" % "" % "" % totQueries % totDrops % "" % "" % "" % "" % "")
% (double)totQPS % "" % "" % "" % totQueries % totDrops % "" % "" % "" % "" % "" % "")
<< endl;
}
else {
ret << (fmt % "All" % "" % "" % ""
% (double)totQPS % "" % "" % "" % totQueries % totDrops % "" % "" % "" % "")
% (double)totQPS % "" % "" % "" % totQueries % totDrops % "" % "" % "" % "" % "")
<< endl;
}

Expand Down
7 changes: 4 additions & 3 deletions pdns/dnsdistdist/html/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,12 @@ $(document).ready(function() {
$("#version").text(data["daemon_type"]+" "+data["version"]);
$("#acl").text(data["acl"]);
$("#local").text(data["local"]);
var bouw='<table width="100%"><tr align=right><th>#</th><th align=left>Name</th><th align=left>Address</th><th>Status</th><th>Latency</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>';
var bouw='<table width="100%"><tr align=right><th>#</th><th align=left>Name</th><th align=left>Address</th><th>Status</th><th>UDP Latency</th><th>TCP Latency</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["name"]+"</td><td align=left>"+b["address"]+"</td><td>"+b["state"]+"</td>");
var latency = (b["protocol"].includes("UDP") ? ((b["latency"] === null) ? 0.0 : b["latency"]) : ((b["tcpLatency"] === null) ? 0.0 : b["tcpLatency"]));
bouw = bouw + ("<td>"+latency.toFixed(2)+"</td><td>"+b["queries"]+"</td><td>"+b["reuseds"]+"</td><td>"+(b["qps"]).toFixed(2)+"</td><td>"+b["outstanding"]+"</td>");
var latency = (b["latency"] === null || b["latency"] === 0.0) ? "-" : b["latency"].toFixed(2);
var tcpLatency = (b["tcpLatency"] === null || b["tcpLatency"] === 0.0) ? "-" : b["tcpLatency"].toFixed(2);
bouw = bouw + ("<td>"+latency+"</td><td>"+tcpLatency+"</td><td>"+b["queries"]+"</td><td>"+b["reuseds"]+"</td><td>"+(b["qps"]).toFixed(2)+"</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>";
Expand Down

0 comments on commit cbd1725

Please sign in to comment.