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)
{
#include <netinet/in.h>
#include <sys/un.h>
#include <unistd.h>
+#include <fstream>
#include "misc.hh"
#include <vector>
#include <sstream>
return true;
}
+// please feel free to add other operating systems here. What we need are stats on dropped UDP packets
+uint64_t udpErrorStats(const std::string& str)
+{
+#ifdef __linux__
+ 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;
+ }
+ }
+#endif
+ return 0;
+}
bool setNonBlocking( int sock );
int closesocket(int fd);
bool setCloseOnExec(int sock);
+uint64_t udpErrorStats(const std::string& str);
#endif
addGetStat("chain-resends", &g_stats.chainResends);
addGetStat("tcp-clients", boost::bind(TCPConnection::getCurrentConnections));
+#ifdef __linux__
+ addGetStat("udp-recvbuf-errors", boost::bind(udpErrorStats, "udp-recvbuf-errors"));
+ addGetStat("udp-sndbuf-errors", boost::bind(udpErrorStats, "udp-sndbuf-errors"));
+ addGetStat("udp-noport-errors", boost::bind(udpErrorStats, "udp-noport-errors"));
+ addGetStat("udp-in-errors", boost::bind(udpErrorStats, "udp-in-errors"));
+#endif
+
addGetStat("edns-ping-matches", &g_stats.ednsPingMatches);
addGetStat("edns-ping-mismatches", &g_stats.ednsPingMismatches);