From: bert hubert Date: Wed, 24 Dec 2014 15:36:14 +0000 (+0100) Subject: teach auth to report the linux udp no-port and udp receive and send errors for your... X-Git-Tag: rec-3.7.0-rc1~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f45a622c031e1504aca8bf7f21f3cc45f0b168b8;p=thirdparty%2Fpdns.git teach auth to report the linux udp no-port and udp receive and send errors for your plotting pleasures, freebsd equivalent welcome --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index cd584fe916..a1feccbaa2 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -24,6 +24,7 @@ #include "secpoll-auth.hh" #include #include +#include "dynhandler.hh" #include 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); diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index c0b92441d8..87522b4bd6 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -300,6 +300,33 @@ string DLReloadHandler(const vector&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 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(parts[5]); + else if(str=="udp-sndbuf-errors") + return boost::lexical_cast(parts[6]); + else if(str=="udp-noport-errors") + return boost::lexical_cast(parts[2]); + else if(str=="udp-in-errors") + return boost::lexical_cast(parts[3]); + else + return 0; + } + } + return 0; +} + string DLListZones(const vector&parts, Utility::pid_t ppid) { UeberBackend B; diff --git a/pdns/dynhandler.hh b/pdns/dynhandler.hh index ce13125577..88d3c3d113 100644 --- a/pdns/dynhandler.hh +++ b/pdns/dynhandler.hh @@ -56,4 +56,5 @@ string DLPurgeHandler(const vector&parts, Utility::pid_t ppid); string DLNotifyRetrieveHandler(const vector&parts, Utility::pid_t ppid); string DLCurrentConfigHandler(const vector&parts, Utility::pid_t ppid); string DLListZones(const vector&parts, Utility::pid_t ppid); +uint64_t udpErrorStats(const std::string& str); #endif /* PDNS_DYNHANDLER_HH */