]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add showTCPStats function
authorRobin Geuze <robing@transip.nl>
Fri, 12 Aug 2016 08:19:29 +0000 (10:19 +0200)
committerRobin Geuze <robing@transip.nl>
Fri, 12 Aug 2016 08:19:29 +0000 (10:19 +0200)
pdns/dnsdist-console.cc
pdns/dnsdist-lua.cc

index 4a7f05412a8f1d8caf679c606ccb36c896144d05..d3611ff5727476a19b864da5b949d1903f98dade 100644 (file)
@@ -316,6 +316,7 @@ const std::vector<ConsoleKeyword> g_consoleKeywords{
   { "showRules", true, "", "show all defined rules" },
   { "showServerPolicy", true, "", "show name of currently operational server selection policy" },
   { "showServers", true, "", "output all servers" },
+  { "showTCPStats", true, "", "show some statistics regarding TCP" },
   { "showVersion", true, "", "show the current version" },
   { "shutdown", true, "", "shut down `dnsdist`" },
   { "SpoofAction", true, "{ip, ...} ", "forge a response with the specified IPv4 (for an A query) or IPv6 (for an AAAA). If you specify multiple addresses, all that match the query type (A, AAAA or ANY) will get spoofed in" },
index f7018c7e5c9e47d17b4c6bd312987c22811da162..08466221fa1f2bc7521c7778ee60e9608f252fee 100644 (file)
@@ -1429,6 +1429,13 @@ vector<std::function<void(void)>> setupLua(bool client, const std::string& confi
       }
     });
 
+  g_lua.writeFunction("showTCPStats", [] {
+      setLuaNoSideEffect();
+      boost::format fmt("%-10d %-10d %-10d %-10d\n");
+      g_outputBuffer += (fmt % "Clients" % "MaxClients" % "Queued" % "MaxQueued").str();
+      g_outputBuffer += (fmt % g_tcpclientthreads->d_numthreads % g_maxTCPClientThreads % g_tcpclientthreads->d_queued % g_maxTCPQueuedConnections).str();
+    });
+
   g_lua.writeFunction("setCacheCleaningDelay", [](uint32_t delay) { g_cacheCleaningDelay = delay; });
 
   g_lua.writeFunction("setECSSourcePrefixV4", [](uint16_t prefix) { g_ECSSourcePrefixV4=prefix; });