newServer {address="2001:4860:4860::8888", qps=1}
newServer {address="2001:4860:4860::8844", qps=1}
newServer {address="2620:0:ccc::2", qps=10}
-newServer {address="2620:0:ccd::2", qps=10}
+newServer {address="2620:0:ccd::2", name="dns1", qps=10}
newServer("192.168.1.2")
setServerPolicy(firstAvailable) -- first server within its QPS limit
* `errlog(string)`: log at level error
* Server related:
* `newServer("ip:port")`: instantiate a new downstream server with default settings
- * `newServer({address="ip:port", qps=1000, order=1, weight=10, pool="abuse", retries=5, tcpSendTimeout=30, tcpRecvTimeout=30})`: instantiate
+ * `newServer({address="ip:port", name="dns1", qps=1000, order=1, weight=10, pool="abuse", retries=5, tcpSendTimeout=30, tcpRecvTimeout=30})`: instantiate
a server with additional parameters
* `showServers()`: output all servers
* `getServer(n)`: returns server with index n
}
const auto states = g_dstates.getCopy();
for(const auto& s : states) {
- string serverName = s->remote.toString();
+ string serverName = s->getName();
boost::replace_all(serverName, ".", "_");
const string base = "dnsdist." + hostname + ".main.servers." + serverName + ".";
str<<base<<"queries" << ' ' << s->queries.load() << " " << now << "\r\n";
ret->tcpRecvTimeout=boost::lexical_cast<int>(boost::get<string>(vars["tcpRecvTimeout"]));
}
+ if(vars.count("name")) {
+ ret->name=boost::get<string>(vars["name"]);
+ }
+
if(g_launchWork) {
g_launchWork->push_back([ret]() {
ret->tid = move(thread(responderThread, ret));
try {
ostringstream ret;
- boost::format fmt("%1$-3d %2% %|30t|%3$5s %|36t|%4$7.1f %|41t|%5$7d %|44t|%6$3d %|53t|%7$2d %|55t|%8$10d %|61t|%9$7d %|76t|%10$5.1f %|84t|%11$5.1f %12%" );
- // 1 2 3 4 5 6 7 8 9 10 11
- ret << (fmt % "#" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Pools") << endl;
+ boost::format fmt("%1$-3d %2$-20s %3% %|40t|%4$5s %|36t|%5$7.1f %|41t|%6$7d %|44t|%7$3d %|53t|%8$2d %|55t|%9$10d %|61t|%10$7d %|76t|%11$5.1f %|84t|%12$5.1f %13%" );
+ // 1 2 3 4 5 6 7 8 9 10 11 12
+ ret << (fmt % "#" % "Name" % "Address" % "State" % "Qps" % "Qlim" % "Ord" % "Wt" % "Queries" % "Drops" % "Drate" % "Lat" % "Pools") << endl;
uint64_t totQPS{0}, totQueries{0}, totDrops{0};
int counter=0;
pools+=p;
}
- ret << (fmt % counter % s->remote.toStringWithPort() %
+ ret << (fmt % counter % s->name % s->remote.toStringWithPort() %
status %
s->queryLoad % s->qps.getRate() % s->order % s->weight % s->queries.load() % s->reuseds.load() % (s->dropRate) % (s->latencyUsec/1000.0) % pools) << endl;
totDrops += s->reuseds.load();
++counter;
}
- ret<< (fmt % "All" % "" % ""
+ ret<< (fmt % "All" % "" % "" % ""
%
(double)totQPS % "" % "" % "" % totQueries % totDrops % "" % "" % "" ) << endl;
}
if (ds->retries > 0 && downstream_failures > ds->retries) {
- vinfolog("Downstream connection to %s failed %d times in a row, giving up.", ds->remote.toStringWithPort(), downstream_failures);
+ vinfolog("Downstream connection to %s failed %d times in a row, giving up.", ds->getName(), downstream_failures);
close(dsock);
sockets.erase(ds->remote);
break;
}
if(!putNonBlockingMsgLen(dsock, qlen, ds->tcpSendTimeout)) {
- vinfolog("Downstream connection to %s died on us, getting a new one!", ds->remote.toStringWithPort());
+ vinfolog("Downstream connection to %s died on us, getting a new one!", ds->getName());
close(dsock);
sockets[ds->remote]=dsock=setupTCPDownstream(ds->remote);
downstream_failures++;
writen2WithTimeout(dsock, query, qlen, ds->tcpSendTimeout);
if(!getNonBlockingMsgLen(dsock, &rlen, ds->tcpRecvTimeout)) {
- vinfolog("Downstream connection to %s died on us phase 2, getting a new one!", ds->remote.toStringWithPort());
+ vinfolog("Downstream connection to %s died on us phase 2, getting a new one!", ds->getName());
close(dsock);
sockets[ds->remote]=dsock=setupTCPDownstream(ds->remote);
downstream_failures++;
pools+=p+" ";
Json::object server{
{"id", num++},
+ {"name", a->name},
{"address", a->remote.toStringWithPort()},
{"state", status},
{"qps", (int)a->queryLoad},
g_stats.downstreamSendErrors++;
}
- vinfolog("Got query from %s, relayed to %s", remote.toStringWithPort(), ss->remote.toStringWithPort());
+ vinfolog("Got query from %s, relayed to %s", remote.toStringWithPort(), ss->getName());
}
catch(std::exception& e){
errlog("Got an error in UDP question thread: %s", e.what());
if(dss->availability==DownstreamState::Availability::Auto) {
bool newState=upCheck(dss->remote);
if(newState != dss->upStatus) {
- warnlog("Marking downstream %s as '%s'", dss->remote.toStringWithPort(), newState ? "up" : "down");
+ warnlog("Marking downstream %s as '%s'", dss->getName(), newState ? "up" : "down");
}
dss->upStatus = newState;
}
if(ret) {
if (const auto strValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
- response=(*strValue)->remote.toStringWithPort();
+ response=(*strValue)->getName();
}
else if (const auto strValue = boost::get<string>(&*ret)) {
response=*strValue;
if(ret) {
if (const auto strValue = boost::get<shared_ptr<DownstreamState>>(&*ret)) {
- cout<<(*strValue)->remote.toStringWithPort()<<endl;
+ cout<<(*strValue)->getName()<<endl;
}
else if (const auto strValue = boost::get<string>(&*ret)) {
cout<<*strValue<<endl;
for(auto& dss : g_dstates.getCopy()) { // it is a copy, but the internal shared_ptrs are the real deal
if(dss->availability==DownstreamState::Availability::Auto) {
bool newState=upCheck(dss->remote);
- warnlog("Marking downstream %s as '%s'", dss->remote.toStringWithPort(), newState ? "up" : "down");
+ warnlog("Marking downstream %s as '%s'", dss->getName(), newState ? "up" : "down");
dss->upStatus = newState;
}
}
std::atomic<uint64_t> reuseds{0};
std::atomic<uint64_t> queries{0};
} prev;
+ string name;
double queryLoad{0.0};
double dropRate{0.0};
double latencyUsec{0.0};
void setUp() { availability = Availability::Up; }
void setDown() { availability = Availability::Down; }
void setAuto() { availability = Availability::Auto; }
+ string getName() const {
+ if (name.empty()) {
+ return remote.toStringWithPort();
+ }
+ return name;
+ }
};
using servers_t =vector<std::shared_ptr<DownstreamState>>;
$.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>Drops</th><th>QPS</th><th>Out</th><th>Weight</th><th>Order</th><th align=left>Pools</th></tr>";
+ var bouw="<table><tr align=right><th>#</th><th align=left>Name</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 + ("<tr align=right><td>"+b["id"]+"</td><td align=left>"+b["name"]+"</td><td align=left>"+b["address"]+"</td><td>"+b["state"]+"</td>");
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>");
});