mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Scripts/Commands: implemented command .server debug
- Shows detailed information about server setup, useful when reporting a bug: * rev. hash * versions of mysql, openssl, boost, cmake * info about autoupdater * info about ports (realmlist and current) * vmap/map/mmap status and folder sizes * available DBC locales * TDB version Closes #19957
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#define _DATE "@rev_date@"
|
||||
#define _BRANCH "@rev_branch@"
|
||||
#define _CMAKE_COMMAND R"(@CMAKE_COMMAND@)"
|
||||
#define _CMAKE_VERSION R"(@CMAKE_VERSION@)"
|
||||
#define _CMAKE_HOST_SYSTEM R"(@CMAKE_HOST_SYSTEM_NAME@ @CMAKE_HOST_SYSTEM_VERSION@)"
|
||||
#define _SOURCE_DIRECTORY R"(@CMAKE_SOURCE_DIR@)"
|
||||
#define _BUILD_DIRECTORY R"(@BUILDDIR@)"
|
||||
#define _MYSQL_EXECUTABLE R"(@MYSQL_EXECUTABLE@)"
|
||||
|
||||
@@ -819,6 +819,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
|
||||
(196,867),
|
||||
(196,870),
|
||||
(196,871),
|
||||
(196,872),
|
||||
(197,232),
|
||||
(197,236),
|
||||
(197,237),
|
||||
@@ -1712,7 +1713,8 @@ INSERT INTO `rbac_permissions` VALUES
|
||||
(866,'Command: list spawnpoints'),
|
||||
(867,'Command: reload quest_greeting_locale'),
|
||||
(870,'Command: debug threatinfo'),
|
||||
(871,'Command: debug instancespawn');
|
||||
(871,'Command: debug instancespawn'),
|
||||
(872,'Command: server debug');
|
||||
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
@@ -1833,7 +1835,8 @@ INSERT INTO `updates` VALUES
|
||||
('2018_01_03_00_auth_2018_01_02_00_auth.sql','08AF5DAB45515B681B738DA17FA414C7C7CCA44E','ARCHIVED','2018-01-02 20:40:37',0),
|
||||
('2018_01_09_00_auth.sql','A5D4EC8FCFAB4F2DCE70EDCAD1ACBFB484FD68D5','ARCHIVED','2018-01-09 00:00:00',69),
|
||||
('2018_01_24_00_auth.sql','167B17D8A253D62A8112F8A7EB21C6E99CAEF1E4','ARCHIVED','2018-01-24 00:00:00',73),
|
||||
('2018_02_19_00_auth.sql','80E50F9C7F1EE7BA62789EA4C4F009170B79E6C9','RELEASED','2018-02-18 19:49:37',62);
|
||||
('2018_02_19_00_auth.sql','80E50F9C7F1EE7BA62789EA4C4F009170B79E6C9','RELEASED','2018-02-18 19:49:37',62),
|
||||
('2018_03_06_00_auth.sql','2D71E93DF7419A30D0D21D8A80CF05698302575A','RELEASED','2018-03-06 00:00:00',0);
|
||||
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
5
sql/updates/auth/3.3.5/2018_03_06_00_auth.sql
Normal file
5
sql/updates/auth/3.3.5/2018_03_06_00_auth.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
DELETE FROM `rbac_permissions` WHERE `id`=872;
|
||||
INSERT INTO `rbac_permissions` (`id`, `name`) VALUES
|
||||
(872, 'Command: server debug');
|
||||
INSERT INTO `rbac_linked_permissions` (`id`, `linkedId`) VALUES
|
||||
(196, 872);
|
||||
3
sql/updates/world/3.3.5/2018_03_06_06_world.sql
Normal file
3
sql/updates/world/3.3.5/2018_03_06_06_world.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DELETE FROM `command` WHERE `name`='server debug';
|
||||
INSERT INTO `command` (`name`, `permission`, `help`) VALUES
|
||||
('server debug', 872, 'Syntax: .server debug\n\nShows detailed information about server setup, useful when reporting a bug');
|
||||
@@ -38,6 +38,16 @@ char const* GitRevision::GetCMakeCommand()
|
||||
return _CMAKE_COMMAND;
|
||||
}
|
||||
|
||||
char const* GitRevision::GetCMakeVersion()
|
||||
{
|
||||
return _CMAKE_VERSION;
|
||||
}
|
||||
|
||||
char const* GitRevision::GetHostOSVersion()
|
||||
{
|
||||
return _CMAKE_HOST_SYSTEM;
|
||||
}
|
||||
|
||||
char const* GitRevision::GetBuildDirectory()
|
||||
{
|
||||
return _BUILD_DIRECTORY;
|
||||
|
||||
@@ -26,6 +26,8 @@ namespace GitRevision
|
||||
TC_COMMON_API char const* GetDate();
|
||||
TC_COMMON_API char const* GetBranch();
|
||||
TC_COMMON_API char const* GetCMakeCommand();
|
||||
TC_COMMON_API char const* GetCMakeVersion();
|
||||
TC_COMMON_API char const* GetHostOSVersion();
|
||||
TC_COMMON_API char const* GetBuildDirectory();
|
||||
TC_COMMON_API char const* GetSourceDirectory();
|
||||
TC_COMMON_API char const* GetMySQLExecutable();
|
||||
|
||||
@@ -777,6 +777,7 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869, // reserved
|
||||
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
|
||||
RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871,
|
||||
RBAC_PERM_COMMAND_SERVER_DEBUG = 872,
|
||||
//
|
||||
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
|
||||
//
|
||||
|
||||
@@ -25,6 +25,8 @@ EndScriptData */
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "GameTime.h"
|
||||
#include "GitRevision.h"
|
||||
#include "Language.h"
|
||||
@@ -32,12 +34,21 @@ EndScriptData */
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "RBAC.h"
|
||||
#include "Realm.h"
|
||||
#include "ServerMotd.h"
|
||||
#include "UpdateTime.h"
|
||||
#include "Util.h"
|
||||
#include "VMapFactory.h"
|
||||
#include "World.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <mysql_version.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
class server_commandscript : public CommandScript
|
||||
{
|
||||
public:
|
||||
@@ -82,6 +93,7 @@ public:
|
||||
static std::vector<ChatCommand> serverCommandTable =
|
||||
{
|
||||
{ "corpses", rbac::RBAC_PERM_COMMAND_SERVER_CORPSES, true, &HandleServerCorpsesCommand, "" },
|
||||
{ "debug", rbac::RBAC_PERM_COMMAND_SERVER_DEBUG, true, &HandleServerDebugCommand, "" },
|
||||
{ "exit", rbac::RBAC_PERM_COMMAND_SERVER_EXIT, true, &HandleServerExitCommand, "" },
|
||||
{ "idlerestart", rbac::RBAC_PERM_COMMAND_SERVER_IDLERESTART, true, nullptr, "", serverIdleRestartCommandTable },
|
||||
{ "idleshutdown", rbac::RBAC_PERM_COMMAND_SERVER_IDLESHUTDOWN, true, nullptr, "", serverIdleShutdownCommandTable },
|
||||
@@ -107,6 +119,136 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerDebugCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
uint16 worldPort = uint16(sWorld->getIntConfig(CONFIG_PORT_WORLD));
|
||||
std::string dbPortOutput;
|
||||
|
||||
{
|
||||
uint16 dbPort = 0;
|
||||
if (QueryResult res = LoginDatabase.PQuery("SELECT port FROM realmlist WHERE id = %u", realm.Id.Realm))
|
||||
dbPort = (*res)[0].GetUInt16();
|
||||
|
||||
if (dbPort)
|
||||
dbPortOutput = Trinity::StringFormat("Realmlist (Realm Id: %u) configured in port %" PRIu16, realm.Id.Realm, dbPort);
|
||||
else
|
||||
dbPortOutput = Trinity::StringFormat("Realm Id: %u not found in `realmlist` table. Please check your setup", realm.Id.Realm);
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
|
||||
handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
|
||||
handler->PSendSysMessage("Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
|
||||
handler->PSendSysMessage("Using MySQL version: %s", MYSQL_SERVER_VERSION);
|
||||
handler->PSendSysMessage("Using CMake version: %s", GitRevision::GetCMakeVersion());
|
||||
|
||||
handler->PSendSysMessage("Compiled on: %s", GitRevision::GetHostOSVersion());
|
||||
|
||||
uint32 updateFlags = sConfigMgr->GetIntDefault("Updates.EnableDatabases", DatabaseLoader::DATABASE_NONE);
|
||||
if (!updateFlags)
|
||||
handler->SendSysMessage("Automatic database updates are disabled for all databases!");
|
||||
else
|
||||
{
|
||||
static char const* const databaseNames[3 /*TOTAL_DATABASES*/] =
|
||||
{
|
||||
"Auth",
|
||||
"Characters",
|
||||
"World"
|
||||
};
|
||||
|
||||
std::string availableUpdateDatabases;
|
||||
for (uint32 i = 0; i < 3 /* TOTAL_DATABASES*/; ++i)
|
||||
{
|
||||
if (!(updateFlags & (1 << i)))
|
||||
continue;
|
||||
|
||||
availableUpdateDatabases += databaseNames[i];
|
||||
if (i != 3 /*TOTAL_DATABASES*/ - 1)
|
||||
availableUpdateDatabases += ", ";
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Automatic database updates are enabled for the following databases: %s", availableUpdateDatabases.c_str());
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Worldserver listening connections on port %" PRIu16, worldPort);
|
||||
handler->PSendSysMessage("%s", dbPortOutput.c_str());
|
||||
|
||||
bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK);
|
||||
bool vmapLOSCheck = VMAP::VMapFactory::createOrGetVMapManager()->isLineOfSightCalcEnabled();
|
||||
bool vmapHeightCheck = VMAP::VMapFactory::createOrGetVMapManager()->isHeightCalcEnabled();
|
||||
|
||||
bool mmapEnabled = sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS);
|
||||
|
||||
std::string dataDir = sWorld->GetDataPath();
|
||||
std::vector<std::string> subDirs;
|
||||
subDirs.emplace_back("maps");
|
||||
if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck)
|
||||
{
|
||||
handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: %i, getHeight: %i, indoorCheck: %i", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck);
|
||||
subDirs.emplace_back("vmaps");
|
||||
}
|
||||
else
|
||||
handler->SendSysMessage("VMAPs status: Disabled");
|
||||
|
||||
if (mmapEnabled)
|
||||
{
|
||||
handler->SendSysMessage("MMAPs status: Enabled");
|
||||
subDirs.emplace_back("mmaps");
|
||||
}
|
||||
else
|
||||
handler->SendSysMessage("MMAPs status: Disabled");
|
||||
|
||||
for (std::string const& subDir : subDirs)
|
||||
{
|
||||
boost::filesystem::path mapPath(dataDir);
|
||||
mapPath.append(subDir);
|
||||
|
||||
if (!boost::filesystem::exists(mapPath))
|
||||
{
|
||||
handler->PSendSysMessage("%s directory doesn't exist!. Using path: %s", subDir.c_str(), mapPath.generic_string().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
auto end = boost::filesystem::directory_iterator();
|
||||
std::size_t folderSize = std::accumulate(boost::filesystem::directory_iterator(mapPath), end, std::size_t(0), [](std::size_t val, boost::filesystem::path const& mapFile)
|
||||
{
|
||||
if (boost::filesystem::is_regular_file(mapFile))
|
||||
val += boost::filesystem::file_size(mapFile);
|
||||
return val;
|
||||
});
|
||||
|
||||
handler->PSendSysMessage("%s directory located in %s. Total size: " SZFMTD " bytes", subDir.c_str(), mapPath.generic_string().c_str(), folderSize);
|
||||
}
|
||||
|
||||
LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale();
|
||||
uint32 availableLocalesMask = (1 << defaultLocale);
|
||||
|
||||
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
LocaleConstant locale = static_cast<LocaleConstant>(i);
|
||||
if (locale == defaultLocale)
|
||||
continue;
|
||||
|
||||
if (sWorld->GetAvailableDbcLocale(locale) != defaultLocale)
|
||||
availableLocalesMask |= (1 << locale);
|
||||
}
|
||||
|
||||
std::string availableLocales;
|
||||
for (uint8 i = 0; i < TOTAL_LOCALES; ++i)
|
||||
{
|
||||
if (!(availableLocalesMask & (1 << i)))
|
||||
continue;
|
||||
|
||||
availableLocales += localeNames[i];
|
||||
if (i != TOTAL_LOCALES - 1)
|
||||
availableLocales += " ";
|
||||
}
|
||||
|
||||
handler->PSendSysMessage("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[defaultLocale], availableLocales.c_str());
|
||||
|
||||
handler->PSendSysMessage("Using World DB: %s", sWorld->GetDBVersion());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleServerInfoCommand(ChatHandler* handler, char const* /*args*/)
|
||||
{
|
||||
uint32 playersNum = sWorld->GetPlayerCount();
|
||||
@@ -118,7 +260,7 @@ public:
|
||||
std::string uptime = secsToTimeString(GameTime::GetUptime());
|
||||
uint32 updateTime = sWorldUpdateTime.GetLastUpdateTime();
|
||||
|
||||
handler->SendSysMessage(GitRevision::GetFullVersion());
|
||||
handler->PSendSysMessage("%s", GitRevision::GetFullVersion());
|
||||
handler->PSendSysMessage(LANG_CONNECTED_PLAYERS, playersNum, maxPlayersNum);
|
||||
handler->PSendSysMessage(LANG_CONNECTED_USERS, activeClientsNum, maxActiveClientsNum, queuedClientsNum, maxQueuedClientsNum);
|
||||
handler->PSendSysMessage(LANG_UPTIME, uptime.c_str());
|
||||
|
||||
Reference in New Issue
Block a user