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

cherry pick of d18f8b94b0

Running this command when reporting bugs is MANDATORY (you can censor paths)
This commit is contained in:
Aokromes
2018-03-14 11:41:09 +01:00
parent 007b5a68c5
commit bc88d3bc15
11 changed files with 183 additions and 18 deletions

View File

@@ -12,15 +12,16 @@ addons:
apt:
sources:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:kzemek/boost'
packages:
- g++-6
- libboost1.55-dev
- libboost-filesystem1.55-dev
- libboost-iostreams1.55-dev
- libboost-program-options1.55-dev
- libboost-regex1.55-dev
- libboost-system1.55-dev
- libboost-thread1.55-dev
- libboost1.58-dev
- libboost-filesystem1.58-dev
- libboost-iostreams1.58-dev
- libboost-program-options1.58-dev
- libboost-regex1.58-dev
- libboost-system1.58-dev
- libboost-thread1.58-dev
- libssl-dev
- libmysqlclient-dev
- libreadline6-dev

View File

@@ -38,9 +38,9 @@ check_cxx_source_compiles("
STD_HAS_WORKING_WREGEX)
if (STD_HAS_WORKING_WREGEX)
find_package(Boost 1.55 REQUIRED system filesystem thread program_options iostreams)
find_package(Boost 1.58 REQUIRED system filesystem thread program_options iostreams)
else()
find_package(Boost 1.55 REQUIRED system filesystem thread program_options iostreams regex)
find_package(Boost 1.58 REQUIRED system filesystem thread program_options iostreams regex)
endif()
# Find if Boost was compiled in C++03 mode because it requires -DBOOST_NO_CXX11_SCOPED_ENUMS

View File

@@ -27,10 +27,7 @@ CHANGEME 3.3.5, master or both
**TC rev. hash/commit:**
CHANGEME Copy the first line of the `worldserver`, `authserver` or `bnetserver` startup.
For example: TrinityCore rev. 0000000000 2000-01-09 11:31:41 +0100 (my branch) (Win64, RelWithDebInfo, Static) (bnetserver)
**TDB version:** CHANGEME Version of the TrinityCore database
CHANGEME Copy the result of server debug command
**Operating system:** CHANGEME OS

View File

@@ -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@)"

View File

@@ -1106,6 +1106,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
(196,842),
(196,843),
(196,869),
(196,872),
(197,232),
(197,236),
(197,237),
@@ -2026,7 +2027,8 @@ INSERT INTO `rbac_permissions` VALUES
(853,'Command: .reload conversation_template'),
(854,'Command: .debug conversation'),
(868,'Command: modify power'),
(869,'Command: debug send playerchoice');
(869,'Command: debug send playerchoice'),
(872,'Command: server debug');
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
UNLOCK TABLES;
@@ -2232,8 +2234,9 @@ INSERT INTO `updates` VALUES
('2017_12_31_00_auth.sql','1721ACBD35EB95FAE33B9E95F8C4E4B1FB70A5E4','ARCHIVED','2017-12-31 20:15:23',0),
('2018_01_02_00_auth.sql','CD9B826B9D95697DC412DEF780E814FA3991D6CD','ARCHIVED','2018-01-02 20:40:37',0),
('2018_02_18_00_auth.sql','8489DD3EFFE14A7486B593435F0BA2BC69B6EABF','ARCHIVED','2018-02-18 16:35:55',0),
('2018_02_19_00_auth.sql','07CE658C5EF88693D3C047EF8E724F94ADA74C15','RELEASED','2018-02-19 22:33:32',233),
('2018_02_28_00_auth.sql','E92EF4ABF7FA0C66649E1633DD0459F44C09EB83','RELEASED','2018-02-28 23:07:59',0);
('2018_02_19_00_auth.sql','07CE658C5EF88693D3C047EF8E724F94ADA74C15','ARCHIVED','2018-02-19 22:33:32',233),
('2018_02_28_00_auth.sql','E92EF4ABF7FA0C66649E1633DD0459F44C09EB83','ARCHIVED','2018-02-28 23:07:59',0),
('2018_03_14_00_auth.sql','2D71E93DF7419A30D0D21D8A80CF05698302575A','ARCHIVED','2018-03-14 23:07:59',0),
/*!40000 ALTER TABLE `updates` ENABLE KEYS */;
UNLOCK TABLES;

View 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);

View 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');

View File

@@ -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;

View File

@@ -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();

View File

@@ -776,7 +776,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869,
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870, // reserved
RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871, // reserved
RBAC_PERM_COMMAND_SERVER_DEBUG = 872, // reserved
RBAC_PERM_COMMAND_SERVER_DEBUG = 872,
//
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN 3.3.5 BRANCH AS WELL!
//

View File

@@ -25,16 +25,27 @@ EndScriptData */
#include "ScriptMgr.h"
#include "Chat.h"
#include "Config.h"
#include "DatabaseEnv.h"
#include "DatabaseLoader.h"
#include "GitRevision.h"
#include "Language.h"
#include "Log.h"
#include "ObjectAccessor.h"
#include "Player.h"
#include "RBAC.h"
#include "Realm.h"
#include "Util.h"
#include "VMapFactory.h"
#include "World.h"
#include "WorldSession.h"
#include <numeric>
#include <boost/filesystem/operations.hpp>
#include <mysql_version.h>
#include <openssl/crypto.h>
#include <openssl/opensslv.h>
class server_commandscript : public CommandScript
{
public:
@@ -79,6 +90,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 },
@@ -104,6 +116,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();
@@ -115,7 +257,7 @@ public:
std::string uptime = secsToTimeString(sWorld->GetUptime());
uint32 updateTime = sWorld->GetUpdateTime();
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());