我使用以下,
docker stats <containerId>
或者
docker stats $(docker ps -q)
查看整个容器的内存使用情况。
我使用指标或:
ps -o "pid,rss,command" <pid>
从命令行查看内存使用情况。
或者只是编写您自己的指标“健康检查”:
@Liveness
@ApplicationScoped
public class InfoCheck implements HealthCheck {
private final DecimalFormat nf = new DecimalFormat("###,### MB", new
DecimalFormatSymbols(new Locale("nl")));
@ConfigProperty(name = "quarkus.application.name")
String appName;
@ConfigProperty(name = "app.version")
String version;
@Override
public HealthCheckResponse call() {
nf.setGroupingUsed(true);
nf.setParseIntegerOnly(true);
Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
long maxMemory = runtime.maxMemory();
return HealthCheckResponse.named(this.appName)
.up()
.withData("application.version", this.version)
.withData("cpu.amount", runtime.availableProcessors())
.withData("memory.free", nf.format(freeMemory / (1024 * 1024)))
.withData("memory.allocated", nf.format(totalMemory / (1024 * 1024)))
.withData("memory.total.free", nf.format((freeMemory + (maxMemory - totalMemory)) / (1024 * 1024)))
.build();
}
}