From 405b355ccec34c0a6e8965cd97e96e48bfd15540 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Tue, 24 May 2022 16:59:42 +0200 Subject: [PATCH] dnsdist: add a statistic for the number of cache cleanups --- pdns/dnsdist-cache.cc | 1 + pdns/dnsdist-cache.hh | 2 ++ pdns/dnsdist-carbon.cc | 1 + pdns/dnsdist-web.cc | 7 +++++-- pdns/dnsdistdist/dnsdist-lua-bindings-packetcache.cc | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist-cache.cc b/pdns/dnsdist-cache.cc index d6b99a0790..7222a29162 100644 --- a/pdns/dnsdist-cache.cc +++ b/pdns/dnsdist-cache.cc @@ -298,6 +298,7 @@ size_t DNSDistPacketCache::purgeExpired(size_t upTo, const time_t now) size_t removed = 0; + d_cleanupCount++; for (auto& shard : d_shards) { auto map = shard.d_map.write_lock(); if (map->size() <= maxPerShard) { diff --git a/pdns/dnsdist-cache.hh b/pdns/dnsdist-cache.hh index 3309459ecb..23b321375c 100644 --- a/pdns/dnsdist-cache.hh +++ b/pdns/dnsdist-cache.hh @@ -53,6 +53,7 @@ public: uint64_t getInsertCollisions() const { return d_insertCollisions; } uint64_t getMaxEntries() const { return d_maxEntries; } uint64_t getTTLTooShorts() const { return d_ttlTooShorts; } + uint64_t getCleanupCount() const { return d_cleanupCount; } uint64_t getEntriesCount(); uint64_t dump(int fd); void setSkippedOptions(const std::unordered_set& optionsToSkip); @@ -130,6 +131,7 @@ private: pdns::stat_t d_insertCollisions{0}; pdns::stat_t d_lookupCollisions{0}; pdns::stat_t d_ttlTooShorts{0}; + pdns::stat_t d_cleanupCount{0}; size_t d_maxEntries; uint32_t d_shardCount; diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index cdad9dd69a..e8048ed174 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -182,6 +182,7 @@ void carbonDumpThread() str<getLookupCollisions() << " " << now << "\r\n"; str<getInsertCollisions() << " " << now << "\r\n"; str<getTTLTooShorts() << " " << now << "\r\n"; + str<getCleanupCount() << " " << now << "\r\n"; } } diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index a60adaf216..5edc46114f 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -787,6 +787,7 @@ static void handlePrometheus(const YaHTTP::Request& req, YaHTTP::Response& resp) output << cachebase << "cache_lookup_collisions" <