From: Bert Hubert Date: Tue, 13 Nov 2012 11:23:18 +0000 (+0000) Subject: update json functionality, can now also get all stats by requesting /jsonstats X-Git-Tag: auth-3.2-rc2~110 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b39c0406404c97537cb4fc4b6601a1d54abaa91;p=thirdparty%2Fpdns.git update json functionality, can now also get all stats by requesting /jsonstats git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2891 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/ws.cc b/pdns/ws.cc index 38b49b40d6..426115dee1 100644 --- a/pdns/ws.cc +++ b/pdns/ws.cc @@ -23,6 +23,7 @@ #include "arguments.hh" #include "dns.hh" #include +#include extern StatBag S; @@ -231,17 +232,26 @@ string StatWebServer::jsonstat(const map &varmap, void *ptr, bool string ret="HTTP/1.1 200 OK\r\n" "Date: Wed, 30 Nov 2011 22:01:15 GMT\r\n" // XXX FIXME real date! "Server: PowerDNS/"VERSION"\r\n" - "Connection: Keep-Alive\r\n" - "Transfer-Encoding: chunked\r\n" + "Connection: close\r\n" "Access-Control-Allow-Origin: *\r\n" "Content-Type: application/json\r\n" "\r\n" ; typedef map varmap_t; + varmap_t ourvarmap=varmap; + if(ourvarmap.empty()) { + vector entries = S.getEntries(); + BOOST_FOREACH(string& ent, entries) { + ourvarmap[ent]; + } + ourvarmap["version"]; + } + + string variable, value; - ret="{"; - for(varmap_t::const_iterator iter = varmap.begin(); iter != varmap.end() ; ++iter) { - if(iter != varmap.begin()) + ret+="{"; + for(varmap_t::const_iterator iter = ourvarmap.begin(); iter != ourvarmap.end() ; ++iter) { + if(iter != ourvarmap.begin()) ret += ","; variable = iter->first;