]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
hook up -l in dnsscope to emit per second statistics
authorbert hubert <bert.hubert@netherlabs.nl>
Sat, 15 Mar 2014 21:29:15 +0000 (22:29 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Sat, 15 Mar 2014 21:29:15 +0000 (22:29 +0100)
pdns/dnsscope.cc

index ab30fcfa6880d2edbb9fbdb479831aece86c716b..ce31be2218fdfaea81137a35351a52f2bca5c7fd 100644 (file)
@@ -77,6 +77,7 @@ try
     ("rd", po::value<bool>(), "If set to true, only process RD packets, to false only non-RD, unset: both")
     ("ipv4", po::value<bool>()->default_value(true), "Process IPv4 packets")
     ("ipv6", po::value<bool>()->default_value(true), "Process IPv6 packets")
+    ("load-stats,l", po::value<string>()->default_value(""), "if set, emit per-second load statistics (questions, answers, outstanding)")
     ("write-failures,w", po::value<string>()->default_value(""), "if set, write weird packets to this PCAP file")
     ("verbose,v", "be verbose");
     
@@ -326,15 +327,18 @@ try
         lastperc=sum*100.0/totpackets;
       }
   }
-
-  //  ofstream load("load");
-  //  BOOST_FOREACH(pcounts_t::value_type& val, pcounts) {
-  //    load<<val.first<<'\t'<<val.second.questions<<'\t'<<val.second.answers<<'\t'<<val.second.outstanding<<'\n';
-  //    
-  //  }
-  
   if(totpackets)
     cout<<"Average response time: "<<tottime/totpackets<<" usec"<<endl;
+
+  if(!g_vm["load-stats"].as<string>().empty()) {
+    ofstream load(g_vm["load-stats"].as<string>().c_str());
+    if(!load) 
+      throw runtime_error("Error writing load statistics to "+g_vm["load-stats"].as<string>());
+    BOOST_FOREACH(pcounts_t::value_type& val, pcounts) {
+      load<<val.first<<'\t'<<val.second.questions<<'\t'<<val.second.answers<<'\t'<<val.second.outstanding<<'\n';  
+    }
+  }
+  
 }
 catch(std::exception& e)
 {