]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Keep time and count metrics when maintenance is called.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 22 Aug 2022 09:40:38 +0000 (11:40 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 22 Aug 2022 11:37:45 +0000 (13:37 +0200)
Fixes #6981

pdns/rec-snmp.cc
pdns/rec_channel_rec.cc
pdns/recursordist/RECURSOR-MIB.txt
pdns/recursordist/docs/metrics.rst
pdns/recursordist/rec-main.cc
pdns/syncres.hh
pdns/ws-recursor.cc

index d3eb3e4c4cee32c038b6773a1207e77bcaff1a79..08b6c961294285a0006cbd997cab239bfd23ad8b 100644 (file)
@@ -147,6 +147,8 @@ static const oid udp6InCsumErrorsOID[] = {RECURSOR_STATS_OID, 123};
 static const oid sourceDisallowedNotifyOID[] = {RECURSOR_STATS_OID, 124};
 static const oid zoneDisallowedNotifyOID[] = {RECURSOR_STATS_OID, 125};
 static const oid nonResolvingNameserverEntriesOID[] = {RECURSOR_STATS_OID, 126};
+static const oid maintenanceUSecOID[] = {RECURSOR_STATS_OID, 127};
+static const oid maintenanceCallsOID[] = {RECURSOR_STATS_OID, 128};
 
 static std::unordered_map<oid, std::string> s_statsMap;
 
@@ -384,5 +386,7 @@ RecursorSNMPAgent::RecursorSNMPAgent(const std::string& name, const std::string&
   registerCounter64Stat("almost-expired-run", almostExpiredRun, OID_LENGTH(almostExpiredRun));
   registerCounter64Stat("almost-expired-exceptions", almostExpiredExceptions, OID_LENGTH(almostExpiredExceptions));
   registerCounter64Stat("non-resolving-nameserver-entries", nonResolvingNameserverEntriesOID, OID_LENGTH(nonResolvingNameserverEntriesOID));
+  registerCounter64Stat("maintenance-usec", maintenanceUSecOID, OID_LENGTH(maintenanceUSecOID));
+  registerCounter64Stat("maintenance-calls", maintenanceCountOID, OID_LENGTH(maintenanceCallsOID));
 #endif /* HAVE_NET_SNMP */
 }
index 09219c1644d3950c377cbf2020c00a75799db138..aa8449a7d3424db79978a7b980e27653d925c2a0 100644 (file)
@@ -1383,6 +1383,9 @@ static void registerAllStats1()
 
   addGetStat("idle-tcpout-connections", getCurrentIdleTCPConnections);
 
+  addGetStat("maintenance-usec", &g_stats.maintenanceUsec);
+  addGetStat("maintenance-calls", &g_stats.maintenanceCalls);
+
   /* make sure that the ECS stats are properly initialized */
   SyncRes::clearECSStats();
   for (size_t idx = 0; idx < SyncRes::s_ecsResponsesBySubnetSize4.size(); idx++) {
index 15be9c21f304e966bef71324db217bfcffded952..5f9552e16c0b880147df58b848c2c9773cfddf73 100644 (file)
@@ -48,6 +48,9 @@ rec MODULE-IDENTITY
     REVISION "202201310000Z"
     DESCRIPTION "Added non-resolving NS name metric."
 
+    REVISION "202208220000Z"
+    DESCRIPTION "Added internal maintenance metrics."
+
     ::= { powerdns 2 }
 
 powerdns               OBJECT IDENTIFIER ::= { enterprises 43315 }
@@ -1235,7 +1238,9 @@ recGroup OBJECT-GROUP
         udp6InCsumErrors,
         sourceDisallowedNotify,
         zoneDisallowedNotify,
-        nonResolvingNameserverEntries
+        nonResolvingNameserverEntries,
+        maintenanceUSec,
+        maintenanceCalls
     }
     STATUS current
     DESCRIPTION "Objects conformance group for PowerDNS Recursor"
index 121dba2cdc88920d45c1baf8b0ac83fea213bbdc..25c0e0659803d2c9859712ecb32f6388abf77317 100644 (file)
@@ -512,6 +512,14 @@ ipv6-questions
 ^^^^^^^^^^^^^^
 counts all end-user initiated queries with the RD   bit set, received over IPv6 UDP
 
+maintenance-usec
+^^^^^^^^^^^^^^^^
+time spent doing internal maintenance, including Lua maintenance
+
+maintenance-calls
+^^^^^^^^^^^^^^^^^
+number of times internal maintenance has been called, including Lua maintenance
+
 malloc-bytes
 ^^^^^^^^^^^^
 returns the number of bytes allocated by the process (broken, always returns 0)
index de718753b2841c907a26ffe03746ae748c37eb56..4b37c1e969885e4816282d8342a5903f4421b569 100644 (file)
@@ -2452,7 +2452,15 @@ static void recursorThread()
       // Use primes, it avoid not being scheduled in cases where the counter has a regular pattern.
       // We want to call handler thread often, it gets scheduled about 2 times per second
       if (((threadInfo.isHandler() || threadInfo.isTaskThread()) && s_counter % 11 == 0) || s_counter % 499 == 0) {
+        struct timeval start;
+        Utility::gettimeofday(&start);
         MT->makeThread(houseKeeping, nullptr);
+        if (!threadInfo.isTaskThread()) {
+          struct timeval stop;
+          Utility::gettimeofday(&stop);
+          g_stats.maintenanceUsec += uSec(stop - start);
+          ++g_stats.maintenanceCalls;
+        }
       }
 
       if (!(s_counter % 55)) {
@@ -2489,8 +2497,14 @@ static void recursorThread()
         if (threadInfo.isWorker() || threadInfo.isListener()) {
           // Only on threads processing queries
           if (g_now.tv_sec - last_lua_maintenance >= luaMaintenanceInterval) {
+            struct timeval start;
+            Utility::gettimeofday(&start);
             t_pdl->maintenance();
             last_lua_maintenance = g_now.tv_sec;
+            struct timeval stop;
+            Utility::gettimeofday(&stop);
+            g_stats.maintenanceUsec += uSec(stop - start);
+            ++g_stats.maintenanceCalls;
           }
         }
       }
index b1078b973952ce5199ef82b5ad0512b252399d4b..e1ea08718f2e552d7834087aea68e4add6c15a22 100644 (file)
@@ -794,6 +794,8 @@ struct RecursorStats
   pdns::stat_t proxyProtocolInvalidCount{0};
   pdns::stat_t nodLookupsDroppedOversize{0};
   pdns::stat_t dns64prefixanswers{0};
+  pdns::stat_t maintenanceUsec{0};
+  pdns::stat_t maintenanceCalls{0};
 
   RecursorStats() :
     answers("answers", { 1000, 10000, 100000, 1000000 }),
index 7160d604c1c333c95e4e7f2948f371f49c179ee7..e34ffc228f5baa6ad5dbbcd266cf4a74ca2a5071 100644 (file)
@@ -1142,6 +1142,13 @@ const std::map<std::string, MetricDefinition> MetricDefinitionStorage::d_metrics
    MetricDefinition(PrometheusMetricType::gauge,
                     "Number of connections in the TCP idle outgoing connections pool")},
 
+  {"maintenance-usec",
+   MetricDefinition(PrometheusMetricType::counter,
+                    "Time spent doing internal maintenance, including Lua maintenance")},
+
+  {"maintenance-calls",
+   MetricDefinition(PrometheusMetricType::counter,
+                    "Number of times internal maintenance has been called, including Lua maintenance")},
 };
 
 #define CHECK_PROMETHEUS_METRICS 0