Some minor updates
This commit is contained in:
parent
bc2c951dde
commit
0aad154c15
@ -1 +1 @@
|
||||
Subproject commit 64a573cbd0f890907d4416c87021092e8cce7367
|
||||
Subproject commit dc0e49097c317f9c04fb9bfc0c8f61156c743ba8
|
@ -654,10 +654,10 @@ std::shared_ptr<ts::server::license::InstanceLicenseInfo> InstanceHandler::gener
|
||||
auto request = std::make_shared<license::InstanceLicenseInfo>();
|
||||
request->license = config::license;
|
||||
request->metrics.servers_online = this->voiceServerManager->runningServers();
|
||||
auto report = this->voiceServerManager->clientReport();
|
||||
request->metrics.client_online = report.clients_ts;
|
||||
request->metrics.web_clients_online = report.clients_web;
|
||||
request->metrics.bots_online = report.bots;
|
||||
auto report = this->voiceServerManager->instanceSlotUsageReport();
|
||||
request->metrics.client_online = report.clients_teamspeak;
|
||||
request->metrics.web_clients_online = report.clients_teaweb;
|
||||
request->metrics.bots_online = report.music_bots;
|
||||
request->metrics.queries_online = report.queries;
|
||||
request->metrics.speech_total = this->properties()[property::SERVERINSTANCE_SPOKEN_TIME_TOTAL].as_or<uint64_t>(0);
|
||||
request->metrics.speech_varianz = this->properties()[property::SERVERINSTANCE_SPOKEN_TIME_VARIANZ].as_or<uint64_t>(0);
|
||||
|
@ -671,36 +671,37 @@ void VirtualServer::stop(const std::string& reason, bool disconnect_query) {
|
||||
this->serverAdmin->server = nullptr;
|
||||
}
|
||||
|
||||
size_t VirtualServer::onlineClients() {
|
||||
size_t result{0};
|
||||
|
||||
for(const auto& client : this->getClients()) {
|
||||
if(client->getType() == CLIENT_TEAMSPEAK || client->getType() == CLIENT_QUERY) {
|
||||
result++;
|
||||
}
|
||||
ServerSlotUsageReport VirtualServer::onlineStats() {
|
||||
ServerSlotUsageReport response{};
|
||||
response.server_count = 1;
|
||||
response.max_clients = this->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0);
|
||||
response.reserved_clients = this->properties()[property::VIRTUALSERVER_RESERVED_SLOTS].as_or<size_t>(0);
|
||||
{
|
||||
std::lock_guard shared_lock{this->channel_tree_mutex};
|
||||
response.online_channels = this->channelTree->channel_count();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
OnlineClientReport VirtualServer::onlineStats() {
|
||||
OnlineClientReport response{};
|
||||
|
||||
for(const auto &client : this->getClients()) {
|
||||
switch (client->getType()) {
|
||||
case CLIENT_TEAMSPEAK:
|
||||
response.clients_teamspeak++;
|
||||
break;
|
||||
|
||||
case CLIENT_TEASPEAK:
|
||||
response.clients_ts++;
|
||||
response.clients_teaspeak++;
|
||||
break;
|
||||
|
||||
case CLIENT_WEB:
|
||||
response.clients_web++;
|
||||
response.clients_teaweb++;
|
||||
break;
|
||||
|
||||
case CLIENT_QUERY:
|
||||
response.queries++;
|
||||
break;
|
||||
|
||||
case CLIENT_MUSIC:
|
||||
response.bots++;
|
||||
response.music_bots++;
|
||||
break;
|
||||
|
||||
case CLIENT_INTERNAL:
|
||||
case MAX:
|
||||
default:
|
||||
|
@ -105,11 +105,35 @@ namespace ts {
|
||||
}
|
||||
};
|
||||
|
||||
struct OnlineClientReport {
|
||||
uint16_t clients_ts = 0;
|
||||
uint16_t clients_web = 0;
|
||||
uint16_t queries = 0;
|
||||
uint16_t bots = 0;
|
||||
struct ServerSlotUsageReport {
|
||||
size_t server_count{0};
|
||||
|
||||
size_t max_clients{0};
|
||||
size_t reserved_clients{0};
|
||||
|
||||
size_t clients_teamspeak{0};
|
||||
size_t clients_teaspeak{0};
|
||||
size_t clients_teaweb{0};
|
||||
size_t queries{0};
|
||||
size_t music_bots{0};
|
||||
|
||||
size_t online_channels{0};
|
||||
|
||||
[[nodiscard]] inline size_t voice_clients() const {
|
||||
return this->clients_teaspeak + this->clients_teamspeak + this->clients_teaweb;
|
||||
}
|
||||
|
||||
inline ServerSlotUsageReport& operator+=(const ServerSlotUsageReport& other) {
|
||||
this->max_clients += other.max_clients;
|
||||
this->reserved_clients += other.reserved_clients;
|
||||
this->clients_teamspeak += other.clients_teamspeak;
|
||||
this->clients_teaspeak += other.clients_teaspeak;
|
||||
this->clients_teaweb += other.clients_teaweb;
|
||||
this->queries += other.queries;
|
||||
this->music_bots += other.music_bots;
|
||||
this->online_channels += other.online_channels;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct CalculateCache {};
|
||||
@ -143,9 +167,7 @@ namespace ts {
|
||||
void preStop(const std::string&);
|
||||
void stop(const std::string& reason, bool /* disconnect query */);
|
||||
|
||||
size_t onlineClients();
|
||||
OnlineClientReport onlineStats();
|
||||
size_t onlineChannels(){ return this->channelTree->channel_count(); }
|
||||
ServerSlotUsageReport onlineStats();
|
||||
std::shared_ptr<ConnectedClient> find_client_by_id(ClientId /* client id */);
|
||||
std::deque<std::shared_ptr<ConnectedClient>> findClientsByCldbId(ClientDbId cldbId);
|
||||
std::deque<std::shared_ptr<ConnectedClient>> findClientsByUid(ClientUid uid);
|
||||
|
@ -272,30 +272,14 @@ ts::ServerId VirtualServerManager::next_available_server_id(bool& success) {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
ServerReport VirtualServerManager::report() {
|
||||
ServerReport result{};
|
||||
for(const auto& sr : this->serverInstances()) {
|
||||
result.available++;
|
||||
if(sr->running()) {
|
||||
result.online++;
|
||||
result.slots += sr->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0);
|
||||
result.onlineClients += sr->onlineClients();
|
||||
result.onlineChannels += sr->onlineChannels();
|
||||
ServerSlotUsageReport VirtualServerManager::instanceSlotUsageReport() {
|
||||
ServerSlotUsageReport result{};
|
||||
for(const auto& server : this->serverInstances()) {
|
||||
if(!server->running()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OnlineClientReport VirtualServerManager::clientReport() {
|
||||
OnlineClientReport result{};
|
||||
for(const auto& server : this->serverInstances()) {
|
||||
if(!server->running()) continue;
|
||||
auto sr = server->onlineStats();
|
||||
result.bots += sr.bots;
|
||||
result.queries += sr.queries;
|
||||
result.clients_web += sr.clients_web;
|
||||
result.clients_ts += sr.clients_ts;
|
||||
result += server->onlineStats();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -307,13 +291,6 @@ size_t VirtualServerManager::runningServers() {
|
||||
return res;
|
||||
}
|
||||
|
||||
size_t VirtualServerManager::usedSlots() {
|
||||
size_t res = 0;
|
||||
for(const auto& sr : this->serverInstances())
|
||||
res += sr->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0);
|
||||
return res;
|
||||
}
|
||||
|
||||
shared_ptr<VirtualServer> VirtualServerManager::create_server(std::string hosts, uint16_t port) {
|
||||
bool sid_success = false;
|
||||
|
||||
|
@ -10,14 +10,6 @@
|
||||
namespace ts::server {
|
||||
class InstanceHandler;
|
||||
|
||||
struct ServerReport {
|
||||
size_t available;
|
||||
size_t online;
|
||||
|
||||
size_t slots;
|
||||
size_t onlineClients;
|
||||
size_t onlineChannels;
|
||||
};
|
||||
class VirtualServerManager {
|
||||
public:
|
||||
enum State {
|
||||
@ -55,10 +47,8 @@ namespace ts::server {
|
||||
return instances;
|
||||
}
|
||||
|
||||
ServerReport report();
|
||||
OnlineClientReport clientReport();
|
||||
ServerSlotUsageReport instanceSlotUsageReport();
|
||||
size_t runningServers();
|
||||
size_t usedSlots();
|
||||
|
||||
void executeAutostart();
|
||||
void shutdownAll(const std::string&);
|
||||
|
@ -846,26 +846,30 @@ void ConnectedClient::sendServerInit() {
|
||||
command["client_myteamspeak_id"] = this->properties()[property::CLIENT_MYTEAMSPEAK_ID].value();
|
||||
command["client_integrations"] = this->properties()[property::CLIENT_INTEGRATIONS].value();
|
||||
|
||||
if(ts::config::server::DefaultServerLicense == LicenseType::LICENSE_AUTOMATIC_INSTANCE) {
|
||||
if(serverInstance->getVoiceServerManager()->usedSlots() <= 32) {
|
||||
command["lt"] = LicenseType::LICENSE_NONE;
|
||||
} else if(serverInstance->getVoiceServerManager()->usedSlots() <= 512) {
|
||||
command["lt"] = LicenseType::LICENSE_NPL;
|
||||
} else {
|
||||
command["lt"] = LicenseType::LICENSE_HOSTING;
|
||||
}
|
||||
} else if(ts::config::server::DefaultServerLicense == LicenseType::LICENSE_AUTOMATIC_SERVER){
|
||||
if(this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0) <= 32) {
|
||||
command["lt"] = LicenseType::LICENSE_NONE;
|
||||
} else if(this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0) <= 512) {
|
||||
command["lt"] = LicenseType::LICENSE_NPL;
|
||||
} else {
|
||||
command["lt"] = LicenseType::LICENSE_HOSTING;
|
||||
}
|
||||
} else {
|
||||
command["lt"] = ts::config::server::DefaultServerLicense;
|
||||
switch(ts::config::server::DefaultServerLicense) {
|
||||
case LicenseType::LICENSE_AUTOMATIC_INSTANCE:
|
||||
/* We offered this option but it's nonsense... Just use automatic server. */
|
||||
case LicenseType::LICENSE_AUTOMATIC_SERVER:
|
||||
if(this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0) <= 32) {
|
||||
command["lt"] = LicenseType::LICENSE_NONE;
|
||||
} else if(this->server->properties()[property::VIRTUALSERVER_MAXCLIENTS].as_or<size_t>(0) <= 512) {
|
||||
command["lt"] = LicenseType::LICENSE_NPL;
|
||||
} else {
|
||||
command["lt"] = LicenseType::LICENSE_HOSTING;
|
||||
}
|
||||
break;
|
||||
|
||||
case LicenseType::LICENSE_NONE:
|
||||
case LicenseType::LICENSE_HOSTING:
|
||||
case LicenseType::LICENSE_OFFLINE:
|
||||
case LicenseType::LICENSE_NPL:
|
||||
case LicenseType::LICENSE_UNKNOWN:
|
||||
case LicenseType::LICENSE_PLACEHOLDER:
|
||||
default:
|
||||
command["lt"] = ts::config::server::DefaultServerLicense;
|
||||
break;
|
||||
}
|
||||
command["pv"] = 6; //Protocol version
|
||||
command["pv"] = 6; /* protocol version */
|
||||
command["acn"] = this->getDisplayName();
|
||||
command["aclid"] = this->getClientId();
|
||||
this->sendCommand(command);
|
||||
|
@ -832,10 +832,14 @@ command_result QueryClient::handleCommandInstanceInfo(Command& cmd) {
|
||||
ACTION_REQUIRES_INSTANCE_PERMISSION(permission::b_serverinstance_info_view, 1);
|
||||
|
||||
Command res("");
|
||||
for(const auto& e : serverInstance->properties()->list_properties(property::FLAG_INSTANCE_VARIABLE, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0))
|
||||
for(const auto& e : serverInstance->properties()->list_properties(property::FLAG_INSTANCE_VARIABLE, this->getType() == CLIENT_TEAMSPEAK ? property::FLAG_NEW : (uint16_t) 0)) {
|
||||
res[e.type().name] = e.value();
|
||||
if(!this->properties()[property::CLIENT_LOGIN_NAME].value().empty())
|
||||
}
|
||||
|
||||
if(!this->properties()[property::CLIENT_LOGIN_NAME].value().empty()) {
|
||||
res["serverinstance_teaspeak"] = true;
|
||||
}
|
||||
|
||||
res["serverinstance_serverquery_max_connections_per_ip"] = res["serverinstance_query_max_connections_per_ip"].as<std::string>();
|
||||
|
||||
this->sendCommand(res);
|
||||
@ -875,11 +879,11 @@ command_result QueryClient::handleCommandHostInfo(Command &) {
|
||||
res["instance_uptime"] = duration_cast<seconds>(system_clock::now() - serverInstance->getStartTimestamp()).count();
|
||||
res["host_timestamp_utc"] = duration_cast<seconds>(system_clock::now().time_since_epoch()).count();
|
||||
|
||||
auto vsReport = serverInstance->getVoiceServerManager()->report();
|
||||
res["virtualservers_running_total"] = vsReport.online;
|
||||
res["virtualservers_total_maxclients"] = vsReport.slots;
|
||||
res["virtualservers_total_clients_online"] = vsReport.onlineClients;
|
||||
res["virtualservers_total_channels_online"] = vsReport.onlineChannels;
|
||||
auto instance_report = serverInstance->getVoiceServerManager()->instanceSlotUsageReport();
|
||||
res["virtualservers_running_total"] = instance_report.server_count;
|
||||
res["virtualservers_total_maxclients"] = instance_report.max_clients;
|
||||
res["virtualservers_total_clients_online"] = instance_report.voice_clients();
|
||||
res["virtualservers_total_channels_online"] = instance_report.online_channels;
|
||||
|
||||
|
||||
auto total_stats = serverInstance->getStatistics()->total_stats();
|
||||
|
Loading…
Reference in New Issue
Block a user