Added CPU & RAM information to /co status
This commit is contained in:
parent
e093970992
commit
dbd8723752
7 changed files with 77 additions and 2 deletions
|
|
@ -54,7 +54,6 @@ public class StatusCommand {
|
|||
}
|
||||
|
||||
/*
|
||||
CoreProtect show RAM usage
|
||||
Items processed (since server start)
|
||||
Items processed (last 60 minutes)
|
||||
*/
|
||||
|
|
@ -102,6 +101,42 @@ public class StatusCommand {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
String cpuInfo = "";
|
||||
if (ConfigHandler.processorInfo != null) {
|
||||
String modelName = ConfigHandler.processorInfo.getModelName();
|
||||
if (modelName.contains(" CPU")) {
|
||||
String[] split = ConfigHandler.processorInfo.getModelName().split(" CPU")[0].split(" ");
|
||||
modelName = split[split.length - 1];
|
||||
}
|
||||
else if (modelName.contains(" Processor")) {
|
||||
String[] split = ConfigHandler.processorInfo.getModelName().split(" Processor")[0].split(" ");
|
||||
modelName = split[split.length - 1];
|
||||
}
|
||||
|
||||
String cpuSpeed = ConfigHandler.processorInfo.getMhz();
|
||||
cpuSpeed = String.format("%.2f", Double.valueOf(cpuSpeed) / 1000.0);
|
||||
cpuInfo = modelName + " " + Runtime.getRuntime().availableProcessors() + " x " + cpuSpeed + "GHz.";
|
||||
}
|
||||
else {
|
||||
cpuInfo = "x" + Runtime.getRuntime().availableProcessors() + " " + Phrase.build(Phrase.CPU_CORES);
|
||||
}
|
||||
|
||||
int mb = 1024 * 1024;
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
String usedRAM = String.format("%.2f", Double.valueOf((runtime.totalMemory() - runtime.freeMemory()) / mb) / 1000.0);
|
||||
String totalRAM = String.format("%.2f", Double.valueOf(runtime.maxMemory() / mb) / 1000.0);
|
||||
String systemInformation = Phrase.build(Phrase.RAM_STATS, usedRAM, totalRAM);
|
||||
if (cpuInfo.length() > 0) {
|
||||
systemInformation = cpuInfo + " (" + systemInformation + ")";
|
||||
}
|
||||
|
||||
Chat.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.STATUS_SYSTEM, Color.WHITE, systemInformation));
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Functions.sendMessage(player, Color.DARK_AQUA + "Website: " + Color.WHITE + "www.coreprotect.net/updates/");
|
||||
|
||||
// Functions.sendMessage(player, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DISCORD, Color.WHITE + "www.coreprotect.net/discord/").replaceFirst(":", ":" + Color.WHITE));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue