mirror of
https://github.com/bcicen/ctop.git
synced 2025-11-09 04:35:40 +01:00
31 lines
431 B
Go
31 lines
431 B
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
ui "github.com/gizak/termui"
|
||
|
|
)
|
||
|
|
|
||
|
|
type Container struct {
|
||
|
|
cid *ui.Par
|
||
|
|
cpu *ui.Gauge
|
||
|
|
memory *ui.Gauge
|
||
|
|
}
|
||
|
|
|
||
|
|
func (c *Container) UpdateCPU(n int) {
|
||
|
|
c.cpu.BarColor = colorScale(n)
|
||
|
|
c.cpu.Percent = n
|
||
|
|
}
|
||
|
|
|
||
|
|
func (c *Container) UpdateMem(n int) {
|
||
|
|
c.memory.Percent = n
|
||
|
|
}
|
||
|
|
|
||
|
|
func colorScale(n int) ui.Attribute {
|
||
|
|
if n > 70 {
|
||
|
|
return ui.ColorRed
|
||
|
|
}
|
||
|
|
if n > 30 {
|
||
|
|
return ui.ColorYellow
|
||
|
|
}
|
||
|
|
return ui.ColorGreen
|
||
|
|
}
|