mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:03:22 +08:00
Add total space to disk health information
Previously, disk health information only included the amount of free space and the configured threshold. This commit adds the disk’s total space. See gh-2705
This commit is contained in:
parent
96f390a5a5
commit
e270a21b82
@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.boot.actuate.health;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -45,7 +47,8 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
@Override
|
||||
protected void doHealthCheck(Health.Builder builder) throws Exception {
|
||||
long diskFreeInBytes = this.properties.getPath().getFreeSpace();
|
||||
File path = this.properties.getPath();
|
||||
long diskFreeInBytes = path.getFreeSpace();
|
||||
if (diskFreeInBytes >= this.properties.getThreshold()) {
|
||||
builder.up();
|
||||
}
|
||||
@ -55,7 +58,8 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
|
||||
this.properties.getThreshold()));
|
||||
builder.down();
|
||||
}
|
||||
builder.withDetail("free", diskFreeInBytes).withDetail("threshold",
|
||||
this.properties.getThreshold());
|
||||
builder.withDetail("total", path.getTotalSpace())
|
||||
.withDetail("free", diskFreeInBytes)
|
||||
.withDetail("threshold", this.properties.getThreshold());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user