Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion libpod/stats_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/containers/podman/v5/pkg/rctl"
"github.com/sirupsen/logrus"
"go.podman.io/storage/pkg/system"
"golang.org/x/sys/unix"
)

// getPlatformContainerStats gets the platform-specific running stats
Expand Down Expand Up @@ -127,5 +128,9 @@ func calculateCPUPercent(currentCPU, previousCPU, now, previousSystem uint64) fl
}

func getOnlineCPUs(container *Container) (int, error) {
return 0, nil
if container.state.State != define.ContainerStateRunning {
return -1, fmt.Errorf("container %s is not running: %w", container.ID(), define.ErrCtrStopped)
}
n, err := unix.SysctlUint32("hw.ncpu")
return int(n), err
}
2 changes: 1 addition & 1 deletion pkg/api/handlers/compat/containers_stats_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func statsContainerJSON(ctnr *libpod.Container, stats *define.ContainerStats, pr
TotalUsage: stats.CPUNano,
},
CPU: stats.CPU,
OnlineCPUs: 0,
OnlineCPUs: uint32(onlineCPUs),
ThrottlingData: container.ThrottlingData{},
},
PreCPUStats: preCPUStats,
Expand Down