return new uint64_t(t_RC->doDump(fd) + dumpNegCache(t_sstorage->negcache, fd));
}
+static uint64_t* pleaseDumpNSSpeeds(int fd)
+{
+ return new uint64_t(t_RC->doDumpNSSpeeds(fd));
+}
+
+template<typename T>
+string doDumpNSSpeeds(T begin, T end)
+{
+ T i=begin;
+ string fname;
+
+ if(i!=end)
+ fname=*i;
+
+ int fd=open(fname.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0660);
+ if(fd < 0)
+ return "Error opening dump file for writing: "+string(strerror(errno))+"\n";
+ uint64_t total = 0;
+ try {
+ total = broadcastAccFunction<uint64_t>(boost::bind(pleaseDumpNSSpeeds, fd));
+ }
+ catch(...){}
+
+ close(fd);
+ return "dumped "+lexical_cast<string>(total)+" records\n";
+}
+
template<typename T>
string doDumpCache(T begin, T end)
{
"current-queries show currently active queries\n"
"dump-cache <filename> dump cache contents to the named file\n"
"dump-edns[status] <filename> dump EDNS status to the named file\n"
+"dump-nsspeeds <filename> dump nsspeeds statistics to the named file\n"
"get [key1] [key2] .. get specific statistics\n"
"get-all get all statistics\n"
"get-parameter [key1] [key2] .. get configuration parameters\n"
if(cmd=="get-parameter")
return doGetParameter(begin, end);
-
if(cmd=="quit") {
*command=&doExit;
return "bye\n";
if(cmd=="dump-ednsstatus" || cmd=="dump-edns")
return doDumpEDNSStatus(begin, end);
+ if(cmd=="dump-nsspeeds")
+ return doDumpNSSpeeds(begin, end);
+
if(cmd=="wipe-cache" || cmd=="flushname")
return doWipeCache(begin, end);
return false;
}
+uint64_t MemRecursorCache::doDumpNSSpeeds(int fd)
+{
+ FILE* fp=fdopen(dup(fd), "w");
+ if(!fp)
+ return 0;
+ fprintf(fp, "; nsspeed dump from thread follows\n;\n");
+ uint64_t count=0;
+
+ for(SyncRes::nsspeeds_t::iterator i = t_sstorage->nsSpeeds.begin() ; i!= t_sstorage->nsSpeeds.end(); ++i)
+ {
+ count++;
+ fprintf(fp, "%s|%d -> ", i->first.first.c_str(), i->first.second);
+ for(SyncRes::DecayingEwmaCollection::collection_t::iterator j = i->second.d_collection.begin(); j!= i->second.d_collection.end(); ++j)
+ {
+ // typedef vector<pair<ComboAddress, DecayingEwma> > collection_t;
+ fprintf(fp, "%s/%f ", j->first.toString().c_str(), j->second.peek());
+ }
+ fprintf(fp, "\n");
+ }
+ fclose(fp);
+ return count;
+}
uint64_t MemRecursorCache::doDump(int fd)
{
void doPrune(void);
void doSlash(int perc);
uint64_t doDump(int fd);
+ uint64_t doDumpNSSpeeds(int fd);
+
int doWipeCache(const string& name, uint16_t qtype=0xffff);
bool doAgeCache(time_t now, const string& name, uint16_t qtype, int32_t newTTL);
uint64_t cacheHits, cacheMisses;