From 9a07e3428b02f99d032b2438466eb04a3d88538b Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 15 Mar 2014 22:29:15 +0100 Subject: [PATCH] hook up -l in dnsscope to emit per second statistics --- pdns/dnsscope.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pdns/dnsscope.cc b/pdns/dnsscope.cc index ab30fcfa68..ce31be2218 100644 --- a/pdns/dnsscope.cc +++ b/pdns/dnsscope.cc @@ -77,6 +77,7 @@ try ("rd", po::value(), "If set to true, only process RD packets, to false only non-RD, unset: both") ("ipv4", po::value()->default_value(true), "Process IPv4 packets") ("ipv6", po::value()->default_value(true), "Process IPv6 packets") + ("load-stats,l", po::value()->default_value(""), "if set, emit per-second load statistics (questions, answers, outstanding)") ("write-failures,w", po::value()->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<().empty()) { + ofstream load(g_vm["load-stats"].as().c_str()); + if(!load) + throw runtime_error("Error writing load statistics to "+g_vm["load-stats"].as()); + BOOST_FOREACH(pcounts_t::value_type& val, pcounts) { + load<