Archiviert
1
0

Fix LoadEvaluation

Fix naming
Dieser Commit ist enthalten in:
yoyosource 2021-06-20 18:03:41 +02:00
Ursprung 72ee7c19c8
Commit 85e129ada6
2 geänderte Dateien mit 8 neuen und 8 gelöschten Zeilen

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){