From 85e129ada651dd376e90d9c1474ba325dab1fe2c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Jun 2021 18:03:41 +0200 Subject: [PATCH] Fix LoadEvaluation Fix naming --- src/de/steamwar/bungeecore/LoadEvaluation.java | 8 ++++---- src/de/steamwar/bungeecore/SubserverSystem.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/LoadEvaluation.java b/src/de/steamwar/bungeecore/LoadEvaluation.java index d1785af1..d4acab05 100644 --- a/src/de/steamwar/bungeecore/LoadEvaluation.java +++ b/src/de/steamwar/bungeecore/LoadEvaluation.java @@ -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) { diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java index 3498008a..d002d2c3 100644 --- a/src/de/steamwar/bungeecore/SubserverSystem.java +++ b/src/de/steamwar/bungeecore/SubserverSystem.java @@ -239,7 +239,7 @@ public class SubserverSystem { List 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){