mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 15:16:41 +08:00
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user