mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Merge branch 'master' into refresh_periodically
# Conflicts: # connector/docker.go
This commit is contained in:
commit
cc43dbc84e
@ -6,47 +6,67 @@ import (
|
|||||||
|
|
||||||
// defaults
|
// defaults
|
||||||
var defaultColumns = []Column{
|
var defaultColumns = []Column{
|
||||||
Column{
|
{
|
||||||
Name: "status",
|
Name: "status",
|
||||||
Label: "Status Indicator",
|
Label: "Status Indicator",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
Label: "Container Name",
|
Label: "Container Name",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "id",
|
Name: "id",
|
||||||
Label: "Container ID",
|
Label: "Container ID",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
|
Name: "image",
|
||||||
|
Label: "Image name",
|
||||||
|
Enabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "ports",
|
||||||
|
Label: "Exposed ports",
|
||||||
|
Enabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "IPs",
|
||||||
|
Label: "Exposed IPs",
|
||||||
|
Enabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "created",
|
||||||
|
Label: "Date created",
|
||||||
|
Enabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
Name: "cpu",
|
Name: "cpu",
|
||||||
Label: "CPU Usage",
|
Label: "CPU Usage",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "cpus",
|
Name: "cpus",
|
||||||
Label: "CPU Usage (% of system total)",
|
Label: "CPU Usage (% of system total)",
|
||||||
Enabled: false,
|
Enabled: false,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "mem",
|
Name: "mem",
|
||||||
Label: "Memory Usage",
|
Label: "Memory Usage",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "net",
|
Name: "net",
|
||||||
Label: "Network RX/TX",
|
Label: "Network RX/TX",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "io",
|
Name: "io",
|
||||||
Label: "Disk IO Read/Write",
|
Label: "Disk IO Read/Write",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
},
|
},
|
||||||
Column{
|
{
|
||||||
Name: "pids",
|
Name: "pids",
|
||||||
Label: "Container PID Count",
|
Label: "Container PID Count",
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
|
@ -12,6 +12,10 @@ var (
|
|||||||
"status": NewStatus,
|
"status": NewStatus,
|
||||||
"name": NewNameCol,
|
"name": NewNameCol,
|
||||||
"id": NewCIDCol,
|
"id": NewCIDCol,
|
||||||
|
"image": NewImageCol,
|
||||||
|
"ports": NewPortsCol,
|
||||||
|
"IPs": NewIpsCol,
|
||||||
|
"created": NewCreatedCol,
|
||||||
"cpu": NewCPUCol,
|
"cpu": NewCPUCol,
|
||||||
"cpus": NewCpuScaledCol,
|
"cpus": NewCpuScaledCol,
|
||||||
"mem": NewMemCol,
|
"mem": NewMemCol,
|
||||||
|
@ -9,32 +9,44 @@ import (
|
|||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NameCol struct {
|
// Column that shows container's meta property i.e. name, id, image tc.
|
||||||
|
type MetaCol struct {
|
||||||
*TextCol
|
*TextCol
|
||||||
|
metaName string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *MetaCol) SetMeta(m models.Meta) {
|
||||||
|
w.setText(m.Get(w.metaName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNameCol() CompactCol {
|
func NewNameCol() CompactCol {
|
||||||
c := &NameCol{NewTextCol("NAME")}
|
c := &MetaCol{NewTextCol("NAME"), "name"}
|
||||||
c.fWidth = 30
|
c.fWidth = 30
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *NameCol) SetMeta(m models.Meta) {
|
|
||||||
w.setText(m.Get("name"))
|
|
||||||
}
|
|
||||||
|
|
||||||
type CIDCol struct {
|
|
||||||
*TextCol
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewCIDCol() CompactCol {
|
func NewCIDCol() CompactCol {
|
||||||
c := &CIDCol{NewTextCol("CID")}
|
c := &MetaCol{NewTextCol("CID"), "id"}
|
||||||
c.fWidth = 12
|
c.fWidth = 12
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *CIDCol) SetMeta(m models.Meta) {
|
func NewImageCol() CompactCol {
|
||||||
w.setText(m.Get("id"))
|
return &MetaCol{NewTextCol("IMAGE"), "image"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPortsCol() CompactCol {
|
||||||
|
return &MetaCol{NewTextCol("PORTS"), "ports"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIpsCol() CompactCol {
|
||||||
|
return &MetaCol{NewTextCol("IPs"), "IPs"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCreatedCol() CompactCol {
|
||||||
|
c := &MetaCol{NewTextCol("CREATED"), "created"}
|
||||||
|
c.fWidth = 19 // Year will be stripped e.g. "Thu Nov 26 07:44:03" without 2020 at end
|
||||||
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetCol struct {
|
type NetCol struct {
|
||||||
|
@ -3,6 +3,7 @@ package single
|
|||||||
import (
|
import (
|
||||||
ui "github.com/gizak/termui"
|
ui "github.com/gizak/termui"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
var envPattern = regexp.MustCompile(`(?P<KEY>[^=]+)=(?P<VALUJE>.*)`)
|
||||||
@ -23,14 +24,16 @@ func NewEnv() *Env {
|
|||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Env) Set(k, v string) {
|
func (w *Env) Set(allEnvs string) {
|
||||||
match := envPattern.FindStringSubmatch(v)
|
envs := strings.Split(allEnvs, ";")
|
||||||
|
w.Rows = [][]string{}
|
||||||
|
for _, env := range envs {
|
||||||
|
match := envPattern.FindStringSubmatch(env)
|
||||||
key := match[1]
|
key := match[1]
|
||||||
value := match[2]
|
value := match[2]
|
||||||
w.data[key] = value
|
w.data[key] = value
|
||||||
|
|
||||||
w.Rows = [][]string{}
|
|
||||||
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
w.Rows = append(w.Rows, mkInfoRows(key, value)...)
|
||||||
|
}
|
||||||
|
|
||||||
w.Height = len(w.Rows) + 2
|
w.Height = len(w.Rows) + 2
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (e *Single) SetWidth(w int) { e.Width = w }
|
|||||||
func (e *Single) SetMeta(m models.Meta) {
|
func (e *Single) SetMeta(m models.Meta) {
|
||||||
for k, v := range m {
|
for k, v := range m {
|
||||||
if k == "[ENV-VAR]" {
|
if k == "[ENV-VAR]" {
|
||||||
e.Env.Set(k, v)
|
e.Env.Set(v)
|
||||||
} else {
|
} else {
|
||||||
e.Info.Set(k, v)
|
e.Info.Set(k, v)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user