multiserver #212
@ -42,7 +42,9 @@ public class LoadEvaluation {
|
||||
|
||||
public static double getRemoteRamPercentage(String remote) {
|
||||
try {
|
||||
Process process = new ProcessBuilder("ssh " + remote + " cat /proc/meminfo").start();
|
||||
// Attention:
|
||||
// memInfo.sh needs to contain: cat /proc/meminfo
|
||||
Process process = new ProcessBuilder("ssh", remote, "\"./memInfo.sh\"").start();
|
||||
process.waitFor();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String memTotal = bufferedReader.readLine().replaceAll(" +", " ");
|
||||
@ -64,7 +66,7 @@ public class LoadEvaluation {
|
||||
try {
|
||||
Process process = new ProcessBuilder("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());
|
||||
return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0;
|
||||
} catch (IOException e) {
|
||||
return 1D;
|
||||
} catch (InterruptedException e) {
|
||||
@ -75,9 +77,11 @@ public class LoadEvaluation {
|
||||
|
||||
public static double getRemoteCPULoad(String remote) {
|
||||
try {
|
||||
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();
|
||||
// Attention:
|
||||
// cpuLoad.sh needs to contain: 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)}'
|
||||
Process process = new ProcessBuilder("ssh", remote, "\"./cpuLoad.sh\"").start();
|
||||
process.waitFor();
|
||||
return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine());
|
||||
return Double.parseDouble(new BufferedReader(new InputStreamReader(process.getInputStream())).readLine()) / 100.0;
|
||||
} catch (IOException e) {
|
||||
return 1D;
|
||||
} catch (InterruptedException e) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren