mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-03 23:57:10 +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
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@)"
|
||||
|
||||
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');
|
||||
@@ -21,6 +21,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;
|
||||
|
||||
@@ -27,6 +27,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();
|
||||
|
||||
@@ -767,6 +767,9 @@ enum RBACPermissions
|
||||
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING_LOCALE = 867,
|
||||
RBAC_PERM_COMMAND_MODIFY_POWER = 868, // reserved
|
||||
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,11 +34,20 @@ EndScriptData */
|
||||
#include "ObjectAccessor.h"
|
||||
#include "Player.h"
|
||||
#include "RBAC.h"
|
||||
#include "Realm.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:
|
||||
@@ -81,6 +92,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 },
|
||||
@@ -106,6 +118,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();
|
||||
@@ -117,7 +259,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