diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java index 3858c826..51b125bd 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/handler/CommandHandler.java @@ -44,13 +44,7 @@ import ru.gravit.launchserver.command.hash.UnindexAssetCommand; import ru.gravit.launchserver.command.modules.LoadModuleCommand; import ru.gravit.launchserver.command.modules.ModulesCommand; -import ru.gravit.launchserver.command.service.ConfigCommand; -import ru.gravit.launchserver.command.service.ConfigHelpCommand; -import ru.gravit.launchserver.command.service.ConfigListCommand; -import ru.gravit.launchserver.command.service.ReloadAllCommand; -import ru.gravit.launchserver.command.service.ReloadCommand; -import ru.gravit.launchserver.command.service.ReloadListCommand; -import ru.gravit.launchserver.command.service.SwapAuthProviderCommand; +import ru.gravit.launchserver.command.service.*; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.VerifyHelper; @@ -153,6 +147,7 @@ protected CommandHandler(LaunchServer server) { registerCommand("configHelp", new ConfigHelpCommand(server)); registerCommand("configList", new ConfigListCommand(server)); registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server)); + registerCommand("serverStatus", new ServerStatusCommand(server)); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java new file mode 100644 index 00000000..8978453b --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/service/ServerStatusCommand.java @@ -0,0 +1,41 @@ +package ru.gravit.launchserver.command.service; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.launchserver.auth.handler.CachedAuthHandler; +import ru.gravit.launchserver.command.Command; +import ru.gravit.utils.helper.JVMHelper; +import ru.gravit.utils.helper.LogHelper; + +public class ServerStatusCommand extends Command { + public ServerStatusCommand(LaunchServer server) { + super(server); + } + + @Override + public String getArgsDescription() { + return null; + } + + @Override + public String getUsageDescription() { + return "Check server status"; + } + + @Override + public void invoke(String... args) throws Exception { + LogHelper.info("Show server status"); + LogHelper.info("Memory: free %d | total: %d | max: %d", JVMHelper.RUNTIME.freeMemory(), JVMHelper.RUNTIME.totalMemory(),JVMHelper.RUNTIME.maxMemory()); + long uptime = JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000; + long second = uptime % 60; + long min = (uptime / 60) % 60; + long hour = (uptime / 60 / 60) % 24; + long days = (uptime / 60 / 60 / 24); + LogHelper.info("Uptime: %d days %d hours %d minutes %d seconds",days,hour,min,second); + LogHelper.info("Uptime (double): %f", (double)JVMHelper.RUNTIME_MXBEAN.getUptime() / 1000); + LogHelper.info("Sessions: %d | Modules: %d | Commands: %d",server.sessionManager.getSessions().size(), server.modulesManager.modules.size(), server.commandHandler.commandsMap().size()); + if(server.config.authHandler instanceof CachedAuthHandler) + { + LogHelper.info("AuthHandler: EntryCache: %d | usernameCache: %d",((CachedAuthHandler) server.config.authHandler).getEntryCache().size(),((CachedAuthHandler) server.config.authHandler).getUsernamesCache().size()); + } + } +}