mirror of
https://github.com/containers/podman.git
synced 2025-10-10 15:57:33 +08:00
Merge pull request #27105 from markjdb/main
A couple of minor stats improvements for FreeBSD
This commit is contained in:
@ -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
|
||||
@ -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
|
||||
}
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user