diff options
| author | DDuarte <dnpd.dd@gmail.com> | 2016-06-04 11:26:57 +0100 |
|---|---|---|
| committer | DDuarte <dnpd.dd@gmail.com> | 2016-06-04 11:26:57 +0100 |
| commit | 8b26aea95a301af5a6af888df4fd3e7683e1ef62 (patch) | |
| tree | f888cf7f3a668565f10f37376a259c7d1c69f1d6 /src/server | |
| parent | 2c2bb4a2377b40af2fccd484b13993aa16ad6380 (diff) | |
Implement real time statistic visualization (#16956)
Docs at https://trinitycore.atlassian.net/wiki/display/tc/Monitoring+a+TrinityCore+server
* Common/Graphs: Initial proof of concept
* Move influx db code to its own class
* Reuse the same socket
* Allow to log values of different categories
* Allow to log events
* Pass the timestamp to influxdb
* Send events in batches
* Send data async
* Log server shutdown.
Fix memory leak.
* Allow to enable/disable Stats in the settings and at runtime
* Read interval between each batch send from config
* Add InfluxDB connection info to configs
* Move each event category to its own table
* Log pathfinding queries
* Move categories table initialization to constructor using enum as key to avoid assigning the table name to the wrong enum value
* Log player login/logout events.
Pass the hostname correctly in the HTTP request.
* Fix linux build
* Handle "Connection: close" HTTP header, reconnecting on next scheduled send.
Disable StatsLogger if connection fails, logging the error.
* Add an enum for categories of logged values, it's still possible to pass a string instead of the enum.
* Don't log the whole batchedData when InfluxDB returns an error, it's too long and unreadable on console.
* Allow to call a function at a specified interval in thread-safe World::Update() context to log data like player count.
* Log map tile load/unload
* Core/StatsLogger: Allow logging more value types other than ints
https://docs.influxdata.com/influxdb/v0.10/write_protocols/write_syntax/
* Fix a typo in string escape of StatsLogger
* Yet more fixes to the escaping in FormatInfluxDBValue
* DB/Gameobject: Fix respawn time of few Quest GameObjects
By Tauriella, closes #16701
* DB/Misc: Fix some engrish
By tkrokli closes #16648
* Tools/MMaps: Add format library linking to mmaps_generator
(Very) partial cherry pick of ed75b0649add23e082976fa4e5d504bc0c312602
* Core/StatsLogger: Simplify code
Convert values and categories arrays to maps initialized in-place
Remove constructor and destructor
* Core/StatsLogger: Add realm name to the event and value tags
* Log amount of processed packet of each session
* Apply recent singleton changes to sStatsLogger too
* Fix influxdb data format if no realm name is present
* Remove unneeded newlines from request body, fixes response 400 from InfluxDB 0.10
* Rename Reporting folder to Metric
* Rename StatsLogger to Metric
* Rename InfluxDB configs to Metric
* Add Grafana dashboards
* Add a random annoying macro
* Move string formatting to Metric::SendBatch(), reducing performance footprint of Metric::LogEvent() and Metric::LogValue()
* Update grafana graphs refresing tags on load and showing now-15m data, refreshing every minute. These settings can be modified in grafana.
* Rename MetricData fields
* Contrib/Grafana: Rename dashboard files
* Contrib/Grafana: Replace hardcoded Windows/Ubuntu realm names by the default, Trinity
* Config/Worldserver: Add missing section to the index
* Contrib/Grafana: Add singlestat panels with current online players, update diff averages (1 min, 5 mins and 15 mins)
http://i.imgur.com/Zi8lfvS.png
* Core/Metric: Replace the enums MetricEventCategory and MetricValueCategory by strings
For the sake of simplicity and less recompile time when adding new metrics, similar to how TC_LOG_* works
* Contrib/Grafana: Display the current number of online players and not its average
Closes #15075
(cherry picked from commit 3ae10160820782d039c3449107960108fb3a63b9)
# Conflicts:
# src/server/game/Server/WorldSession.cpp
# src/server/game/World/World.cpp
# src/server/worldserver/Main.cpp
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/game/Handlers/CharacterHandler.cpp | 3 | ||||
| -rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 3 | ||||
| -rw-r--r-- | src/server/game/Server/WorldSession.cpp | 5 | ||||
| -rw-r--r-- | src/server/game/World/World.cpp | 8 | ||||
| -rw-r--r-- | src/server/worldserver/Main.cpp | 11 | ||||
| -rw-r--r-- | src/server/worldserver/worldserver.conf.dist | 39 |
6 files changed, 69 insertions, 0 deletions
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index ee1d69571f0..e4b03ed79c7 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -54,6 +54,7 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" +#include "Metric.h" class LoginQueryHolder : public SQLQueryHolder { @@ -1147,6 +1148,8 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) sScriptMgr->OnPlayerLogin(pCurrChar, firstLogin); + TC_METRIC_EVENT("player_events", "Login", pCurrChar->GetName()); + delete holder; } diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index fe09aa26af2..39087269e54 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -26,6 +26,7 @@ #include "DisableMgr.h" #include "DetourCommon.h" #include "DetourNavMeshQuery.h" +#include "Metric.h" ////////////////// PathGenerator ////////////////// PathGenerator::PathGenerator(const Unit* owner) : @@ -62,6 +63,8 @@ bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool fo if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z)) return false; + TC_METRIC_EVENT("mmap_events", "CalculatePath", ""); + G3D::Vector3 dest(destX, destY, destZ); SetEndPosition(dest); diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index 41141148922..c11c85aaffa 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -51,6 +51,7 @@ #include "BattlePetMgr.h" #include "PacketUtilities.h" #include "CollectionMgr.h" +#include "Metric.h" #include <zlib.h> @@ -456,6 +457,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater) break; } + TC_METRIC_VALUE("processed_packets", processedPackets); + _recvQueue.readd(requeuePackets.begin(), requeuePackets.end()); if (m_Socket[CONNECTION_TYPE_REALM] && m_Socket[CONNECTION_TYPE_REALM]->IsOpen() && _warden) @@ -614,6 +617,8 @@ void WorldSession::LogoutPlayer(bool save) //! Call script hook before deletion sScriptMgr->OnPlayerLogout(_player); + TC_METRIC_EVENT("player_events", "Logout", _player->GetName()); + //! Remove the player from the world // the player may not be in the world when logging out // e.g if he got disconnected during a transfer to another map diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 61e1755b4e4..5513c8e94dd 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -63,6 +63,7 @@ #include "SkillDiscovery.h" #include "SkillExtraItems.h" #include "SmartAI.h" +#include "Metric.h" #include "SupportMgr.h" #include "TaxiPathGraph.h" #include "TransportMgr.h" @@ -437,6 +438,7 @@ void World::LoadConfigSettings(bool reload) return; } sLog->LoadFromConfig(); + sMetric->LoadFromConfigs(); } m_defaultDbcLocale = LocaleConstant(sConfigMgr->GetIntDefault("DBC.Locale", 0)); @@ -2128,6 +2130,8 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.worldserver", "World initialized in %u minutes %u seconds", (startupDuration / 60000), ((startupDuration % 60000) / 1000)); + TC_METRIC_EVENT("events", "World initialized", "World initialized in " + std::to_string(startupDuration / 60000) + " minutes " + std::to_string((startupDuration % 60000) / 1000) + " seconds"); + if (uint32 realmId = sConfigMgr->GetIntDefault("RealmID", 0)) // 0 reserved for auth sLog->SetRealmId(realmId); } @@ -2430,6 +2434,10 @@ void World::Update(uint32 diff) ProcessCliCommands(); sScriptMgr->OnWorldUpdate(diff); + + // Stats logger update + sMetric->Update(); + TC_METRIC_VALUE("update_time_diff", diff); } void World::ForceGameEventUpdate() diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index 5d8d0819102..2d14e3301a3 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -45,6 +45,7 @@ #include "RealmList.h" #include "DatabaseLoader.h" #include "AppenderDB.h" +#include "Metric.h" #include <openssl/opensslv.h> #include <openssl/crypto.h> #include <boost/asio/io_service.hpp> @@ -200,6 +201,13 @@ extern int main(int argc, char** argv) LoadRealmInfo(); + sMetric->Initialize(realm.Name, _ioService, []() + { + TC_METRIC_VALUE("online_players", sWorld->GetPlayerCount()); + }); + + TC_METRIC_EVENT("events", "Worldserver started", ""); + // Initialize the World sScriptMgr->SetScriptLoader(AddScripts); sWorld->SetInitialWorldSettings(); @@ -300,6 +308,9 @@ extern int main(int argc, char** argv) StopDB(); + TC_METRIC_EVENT("events", "Worldserver shutdown", ""); + sMetric->ForceSend(); + TC_LOG_INFO("server.worldserver", "Halting process..."); ShutdownCLIThread(cliThread); diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 87d76c3f8a1..dcaad115812 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -37,6 +37,7 @@ # LOGGING SYSTEM SETTINGS # CURRENCIES SETTINGS # PACKET SPOOF PROTECTION SETTINGS +# METRIC SETTINGS # ################################################################################################### @@ -3853,3 +3854,41 @@ PacketSpoof.BanDuration = 86400 # ################################################################################################### + +################################################################################################### +# METRIC SETTINGS +# +# These settings control the statistics sent to the metric database (currently InfluxDB) +# +# Metric.Enable +# Description: Enables statistics sent to the metric database. +# Default: 0 - (Disabled) +# 1 - (Enabled) + +Metric.Enable = 0 + +# +# Metric.Interval +# Description: Interval between every batch of data sent in seconds +# Default: 10 seconds +# + +Metric.Interval = 10 + +# +# Metric.ConnectionInfo +# Description: Connection settings for metric database (currently InfluxDB). +# Example: "hostname;port;database" +# Default: "127.0.0.1;8086;worldserver" + +Metric.ConnectionInfo = "127.0.0.1;8086;worldserver" + +# +# Metric.OverallStatusInterval +# Description: Interval between every gathering of overall worldserver status data in seconds +# Default: 1 second +# + +Metric.OverallStatusInterval = 1 + +################################################################################################### |
