mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 09:09:46 +03:00
[FEATURE] serverStatusCommand
This commit is contained in:
parent
68540a1c44
commit
790dc5003a
2 changed files with 43 additions and 7 deletions
|
@ -44,13 +44,7 @@
|
||||||
import ru.gravit.launchserver.command.hash.UnindexAssetCommand;
|
import ru.gravit.launchserver.command.hash.UnindexAssetCommand;
|
||||||
import ru.gravit.launchserver.command.modules.LoadModuleCommand;
|
import ru.gravit.launchserver.command.modules.LoadModuleCommand;
|
||||||
import ru.gravit.launchserver.command.modules.ModulesCommand;
|
import ru.gravit.launchserver.command.modules.ModulesCommand;
|
||||||
import ru.gravit.launchserver.command.service.ConfigCommand;
|
import ru.gravit.launchserver.command.service.*;
|
||||||
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.utils.helper.LogHelper;
|
import ru.gravit.utils.helper.LogHelper;
|
||||||
import ru.gravit.utils.helper.VerifyHelper;
|
import ru.gravit.utils.helper.VerifyHelper;
|
||||||
|
|
||||||
|
@ -153,6 +147,7 @@ protected CommandHandler(LaunchServer server) {
|
||||||
registerCommand("configHelp", new ConfigHelpCommand(server));
|
registerCommand("configHelp", new ConfigHelpCommand(server));
|
||||||
registerCommand("configList", new ConfigListCommand(server));
|
registerCommand("configList", new ConfigListCommand(server));
|
||||||
registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server));
|
registerCommand("swapAuthProvider", new SwapAuthProviderCommand(server));
|
||||||
|
registerCommand("serverStatus", new ServerStatusCommand(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue