Fix logic for resource usage -- include disk and reset to 0 when stopped

This commit is contained in:
Dane Everitt
2019-08-17 16:10:48 -07:00
parent c8e6e29abc
commit 9a4f1672f7
3 changed files with 21 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ type ResourceUsage struct {
CpuAbsolute float64 `json:"cpu_absolute"`
// The current disk space being used by the server. This is cached to prevent slow lookup
// issues on frequent refreshes.
Disk uint64 `json:"disk_bytes"`
Disk int64 `json:"disk_bytes"`
// Current network transmit in & out for a container.
Network struct {
RxBytes uint64 `json:"rx_bytes"`
@@ -47,5 +47,5 @@ func (ru *ResourceUsage) CalculateAbsoluteCpu(previousCpu, previousSystem float6
percent = (cpuDelta / systemDelta) * cpus * 100.0
}
return math.Round(percent * 1000) / 1000
}
return math.Round(percent*1000) / 1000
}