diff --git a/src/server/ban.cpp b/src/server/ban.cpp index 34e4160d796..e1175da1506 100644 --- a/src/server/ban.cpp +++ b/src/server/ban.cpp @@ -629,7 +629,7 @@ namespace wesnothd { } ban_help_ += "ban 127.0.0.1 2h20m flooded lobby\n" "kban suokko 5D flooded again\n" - "kban suokko Y One year ban for constant flooding\n"; + "kban suokko Y One year ban for constant flooding"; } void ban_manager::load_config(const config& cfg) diff --git a/src/server/metrics.cpp b/src/server/metrics.cpp index d668e4be34f..6680a68495b 100644 --- a/src/server/metrics.cpp +++ b/src/server/metrics.cpp @@ -111,36 +111,15 @@ void metrics::game_terminated(const std::string& reason) std::ostream& metrics::games(std::ostream& out) { - if (terminations_.empty()) return out; + if (terminations_.empty()) return out << "No game ended so far."; size_t n = 0; - out << "Games have been terminated in the following ways: \n"; + out << "Games have been terminated in the following ways:\n"; for(std::map::const_iterator i = terminations_.begin(); i != terminations_.end(); ++i) { out << i->first << ": " << i->second << "\n"; ++n; } - out << "Total number of games = " << n; - - return out; -} - -std::ostream& metrics::samples(std::ostream& out) -{ - if (samples_.empty()) return out; - - std::vector ordered_samples = samples_; - std::sort(ordered_samples.begin(), ordered_samples.end(), compare_samples_by_time()); - - out << "Request types:\n"; - - size_t n = 0; - for(std::vector::const_iterator s = ordered_samples.begin(); s != ordered_samples.end(); ++s) { - out << "'" << s->name << "' called " << s->nsamples << " times " - << s->parsing_time << "("<< s->max_parsing_time <<") parsing time, " - << s->processing_time << "("<max_processing_time<<") processing time\n"; - ++n; - } - out << "Total number of games = " << n; + out << "Total number of finished games = " << n; return out; } @@ -158,8 +137,30 @@ std::ostream& operator<<(std::ostream& out, metrics& met) << minutes << " minutes, " << seconds << " seconds\n" << met.nrequests_ << " requests serviced. " << requests_immediate << " (" << percent_immediate << "%) " - << " requests were serviced immediately\n" - << "longest burst of requests was " << met.most_consecutive_requests_; + << "requests were serviced immediately.\n" + << "longest burst of requests was: " << met.most_consecutive_requests_; + + if (met.samples_.empty()) return out; + + std::vector ordered_samples = met.samples_; + std::sort(ordered_samples.begin(), ordered_samples.end(), compare_samples_by_time()); + + out << "\nSampled request types:\n"; + + size_t n = 0; + size_t pa = 0; + size_t pr = 0; + for(std::vector::const_iterator s = ordered_samples.begin(); s != ordered_samples.end(); ++s) { + out << "'" << s->name << "' called " << s->nsamples << " times " + << s->parsing_time << "("<< s->max_parsing_time <<") parsing time, " + << s->processing_time << "("<max_processing_time<<") processing time\n"; + n += s->nsamples; + pa += s->parsing_time; + pr += s->processing_time; + } + out << "Total number of request samples = " << n << "\n" + << "Total parsing time = " << pa << "\n" + << "Total processing time = " << pr; return out; } diff --git a/src/server/metrics.hpp b/src/server/metrics.hpp index 5a506db31b6..782ceefa024 100644 --- a/src/server/metrics.hpp +++ b/src/server/metrics.hpp @@ -42,7 +42,6 @@ public: void game_terminated(const std::string& reason); std::ostream& games(std::ostream& out); - std::ostream& samples(std::ostream& out); friend std::ostream& operator<<(std::ostream& out, metrics& met); struct sample { diff --git a/src/server/server.cpp b/src/server/server.cpp index d464034a98c..3360497817f 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -1125,7 +1125,7 @@ void server::process_query(const network::connection sock, const simple_wml::string_span& command(query["type"]); std::ostringstream response; const std::string& help_msg = "Available commands are: help, games, metrics," - " motd, netstats [all], samples, stats, status, wml."; + " motd, netstats [all], stats, status, wml."; if (admins_.count(sock) != 0) { LOG_SERVER << "Admin Command:" << "\ttype: " << command << "\tIP: "<< network::ip_address(sock) @@ -1136,8 +1136,16 @@ void server::process_query(const network::connection sock, response << help_msg; } else if (command == "status") { response << process_command(command.to_string() + " " + pl->second.name(), pl->second.name()); - } else if (command == "status " + pl->second.name() || command == "metrics" - || command == "motd" || command == "wml" || command == "netstats" || command == "netstats all") { + } else if (command == "games" + || command == "metrics" + || command == "motd" + || command == "netstats" + || command == "netstats all" + || command == "sample" + || command == "stats" + || command == "status " + pl->second.name() + || command == "wml") + { response << process_command(command.to_string(), pl->second.name()); } else if (command == admin_passwd_) { LOG_SERVER << "New Admin recognized:" << "\tIP: " @@ -1175,11 +1183,12 @@ std::string server::process_command(const std::string& query, const std::string& std::string parameters = (i == query.end() ? "" : std::string(i+1,query.end())); utils::strip(parameters); const std::string& help_msg = "Available commands are: ban [