Add RamUsage.getLoad
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
c558db31b3
Commit
9ac0a847e5
@ -42,6 +42,19 @@ public class RamUsage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getLoad() {
|
||||||
|
try {
|
||||||
|
Process process = new ProcessBuilder("bash", "-c", "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) {
|
||||||
|
return 1D;
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return 1D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static long getNumber(String s) {
|
private static long getNumber(String s) {
|
||||||
return Long.parseLong(s.split(" ")[1]);
|
return Long.parseLong(s.split(" ")[1]);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren