]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/dnsdist-carbon.cc
dnsdist: Fix invalid carbon formatting for TCP stats
[thirdparty/pdns.git] / pdns / dnsdist-carbon.cc
index 6815cc976273986d28132514d2799b1f686b286b..9ad220f4078bb776d9713c537897f7e1fbd3ac89 100644 (file)
@@ -37,7 +37,7 @@ uint64_t uptimeOfProcess(const std::string& str)
   return time(0) - s_start;
 }
 
-void* carbonDumpThread()
+void carbonDumpThread()
 try
 {
   setThreadName("dnsdist/carbon");
@@ -56,10 +56,7 @@ try
 
     for (const auto& conf : *localCarbon) {
       const auto& server = conf.server;
-      std::string namespace_name = conf.namespace_name;
-      if(namespace_name.empty()) {
-        namespace_name="dnsdist";
-      }
+      const std::string& namespace_name = conf.namespace_name;
       std::string hostname = conf.ourname;
       if(hostname.empty()) {
         char tmp[80];
@@ -70,10 +67,7 @@ try
         hostname=tmp;
         boost::replace_all(hostname, ".", "_");
       }
-      std::string instance_name = conf.instance_name;
-      if(instance_name.empty()) {
-        instance_name="main";
-      }
+      const std::string& instance_name = conf.instance_name;
 
       try {
         Socket s(server.sin4.sin_family, SOCK_STREAM);
@@ -101,6 +95,11 @@ try
           str<<base<<"latency" << ' ' << (state->availability != DownstreamState::Availability::Down ? state->latencyUsec/1000.0 : 0) << " " << now << "\r\n";
           str<<base<<"senderrors" << ' ' << state->sendErrors.load() << " " << now << "\r\n";
           str<<base<<"outstanding" << ' ' << state->outstanding.load() << " " << now << "\r\n";
+          str<<base<<"tcpdiedsendingquery" << ' '<< state->tcpDiedSendingQuery.load() << " " << now << "\r\n";
+          str<<base<<"tcpdiedreaddingresponse" << ' '<< state->tcpDiedReadingResponse.load() << " " << now << "\r\n";
+          str<<base<<"tcpgaveup" << ' '<< state->tcpGaveUp.load() << " " << now << "\r\n";
+          str<<base<<"tcpreadimeouts" << ' '<< state->tcpReadTimeouts.load() << " " << now << "\r\n";
+          str<<base<<"tcpwritetimeouts" << ' '<< state->tcpWriteTimeouts.load() << " " << now << "\r\n";
         }
         for(const auto& front : g_frontends) {
           if (front->udpFD == -1 && front->tcpFD == -1)
@@ -110,6 +109,11 @@ try
           boost::replace_all(frontName, ".", "_");
           const string base = namespace_name + "." + hostname + "." + instance_name + ".frontends." + frontName + ".";
           str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
+          str<<base<<"tcpdiedreadingquery" << ' '<< front->tcpDiedReadingQuery.load() << " " << now << "\r\n";
+          str<<base<<"tcpdiedsendingresponse" << ' '<< front->tcpDiedSendingResponse.load() << " " << now << "\r\n";
+          str<<base<<"tcpgaveup" << ' '<< front->tcpGaveUp.load() << " " << now << "\r\n";
+          str<<base<<"tcpclientimeouts" << ' '<< front->tcpClientTimeouts.load() << " " << now << "\r\n";
+          str<<base<<"tcpdownstreamtimeouts" << ' '<< front->tcpDownstreamTimeouts.load() << " " << now << "\r\n";
         }
         auto localPools = g_pools.getLocal();
         for (const auto& entry : *localPools) {
@@ -162,20 +166,16 @@ try
       }
     }
   }
-  return 0;
 }
 catch(std::exception& e)
 {
   errlog("Carbon thread died: %s", e.what());
-  return 0;
 }
 catch(PDNSException& e)
 {
   errlog("Carbon thread died, PDNSException: %s", e.reason);
-  return 0;
 }
 catch(...)
 {
   errlog("Carbon thread died");
-  return 0;
 }