mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
rename collector subpackage
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/bcicen/ctop/collector"
|
"github.com/bcicen/ctop/metrics"
|
||||||
"github.com/bcicen/ctop/widgets"
|
"github.com/bcicen/ctop/widgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ type Container struct {
|
|||||||
id string
|
id string
|
||||||
name string
|
name string
|
||||||
state string
|
state string
|
||||||
metrics collector.Metrics
|
metrics metrics.Metrics
|
||||||
widgets widgets.ContainerWidgets
|
widgets widgets.ContainerWidgets
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ func (c *Container) SetState(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read metric stream, updating widgets
|
// Read metric stream, updating widgets
|
||||||
func (c *Container) Read(stream chan collector.Metrics) {
|
func (c *Container) Read(stream chan metrics.Metrics) {
|
||||||
log.Infof("starting reader for container: %s", c.id)
|
log.Infof("starting reader for container: %s", c.id)
|
||||||
go func() {
|
go func() {
|
||||||
for metrics := range stream {
|
for metrics := range stream {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bcicen/ctop/collector"
|
|
||||||
"github.com/bcicen/ctop/config"
|
"github.com/bcicen/ctop/config"
|
||||||
|
"github.com/bcicen/ctop/metrics"
|
||||||
"github.com/bcicen/ctop/widgets"
|
"github.com/bcicen/ctop/widgets"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
type ContainerMap struct {
|
type ContainerMap struct {
|
||||||
client *docker.Client
|
client *docker.Client
|
||||||
containers map[string]*Container
|
containers map[string]*Container
|
||||||
collectors map[string]collector.Collector
|
collectors map[string]metrics.Collector
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContainerMap() *ContainerMap {
|
func NewContainerMap() *ContainerMap {
|
||||||
@@ -25,7 +25,7 @@ func NewContainerMap() *ContainerMap {
|
|||||||
cm := &ContainerMap{
|
cm := &ContainerMap{
|
||||||
client: client,
|
client: client,
|
||||||
containers: make(map[string]*Container),
|
containers: make(map[string]*Container),
|
||||||
collectors: make(map[string]collector.Collector),
|
collectors: make(map[string]metrics.Collector),
|
||||||
}
|
}
|
||||||
cm.Refresh()
|
cm.Refresh()
|
||||||
return cm
|
return cm
|
||||||
@@ -69,7 +69,7 @@ func (cm *ContainerMap) Refresh() {
|
|||||||
if c.state == "running" {
|
if c.state == "running" {
|
||||||
if _, ok := cm.collectors[id]; ok == false {
|
if _, ok := cm.collectors[id]; ok == false {
|
||||||
log.Infof("starting collector for container: %s", id)
|
log.Infof("starting collector for container: %s", id)
|
||||||
cm.collectors[id] = collector.NewDocker(cm.client, id)
|
cm.collectors[id] = metrics.NewDocker(cm.client, id)
|
||||||
cm.collectors[id].Start()
|
cm.collectors[id].Start()
|
||||||
c.Read(cm.collectors[id].Stream())
|
c.Read(cm.collectors[id].Stream())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package collector
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
api "github.com/fsouza/go-dockerclient"
|
api "github.com/fsouza/go-dockerclient"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package collector
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package collector
|
package metrics
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
Reference in New Issue
Block a user