#endif
#include <boost/tokenizer.hpp>
-#include <boost/circular_buffer.hpp>
#include "namespaces.hh"
#include "ws-api.hh"
#include "json.hh"
if(req->method != "GET")
throw HttpMethodNotAllowedException();
+ Json::array doc;
+ string name = req->getvars["statistic"];
+ if (!name.empty()) {
+ auto stat = productServerStatisticsFetch(name);
+ if (!stat) {
+ throw ApiException("Unknown statistic name");
+ }
+
+ doc.push_back(Json::object {
+ { "type", "StatisticItem" },
+ { "name", name },
+ { "value", std::to_string(*stat) },
+ });
+
+ resp->setBody(doc);
+
+ return;
+ }
+
typedef map<string, string> stat_items_t;
stat_items_t general_stats;
productServerStatisticsFetch(general_stats);
- auto resp_qtype_stats = g_rs.getQTypeResponseCounts();
- auto resp_size_stats = g_rs.getSizeResponseCounts();
-
- Json::array doc;
for(const auto& item : general_stats) {
doc.push_back(Json::object {
{ "type", "StatisticItem" },
});
}
+ auto resp_qtype_stats = g_rs.getQTypeResponseCounts();
+ auto resp_size_stats = g_rs.getSizeResponseCounts();
+ auto resp_rcode_stats = g_rs.getRCodeResponseCounts();
{
Json::array values;
for(const auto& item : resp_qtype_stats) {
doc.push_back(Json::object {
{ "type", "MapStatisticItem" },
- { "name", "queries-by-qtype" },
+ { "name", "response-by-qtype" },
{ "value", values },
});
}
});
}
+ {
+ Json::array values;
+ for(const auto& item : resp_rcode_stats) {
+ if (item.second == 0)
+ continue;
+ values.push_back(Json::object {
+ { "name", RCode::to_s(item.first) },
+ { "value", std::to_string(item.second) },
+ });
+ }
+
+ doc.push_back(Json::object {
+ { "type", "MapStatisticItem" },
+ { "name", "response-by-rcode" },
+ { "value", values },
+ });
+ }
+
#ifndef RECURSOR
for(const auto& ringName : S.listRings()) {
Json::array values;