mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
cli: Show memory usage instead of RSS
If a task doesn't report RSS, let's use memory usage.
This commit is contained in:
@@ -586,7 +586,13 @@ func (c *AllocStatusCommand) outputTaskResources(alloc *api.Allocation, task str
|
||||
cpuUsage = fmt.Sprintf("%v/%v", math.Floor(cs.TotalTicks), cpuUsage)
|
||||
}
|
||||
if ms := ru.ResourceUsage.MemoryStats; ms != nil {
|
||||
memUsage = fmt.Sprintf("%v/%v", humanize.IBytes(ms.RSS), memUsage)
|
||||
// Nomad uses RSS as the top-level metric to report, for historical reasons,
|
||||
// but it's not always measured (e.g. with cgroup-v2)
|
||||
usage := ms.RSS
|
||||
if usage == 0 && !stringsContain(ms.Measured, "RSS") {
|
||||
usage = ms.Usage
|
||||
}
|
||||
memUsage = fmt.Sprintf("%v/%v", humanize.IBytes(usage), memUsage)
|
||||
}
|
||||
deviceStats = ru.ResourceUsage.DeviceStats
|
||||
}
|
||||
|
||||
@@ -542,3 +542,14 @@ func (w *uiErrorWriter) Close() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// stringsContains returns true if s is present in the vs string slice
|
||||
func stringsContain(vs []string, s string) bool {
|
||||
for _, v := range vs {
|
||||
if v == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user