}
/* if the existing entry had a longer TTD, keep it */
- if (newValidity <= value.validity)
+ if (newValidity <= value.validity) {
return;
+ }
value = newValue;
}
ReadLock r(&d_lock);
return std::to_string(d_map.size()) + "/" + std::to_string(d_maxEntries);
}
+
+uint64_t DNSDistPacketCache::getEntriesCount()
+{
+ ReadLock r(&d_lock);
+ return d_map.size();
+}
void expungeByName(const DNSName& name, uint16_t qtype=QType::ANY);
bool isFull();
string toString();
- uint64_t getSize() const { return d_map.size(); };
- uint64_t getHits() const { return d_hits; };
- uint64_t getMisses() const { return d_misses; };
- uint64_t getDeferredLookups() const { return d_deferredLookups; };
- uint64_t getDeferredInserts() const { return d_deferredInserts; };
- uint64_t getLookupCollisions() const { return d_lookupCollisions; };
- uint64_t getInsertCollisions() const { return d_insertCollisions; };
+ uint64_t getSize() const { return d_map.size(); }
+ uint64_t getHits() const { return d_hits; }
+ uint64_t getMisses() const { return d_misses; }
+ uint64_t getDeferredLookups() const { return d_deferredLookups; }
+ uint64_t getDeferredInserts() const { return d_deferredInserts; }
+ uint64_t getLookupCollisions() const { return d_lookupCollisions; }
+ uint64_t getInsertCollisions() const { return d_insertCollisions; }
+ uint64_t getMaxEntries() const { return d_maxEntries; }
+ uint64_t getEntriesCount();
static uint32_t getMinTTL(const char* packet, uint16_t length);
const string base = "dnsdist." + hostname + ".main.frontends." + frontName + ".";
str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
}
+ const auto localPools = g_pools.getCopy();
+ for (const auto& entry : localPools) {
+ string poolName = entry.first;
+ boost::replace_all(poolName, ".", "_");
+ if (poolName.empty()) {
+ poolName = "_default_";
+ }
+ const string base = "dnsdist." + hostname + ".main.pools." + poolName + ".";
+ const std::shared_ptr<ServerPool> pool = entry.second;
+ str<<base<<"servers" << " " << pool->servers.size() << " " << now << "\r\n";
+ if (pool->packetCache != nullptr) {
+ const auto& cache = pool->packetCache;
+ str<<base<<"cache-size" << " " << cache->getMaxEntries() << " " << now << "\r\n";
+ str<<base<<"cache-entries" << " " << cache->getEntriesCount() << " " << now << "\r\n";
+ str<<base<<"cache-hits" << " " << cache->getHits() << " " << now << "\r\n";
+ str<<base<<"cache-misses" << " " << cache->getMisses() << " " << now << "\r\n";
+ str<<base<<"cache-deferred-inserts" << " " << cache->getDeferredInserts() << " " << now << "\r\n";
+ str<<base<<"cache-deferred-lookups" << " " << cache->getDeferredLookups() << " " << now << "\r\n";
+ str<<base<<"cache-lookup-collisions" << " " << cache->getLookupCollisions() << " " << now << "\r\n";
+ str<<base<<"cache-insert-collisions" << " " << cache->getInsertCollisions() << " " << now << "\r\n";
+ }
+ }
const string msg = str.str();
int ret = waitForRWData(s.getHandle(), false, 1 , 0);
});
g_lua.registerFunction<void(std::shared_ptr<DNSDistPacketCache>::*)()>("printStats", [](const std::shared_ptr<DNSDistPacketCache> cache) {
if (cache) {
- g_outputBuffer="Hits: " + std::to_string(cache->getHits()) + "\n";
+ g_outputBuffer="Entries: " + std::to_string(cache->getEntriesCount()) + "/" + std::to_string(cache->getMaxEntries()) + "\n";
+ g_outputBuffer+="Hits: " + std::to_string(cache->getHits()) + "\n";
g_outputBuffer+="Misses: " + std::to_string(cache->getMisses()) + "\n";
g_outputBuffer+="Deferred inserts: " + std::to_string(cache->getDeferredInserts()) + "\n";
g_outputBuffer+="Deferred lookups: " + std::to_string(cache->getDeferredLookups()) + "\n";