summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-13 06:28:00 -0500
committerGitHub <noreply@github.com>2021-01-13 06:28:00 -0500
commit183f443a585a3659d807ee413e5b708d37a72924 (patch)
tree0290cdb28a22d59151aae228d24e10fa1b70d2af /cmd/podman
parent85460bc41cb67e668bc8b7196346685691953176 (diff)
parenta2367705be776d4e2b2f5ee0563c56e27ddcef8f (diff)
downloadpodman-183f443a585a3659d807ee413e5b708d37a72924.tar.gz
podman-183f443a585a3659d807ee413e5b708d37a72924.tar.bz2
podman-183f443a585a3659d807ee413e5b708d37a72924.zip
Merge pull request #8957 from srcshelton/feature/issue-8945
Add 'MemUsageBytes' format option
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/stats.go27
-rw-r--r--cmd/podman/pods/stats.go11
2 files changed, 26 insertions, 12 deletions
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index ca5c0fdb8..1a436aaef 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -147,13 +147,14 @@ func stats(cmd *cobra.Command, args []string) error {
func outputStats(reports []define.ContainerStats) error {
headers := report.Headers(define.ContainerStats{}, map[string]string{
- "ID": "ID",
- "CPUPerc": "CPU %",
- "MemUsage": "MEM USAGE / LIMIT",
- "MemPerc": "MEM %",
- "NetIO": "NET IO",
- "BlockIO": "BLOCK IO",
- "PIDS": "PIDS",
+ "ID": "ID",
+ "CPUPerc": "CPU %",
+ "MemUsage": "MEM USAGE / LIMIT",
+ "MemUsageBytes": "MEM USAGE / LIMIT",
+ "MemPerc": "MEM %",
+ "NetIO": "NET IO",
+ "BlockIO": "BLOCK IO",
+ "PIDS": "PIDS",
})
if !statsOptions.NoReset {
tm.Clear()
@@ -222,10 +223,15 @@ func (s *containerStats) PIDS() string {
}
return fmt.Sprintf("%d", s.PIDs)
}
+
func (s *containerStats) MemUsage() string {
return combineHumanValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit)
}
+func (s *containerStats) MemUsageBytes() string {
+ return combineBytesValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit)
+}
+
func floatToPercentString(f float64) string {
strippedFloat, err := utils.RemoveScientificNotationFromFloat(f)
if err != nil || strippedFloat == 0 {
@@ -242,6 +248,13 @@ func combineHumanValues(a, b uint64) string {
return fmt.Sprintf("%s / %s", units.HumanSize(float64(a)), units.HumanSize(float64(b)))
}
+func combineBytesValues(a, b uint64) string {
+ if a == 0 && b == 0 {
+ return "-- / --"
+ }
+ return fmt.Sprintf("%s / %s", units.BytesSize(float64(a)), units.BytesSize(float64(b)))
+}
+
func outputJSON(stats []containerStats) error {
type jstat struct {
Id string `json:"id"` // nolint
diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go
index 79e7cd8ed..5f79fa016 100644
--- a/cmd/podman/pods/stats.go
+++ b/cmd/podman/pods/stats.go
@@ -75,11 +75,12 @@ func stats(cmd *cobra.Command, args []string) error {
doJSON := report.IsJSON(row)
headers := report.Headers(entities.PodStatsReport{}, map[string]string{
- "CPU": "CPU %",
- "MemUsage": "MEM USAGE/ LIMIT",
- "MEM": "MEM %",
- "NET IO": "NET IO",
- "BlockIO": "BLOCK IO",
+ "CPU": "CPU %",
+ "MemUsage": "MEM USAGE/ LIMIT",
+ "MemUsageBytes": "MEM USAGE/ LIMIT",
+ "MEM": "MEM %",
+ "NET IO": "NET IO",
+ "BlockIO": "BLOCK IO",
})
for ; ; time.Sleep(time.Second) {