mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
37 lines
743 B
Go
37 lines
743 B
Go
package main
|
|
|
|
import (
|
|
"github.com/bcicen/ctop/collector"
|
|
"github.com/bcicen/ctop/widgets"
|
|
)
|
|
|
|
type Container struct {
|
|
id string
|
|
name string
|
|
dead bool
|
|
metrics collector.Metrics
|
|
collect collector.Collector
|
|
widgets widgets.ContainerWidgets
|
|
}
|
|
|
|
func (c *Container) Expand() {
|
|
c.widgets = widgets.NewExpanded(c.id, c.name)
|
|
}
|
|
|
|
func (c *Container) Collapse() {
|
|
c.widgets = widgets.NewCompact(c.id, c.name)
|
|
}
|
|
|
|
func (c *Container) Collect() {
|
|
c.collect.Start()
|
|
go func() {
|
|
for metrics := range c.collect.Stream() {
|
|
c.metrics = metrics
|
|
c.widgets.SetCPU(metrics.CPUUtil)
|
|
c.widgets.SetMem(metrics.MemUsage, metrics.MemLimit, metrics.MemPercent)
|
|
c.widgets.SetNet(metrics.NetRx, metrics.NetTx)
|
|
}
|
|
c.dead = true
|
|
}()
|
|
}
|