Some small updates

This commit is contained in:
WolverinDEV 2020-03-02 21:00:18 +01:00
parent 12d86cbfea
commit dfb61b9fea
4 changed files with 22 additions and 15 deletions

View File

@ -31,6 +31,8 @@ using namespace license;
* Online clients: SELECT SUM(`clients`) FROM (SELECT DISTINCT(`ip`), `clients` FROM `history_online` WHERE `timestamp` > (UNIX_TIMESTAMP() - 60 * 60 * 2) * 1000) AS `a`
* Online bots: SELECT SUM(`clients`) FROM (SELECT DISTINCT(`ip`), `clients` FROM `history_online` WHERE `timestamp` > (UNIX_TIMESTAMP() - 60 * 60 * 2) * 1000) AS `a`
* Online VS Server: SELECT SUM(`music`) FROM (SELECT DISTINCT(`ip`), `music` FROM `history_online` WHERE `timestamp` > (UNIX_TIMESTAMP() - 60 * 60 * 2) * 1000) AS `a`
*
* Empty instances: curl -ik "https://stats.teaspeak.de:27788?type=request&request_type=general" -X GET 2>&1 | grep "data:"
*/
bool handle_command(string& line);

View File

@ -139,6 +139,7 @@ std::shared_ptr<GeneralStatistics> StatisticManager::general_statistics() {
deque<unique_ptr<GeneralStatisticEntry>> entries;
//TODO: Calculate web clients!
auto result = sql::command(this->license_manager->sql(), "SELECT `keyId`, `unique_id`, `timestamp`,`server`,`clients`,`music` FROM `history_online` WHERE `timestamp` > :time ORDER BY `timestamp` ASC",
variable{":time", duration_cast<milliseconds>(system_clock::now().time_since_epoch() - hours(2) - minutes(10)).count()}) //10min as buffer
.query(std::function<decltype(parse_general_entry)>{parse_general_entry}, entries, true);

View File

@ -473,6 +473,7 @@ bool WebStatistics::handle_message(const std::shared_ptr<license::web::WebStatis
auto& history_data = response["history"]["data"];
for(index = 0; index < stats->record_count; index++) {
auto& indexed_data = history_data[index];
indexed_data["instances_empty"] = stats->history[index].instance_empty;
indexed_data["instances"] = stats->history[index].instance_online;
indexed_data["servers"] = stats->history[index].servers_online;
indexed_data["clients"] = stats->history[index].clients_online;
@ -557,7 +558,9 @@ bool WebStatistics::handle_request(const std::shared_ptr<license::web::WebStatis
auto type = request.parameters.at("type");
logMessage(LOG_LICENSE_WEB, "[{}] Received HTTP status request of type {}", client->client_prefix(), type);
if(type == "request" && request.parameters.at("request_type") == "general") {
if(type == "request" && request.parameters.count("request_type") > 0) {
const auto& type = request.parameters.at("request_type");
if(type == "general") {
Json::Value json;
json["type"] = "response";
auto stats = this->statistics_manager->general_statistics();
@ -569,6 +572,7 @@ bool WebStatistics::handle_request(const std::shared_ptr<license::web::WebStatis
response.setHeader("data", {json_dump(json).string()});
response.code = http::code::_200;
}
}
return false;
}

View File

@ -42,12 +42,12 @@ cd libs || { echo "failed to enter lib directory"; exit 1; }
library_base=$(realpath ../../../../../libraries)
# Setting up ssl
library_path=$(realpath "${library_base}/boringssl/${build_path}/ssl/libssl.so")
cp "$library_path" . || { echo "failed to copy libssl.so"; exit 1; }
query_system_link "libssl.so.1.1"
cp "${library_path}" . || { echo "failed to copy libssl.so.1.1"; exit 1; }
# Setting up crypto
library_path=$(realpath "${library_base}/boringssl/${build_path}/crypto/libcrypto.so")
cp "$library_path" . || { echo "failed to copy libcrypto.so"; exit 1; }
query_system_link "libcrypto.so.1.1"
cp "${library_path}" . || { echo "failed to copy libcrypto.so.1.1"; exit 1; }
# Setting up DataPipes
library_path=$(realpath "${library_base}/DataPipes/${build_path}/lib/libDataPipes-RTC.so")