]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
teach auth to report the linux udp no-port and udp receive and send errors for your...
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 24 Dec 2014 15:36:14 +0000 (16:36 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 24 Dec 2014 15:36:14 +0000 (16:36 +0100)
pdns/common_startup.cc
pdns/dynhandler.cc
pdns/dynhandler.hh

index cd584fe9166345f4fb923a060c6d76a22bb7c654..a1feccbaa2120b3cc92645462aabdef544eed64f 100644 (file)
@@ -24,6 +24,7 @@
 #include "secpoll-auth.hh"
 #include <sys/time.h>
 #include <sys/resource.h>
+#include "dynhandler.hh"
 #include <boost/foreach.hpp>
 
 bool g_anyToTcp;
@@ -254,6 +255,13 @@ void declareStats(void)
   S.declare("incoming-notifications", "NOTIFY packets received.");
 
   S.declare("uptime", "Uptime of process in seconds", uptimeOfProcess);
+#ifdef __linux__
+  S.declare("udp-recvbuf-errors", "UDP 'recvbuf' errors", udpErrorStats);
+  S.declare("udp-sndbuf-errors", "UDP 'sndbuf' errors", udpErrorStats);
+  S.declare("udp-noport-errors", "UDP 'noport' errors", udpErrorStats);
+  S.declare("udp-in-errors", "UDP 'in' errors", udpErrorStats);
+#endif
+
   S.declare("sys-msec", "Number of msec spent in system time", getSysUserTimeMsec);
   S.declare("user-msec", "Number of msec spent in user time", getSysUserTimeMsec);
   S.declare("meta-cache-size", "Number of entries in the metadata cache", DNSSECKeeper::dbdnssecCacheSizes);
index c0b92441d89ae2acc0e4a0d03aaf9eb469fb5900..87522b4bd6b217171089a099d7beec586ca01827 100644 (file)
@@ -300,6 +300,33 @@ string DLReloadHandler(const vector<string>&parts, Utility::pid_t ppid)
   return "Ok";
 }
 
+uint64_t udpErrorStats(const std::string& str)
+{
+  ifstream ifs("/proc/net/snmp");
+  if(!ifs)
+    return 0;
+  string line;
+  vector<string> parts;
+  while(getline(ifs,line)) {
+    if(boost::starts_with(line, "Udp: ") && isdigit(line[5])) {
+      stringtok(parts, line, " \n\t\r");
+      if(parts.size() < 7)
+       break;
+      if(str=="udp-rcvbuf-errors")
+       return boost::lexical_cast<uint64_t>(parts[5]);
+      else if(str=="udp-sndbuf-errors")
+       return boost::lexical_cast<uint64_t>(parts[6]);
+      else if(str=="udp-noport-errors")
+       return boost::lexical_cast<uint64_t>(parts[2]);
+      else if(str=="udp-in-errors")
+       return boost::lexical_cast<uint64_t>(parts[3]);
+      else
+       return 0;
+    }
+  }
+  return 0;
+}
+
 string DLListZones(const vector<string>&parts, Utility::pid_t ppid)
 {
   UeberBackend B;
index ce13125577c03c11ff92a6a4d58e9a11afa652af..88d3c3d113150c4f9f69a66565a2f434f7ef74cd 100644 (file)
@@ -56,4 +56,5 @@ string DLPurgeHandler(const vector<string>&parts, Utility::pid_t ppid);
 string DLNotifyRetrieveHandler(const vector<string>&parts, Utility::pid_t ppid);
 string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid);
 string DLListZones(const vector<string>&parts, Utility::pid_t ppid);
+uint64_t udpErrorStats(const std::string& str);
 #endif /* PDNS_DYNHANDLER_HH */