str<<"dnsdist."<<hostname<<".main."<<e.first<<' ';
if(const auto& val = boost::get<DNSDistStats::stat_t*>(&e.second))
str<<(*val)->load();
+ else if (const auto& val = boost::get<double*>(&e.second))
+ str<<**val;
else
- str<<*boost::get<double*>(e.second);
+ str<<(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first);
str<<' '<<now<<"\r\n";
}
const string msg = str.str();
-
+
int ret = waitForRWData(s.getHandle(), false, 1 , 0);
if(ret <= 0 ) {
infolog("Unable to write data to carbon server on %s: %s", localCarbon->server.toStringWithPort(), (ret<0 ? strerror(errno) : "Timeout"));
static int setupTCPDownstream(const ComboAddress& remote)
{
-
vinfolog("TCP connecting to downstream %s", remote.toStringWithPort());
int sock = SSocket(remote.sin4.sin_family, SOCK_STREAM, 0);
SConnect(sock, remote);
return sock;
}
-
struct ConnectionInfo
{
int fd;
void* tcpClientThread(int pipefd);
-
- // Should not be called simultaneously!
+// Should not be called simultaneously!
void TCPClientCollection::addTCPClientThread()
{
vinfolog("Adding TCP Client thread");
typedef std::function<bool(ComboAddress, DNSName, uint16_t, dnsheader*)> blockfilter_t;
blockfilter_t blockFilter = 0;
-
{
std::lock_guard<std::mutex> lock(g_luamutex);
ds->queries++;
ds->outstanding++;
- if(qtype == QType::AXFR) // XXX fixme we really need to do better
+ if(qtype == QType::AXFR || qtype == QType::IXFR) // XXX fixme we really need to do better
break;
retry:;
stat_t latency0_1{0}, latency1_10{0}, latency10_50{0}, latency50_100{0}, latency100_1000{0}, latencySlow{0};
double latencyAvg100{0}, latencyAvg1000{0}, latencyAvg10000{0}, latencyAvg1000000{0};
- typedef boost::variant<stat_t*, double*> entry_t;
+ typedef std::function<uint64_t(const std::string&)> statfunction_t;
+ typedef boost::variant<stat_t*, double*, statfunction_t> entry_t;
std::vector<std::pair<std::string, entry_t>> entries{
{"responses", &responses}, {"servfail-responses", &servfailResponses},
{"queries", &queries}, {"acl-drops", &aclDrops},
{"latency10-50", &latency10_50}, {"latency50-100", &latency50_100},
{"latency100-1000", &latency100_1000}, {"latency-slow", &latencySlow},
{"latency-avg100", &latencyAvg100}, {"latency-avg1000", &latencyAvg1000},
- {"latency-avg10000", &latencyAvg10000}, {"latency-avg1000000", &latencyAvg1000000}
+ {"latency-avg10000", &latencyAvg10000}, {"latency-avg1000000", &latencyAvg1000000},
+ {"real-memory-usage", getRealMemoryUsage}
};
};
}
throw PDNSException("getTSIGAlgoName does not understand given algorithm, please fix!");
}
+
+uint64_t getRealMemoryUsage(const std::string&)
+{
+#ifdef __linux__
+ ifstream ifs("/proc/"+std::to_string(getpid())+"/smaps");
+ if(!ifs)
+ return 0;
+ string line;
+ uint64_t bytes=0;
+ string header("Private_Dirty:");
+ while(getline(ifs, line)) {
+ if(boost::starts_with(line, header)) {
+ bytes += atoi(line.c_str() + header.length() +1)*1024;
+ }
+ }
+ return bytes;
+#else
+ return 0;
+#endif
+}
bool setCloseOnExec(int sock);
uint64_t udpErrorStats(const std::string& str);
+uint64_t getRealMemoryUsage(const std::string&);
+
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{