首页接口重构
This commit is contained in:
@@ -119,4 +119,37 @@ public class DockerUtil {
|
||||
String res = runCommand(accounts, "docker inspect " + containerId);
|
||||
return res != null ? DockerResult.ok(res) : DockerResult.fail("查询详情失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取CPU使用率
|
||||
*/
|
||||
public static String getCpuUsage(MySftpAccounts accounts) {
|
||||
try {
|
||||
return runCommand(accounts, "top -bn1 | grep Cpu | awk '{print 100 - $8}'");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内存使用情况
|
||||
*/
|
||||
public static String getMemoryUsage(MySftpAccounts accounts) {
|
||||
try {
|
||||
return runCommand(accounts, "free -m | grep Mem | awk '{print $3\"MB / \"$2\"MB\"}'");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取磁盘使用情况
|
||||
*/
|
||||
public static String getDiskUsage(MySftpAccounts accounts) {
|
||||
try {
|
||||
return runCommand(accounts, "df -h / | grep / | awk '{print $3\" / \"$2}\" \"$5}'");
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user