mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Use percent() function to calc CPU usage
This commit is contained in:
parent
a22d99fefb
commit
3a29c94833
@ -86,9 +86,9 @@ func (c *Docker) ReadCPU(stats *api.Stats) {
|
||||
syscpudiff := system - c.lastSysCpu
|
||||
|
||||
if c.scaleCpu {
|
||||
c.CPUUtil = round((cpudiff / syscpudiff * 100))
|
||||
c.CPUUtil = percent(cpudiff, syscpudiff)
|
||||
} else {
|
||||
c.CPUUtil = round((cpudiff / syscpudiff * 100) * ncpus)
|
||||
c.CPUUtil = percent(ncpus*cpudiff, syscpudiff)
|
||||
}
|
||||
c.lastCpu = total
|
||||
c.lastSysCpu = system
|
||||
|
@ -96,9 +96,9 @@ func (c *Runc) ReadCPU(stats *cgroups.Stats) {
|
||||
syscpudiff := system - c.lastSysCpu
|
||||
|
||||
if c.scaleCpu {
|
||||
c.CPUUtil = round((cpudiff / syscpudiff * 100))
|
||||
c.CPUUtil = percent(cpudiff, syscpudiff)
|
||||
} else {
|
||||
c.CPUUtil = round((cpudiff / syscpudiff * 100) * ncpus)
|
||||
c.CPUUtil = percent(ncpus*cpudiff, syscpudiff)
|
||||
}
|
||||
c.lastCpu = total
|
||||
c.lastSysCpu = system
|
||||
|
Loading…
Reference in New Issue
Block a user