SteamWar/BungeeCore
Archiviert
13
2

multiserver #212

Manuell gemergt
Lixfel hat 3 Commits von multiserver nach master 2021-06-20 19:33:34 +02:00 zusammengeführt
2 geänderte Dateien mit 8 neuen und 8 gelöschten Zeilen
Nur Änderungen aus Commit 85e129ada6 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -40,9 +40,9 @@ public class LoadEvaluation {
}
}
public static double getRemoteRamPercentage() {
public static double getRemoteRamPercentage(String remote) {
try {
Process process = new ProcessBuilder("ssh lx cat /proc/meminfo").start();
Process process = new ProcessBuilder("ssh " + remote + " cat /proc/meminfo").start();
process.waitFor();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String memTotal = bufferedReader.readLine().replaceAll(" +", " ");
@ -73,9 +73,9 @@ public class LoadEvaluation {
}
}
public static double getRemoteCPULoad() {
public static double getRemoteCPULoad(String remote) {
try {
Process process = new ProcessBuilder("ssh lx cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start();
Process process = new ProcessBuilder("ssh " + remote + " cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS=\"\" '{printf \"%.2f\\n\", ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}'").start();
process.waitFor();
return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine());
} catch (IOException e) {

Datei anzeigen

@ -239,7 +239,7 @@ public class SubserverSystem {
List<String> cmd = new ArrayList<>();
boolean jdk11 = serverJar.contains("1.15.2");
if(!steamwarStartAvailible() && lixfelStartAvailible()){
if(!steamwarStartAvailable() && lixfelStartAvailable()){
cmd.add("ssh");
cmd.add("-L");
cmd.add(port + ":localhost:" + port);
@ -274,12 +274,12 @@ public class SubserverSystem {
return cmd;
}
private static boolean steamwarStartAvailible(){
private static boolean steamwarStartAvailable(){
return LoadEvaluation.getCPULoad() < 0.8 && LoadEvaluation.getRamPercentage() < 0.8;
}
private static boolean lixfelStartAvailible(){
return LoadEvaluation.getRemoteCPULoad() < 0.8 && LoadEvaluation.getRemoteRamPercentage() < 0.8;
private static boolean lixfelStartAvailable(){
return LoadEvaluation.getRemoteCPULoad("lx") < 0.8 && LoadEvaluation.getRemoteRamPercentage("lx") < 0.8;
}
private static boolean bauRunning(ProxiedPlayer p, UUID owner){