return time(0) - s_start;
}
-void* carbonDumpThread()
+void carbonDumpThread()
try
{
setThreadName("dnsdist/carbon");
for (const auto& conf : *localCarbon) {
const auto& server = conf.server;
+ const std::string& namespace_name = conf.namespace_name;
std::string hostname = conf.ourname;
if(hostname.empty()) {
char tmp[80];
hostname=tmp;
boost::replace_all(hostname, ".", "_");
}
+ const std::string& instance_name = conf.instance_name;
try {
Socket s(server.sin4.sin_family, SOCK_STREAM);
ostringstream str;
time_t now=time(0);
for(const auto& e : g_stats.entries) {
- str<<"dnsdist."<<hostname<<".main."<<e.first<<' ';
+ str<<namespace_name<<"."<<hostname<<"."<<instance_name<<"."<<e.first<<' ';
if(const auto& val = boost::get<DNSDistStats::stat_t*>(&e.second))
str<<(*val)->load();
else if (const auto& dval = boost::get<double*>(&e.second))
for(const auto& state : *states) {
string serverName = state->name.empty() ? (state->remote.toString() + ":" + std::to_string(state->remote.getPort())) : state->getName();
boost::replace_all(serverName, ".", "_");
- const string base = "dnsdist." + hostname + ".main.servers." + serverName + ".";
+ const string base = namespace_name + "." + hostname + "." + instance_name + ".servers." + serverName + ".";
str<<base<<"queries" << ' ' << state->queries.load() << " " << now << "\r\n";
str<<base<<"drops" << ' ' << state->reuseds.load() << " " << now << "\r\n";
str<<base<<"latency" << ' ' << (state->availability != DownstreamState::Availability::Down ? state->latencyUsec/1000.0 : 0) << " " << now << "\r\n";
str<<base<<"senderrors" << ' ' << state->sendErrors.load() << " " << now << "\r\n";
str<<base<<"outstanding" << ' ' << state->outstanding.load() << " " << now << "\r\n";
+ str<<base<<"tcpdiedsendingquery" << ' '<< state->tcpDiedSendingQuery.load() << " " << now << "\r\n";
+ str<<base<<"tcpdiedreaddingresponse" << ' '<< state->tcpDiedReadingResponse.load() << " " << now << "\r\n";
+ str<<base<<"tcpgaveup" << ' '<< state->tcpGaveUp.load() << " " << now << "\r\n";
+ str<<base<<"tcpreadimeouts" << ' '<< state->tcpReadTimeouts.load() << " " << now << "\r\n";
+ str<<base<<"tcpwritetimeouts" << ' '<< state->tcpWriteTimeouts.load() << " " << now << "\r\n";
}
for(const auto& front : g_frontends) {
if (front->udpFD == -1 && front->tcpFD == -1)
string frontName = front->local.toString() + ":" + std::to_string(front->local.getPort()) + (front->udpFD >= 0 ? "_udp" : "_tcp");
boost::replace_all(frontName, ".", "_");
- const string base = "dnsdist." + hostname + ".main.frontends." + frontName + ".";
+ const string base = namespace_name + "." + hostname + "." + instance_name + ".frontends." + frontName + ".";
str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
+ str<<base<<"tcpdiedreadingquery" << ' '<< front->tcpDiedReadingQuery.load() << " " << now << "\r\n";
+ str<<base<<"tcpdiedsendingresponse" << ' '<< front->tcpDiedSendingResponse.load() << " " << now << "\r\n";
+ str<<base<<"tcpgaveup" << ' '<< front->tcpGaveUp.load() << " " << now << "\r\n";
+ str<<base<<"tcpclientimeouts" << ' '<< front->tcpClientTimeouts.load() << " " << now << "\r\n";
+ str<<base<<"tcpdownstreamtimeouts" << ' '<< front->tcpDownstreamTimeouts.load() << " " << now << "\r\n";
}
auto localPools = g_pools.getLocal();
for (const auto& entry : *localPools) {
if (poolName.empty()) {
poolName = "_default_";
}
- const string base = "dnsdist." + hostname + ".main.pools." + poolName + ".";
+ const string base = namespace_name + "." + hostname + "." + instance_name + ".pools." + poolName + ".";
const std::shared_ptr<ServerPool> pool = entry.second;
str<<base<<"servers" << " " << pool->countServers(false) << " " << now << "\r\n";
str<<base<<"servers-up" << " " << pool->countServers(true) << " " << now << "\r\n";
}
}
}
- return 0;
}
catch(std::exception& e)
{
errlog("Carbon thread died: %s", e.what());
- return 0;
}
catch(PDNSException& e)
{
errlog("Carbon thread died, PDNSException: %s", e.reason);
- return 0;
}
catch(...)
{
errlog("Carbon thread died");
- return 0;
}