Author: soliton
Date: Fri Oct 3 04:31:16 2008
New Revision: 29818
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29818&view=rev
Log:
some more server command tweaks
* merged the samples command back into metrics
* actually allowed advertised commands for ordinary users
Modified:
trunk/src/server/ban.cpp
trunk/src/server/metrics.cpp
trunk/src/server/metrics.hpp
trunk/src/server/server.cpp
Modified: trunk/src/server/ban.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/ban.cpp?rev=29818&r1=29817&r2=29818&view=diff
==============================================================================
--- trunk/src/server/ban.cpp (original)
+++ trunk/src/server/ban.cpp Fri Oct 3 04:31:16 2008
@@ -629,7 +629,7 @@
}
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)
Modified: trunk/src/server/metrics.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/metrics.cpp?rev=29818&r1=29817&r2=29818&view=diff
==============================================================================
--- trunk/src/server/metrics.cpp (original)
+++ trunk/src/server/metrics.cpp Fri Oct 3 04:31:16 2008
@@ -111,36 +111,15 @@
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<std::string,int>::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<metrics::sample> 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<metrics::sample>::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 <<
"("<<s->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 @@
<< 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<metrics::sample> 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<metrics::sample>::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 <<
"("<<s->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;
}
Modified: trunk/src/server/metrics.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/metrics.hpp?rev=29818&r1=29817&r2=29818&view=diff
==============================================================================
--- trunk/src/server/metrics.hpp (original)
+++ trunk/src/server/metrics.hpp Fri Oct 3 04:31:16 2008
@@ -42,7 +42,6 @@
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 {
Modified: trunk/src/server/server.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=29818&r1=29817&r2=29818&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Fri Oct 3 04:31:16 2008
@@ -1125,7 +1125,7 @@
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 @@
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 parameters = (i == query.end() ? "" :
std::string(i+1,query.end()));
utils::strip(parameters);
const std::string& help_msg = "Available commands are: ban <mask>
[<time>] <reason>,"
- " bans [deleted], kick <mask>, k(ick)ban <mask>
[<time>] <reason>,"
- " help, games, metrics, netstats, (lobby)msg <message>,
motd [<message>],"
- " samples, stats, status [<mask>], searchlog [<mask>],
unban <ipmask>";
- // Shutdown and restart commands can only be issued via the socket.
- if (command == "shut_down" && issuer_name == "*socket*") {
+ " bans [deleted], kick <mask>, k[ick]ban <mask>
[<time>] <reason>,"
+ " help, games, metrics, netstats [all], [lobby]msg
<message>, motd [<message>],"
+ " requestes, stats, status [<mask>], searchlog
[<mask>], unban <ipmask>";
+ // Shutdown, restart and sample commands can only be issued via the
socket.
+ if (command == "shut_down") {
+ if (issuer_name != "*socket*") return "";
if (parameters == "now") {
throw network::error("shut down");
} else {
@@ -1193,7 +1202,8 @@
#ifndef _WIN32 // Not sure if this works on windows
// TODO: check if this works in windows.
- } else if (command == "restart" && issuer_name == "*socket*") {
+ } else if (command == "restart") {
+ if (issuer_name != "*socket*") return "";
if (restart_command.empty()) {
out << "No restart_command configured! Not restarting.";
} else {
@@ -1208,10 +1218,12 @@
out << "New server started.";
}
#endif
- } else if (command == "sample" && issuer_name == "*socket*") {
+ } else if (command == "sample") {
if (parameters.empty()) {
out << "Current sample frequency: " <<
request_sample_frequency;
return out.str();
+ } else if (issuer_name != "*socket*") {
+ return "";
}
request_sample_frequency = atoi(parameters.c_str());
if (request_sample_frequency <= 0) {
@@ -1220,16 +1232,15 @@
out << "Sampling every " << request_sample_frequency <<
" requests.";
}
} else if (command == "help") {
- out << help_msg;
+ return help_msg;
} else if (command == "stats") {
out << "Number of games = " << games_.size()
<< "\nTotal number of users = " << players_.size()
<< "\nNumber of ghost users = " << ghost_players_.size()
<< "\nNumber of users in the lobby = " <<
lobby_.nobservers();
+ return out.str();
} else if (command == "metrics") {
out << metrics_;
- } else if (command == "samples") {
- metrics_.samples(out);
} else if (command == "games") {
metrics_.games(out);
} else if (command == "wml") {
@@ -1254,7 +1265,7 @@
}
}
LOG_SERVER << "<server> " + parameters + "\n";
- out << "message '" << parameters << "' relayed to players\n";
+ out << "message '" << parameters << "' relayed to players";
} else if (command == "status") {
out << "STATUS REPORT";
// If a simple username is given we'll check for its IP instead.
@@ -1267,7 +1278,7 @@
break;
}
}
- if (!found) return "";
+ if (!found) return out.str();
}
for (wesnothd::player_map::const_iterator pl =
players_.begin(); pl != players_.end(); ++pl) {
if (parameters == ""
@@ -1446,7 +1457,7 @@
i != ip_log_.end(); i++) {
if (utils::wildcard_string_match(i->second,
parameters)) {
found_something = true;
- out << "\n" << i->first << "@" <<
i->second;
+ out << "\n'" << i->first << "' @ " <<
i->second;
}
}
} else {
@@ -1458,7 +1469,7 @@
}
}
}
- if (!found_something) out << "No results found for '" <<
parameters << "'.";
+ if (!found_something) out << "\nNo results found for '" <<
parameters << "'.";
} else {
out << "Command '" << command << "' is not recognized.\n" <<
help_msg;
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits