mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Revert "Added Ports information to the expanded view"
This reverts commit b2165b6a29
.
This commit is contained in:
@ -18,7 +18,6 @@ type Expanded struct {
|
|||||||
Cpu *Cpu
|
Cpu *Cpu
|
||||||
Mem *Mem
|
Mem *Mem
|
||||||
IO *IO
|
IO *IO
|
||||||
Ports *Ports
|
|
||||||
X, Y int
|
X, Y int
|
||||||
Width int
|
Width int
|
||||||
}
|
}
|
||||||
@ -33,7 +32,6 @@ func NewExpanded(id string) *Expanded {
|
|||||||
Cpu: NewCpu(),
|
Cpu: NewCpu(),
|
||||||
Mem: NewMem(),
|
Mem: NewMem(),
|
||||||
IO: NewIO(),
|
IO: NewIO(),
|
||||||
Ports: NewPorts(),
|
|
||||||
Width: ui.TermWidth(),
|
Width: ui.TermWidth(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +60,6 @@ func (e *Expanded) SetMetrics(m metrics.Metrics) {
|
|||||||
e.Net.Update(m.NetRx, m.NetTx)
|
e.Net.Update(m.NetRx, m.NetTx)
|
||||||
e.Mem.Update(int(m.MemUsage), int(m.MemLimit))
|
e.Mem.Update(int(m.MemUsage), int(m.MemLimit))
|
||||||
e.IO.Update(m.IOBytesRead, m.IOBytesWrite)
|
e.IO.Update(m.IOBytesRead, m.IOBytesWrite)
|
||||||
e.Ports.Update(m.PortsExposed, m.PortsOpen)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return total column height
|
// Return total column height
|
||||||
@ -72,7 +69,6 @@ func (e *Expanded) GetHeight() (h int) {
|
|||||||
h += e.Cpu.Height
|
h += e.Cpu.Height
|
||||||
h += e.Mem.Height
|
h += e.Mem.Height
|
||||||
h += e.IO.Height
|
h += e.IO.Height
|
||||||
h += e.Ports.Height
|
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +106,6 @@ func (e *Expanded) Buffer() ui.Buffer {
|
|||||||
buf.Merge(e.Mem.Buffer())
|
buf.Merge(e.Mem.Buffer())
|
||||||
buf.Merge(e.Net.Buffer())
|
buf.Merge(e.Net.Buffer())
|
||||||
buf.Merge(e.IO.Buffer())
|
buf.Merge(e.IO.Buffer())
|
||||||
buf.Merge(e.Ports.Buffer())
|
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +113,6 @@ func (e *Expanded) all() []ui.GridBufferer {
|
|||||||
return []ui.GridBufferer{
|
return []ui.GridBufferer{
|
||||||
e.Info,
|
e.Info,
|
||||||
e.Cpu,
|
e.Cpu,
|
||||||
e.Ports,
|
|
||||||
e.Mem,
|
e.Mem,
|
||||||
e.Net,
|
e.Net,
|
||||||
e.IO,
|
e.IO,
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
package expanded
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
ui "github.com/gizak/termui"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Ports struct {
|
|
||||||
*ui.Table
|
|
||||||
Exposed []int
|
|
||||||
Open [][]int
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewPorts() *Ports {
|
|
||||||
t := ui.NewTable()
|
|
||||||
t.BorderLabel = "Ports"
|
|
||||||
t.Height = 4
|
|
||||||
t.Width = colWidth[0]
|
|
||||||
t.FgColor = ui.ThemeAttr("par.text.fg")
|
|
||||||
t.Separator = false
|
|
||||||
p := &Ports{t, nil, nil}
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Ports) Update(exposed []int64, open [][]int64) {
|
|
||||||
p.Rows = [][]string{}
|
|
||||||
|
|
||||||
exp_string := ""
|
|
||||||
for i, exp := range exposed {
|
|
||||||
if i == 0 {
|
|
||||||
exp_string = strconv.Itoa(int(exp))
|
|
||||||
} else {
|
|
||||||
exp_string = strings.Join([]string{exp_string, strconv.Itoa(int(exp))}, ", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.Rows = append(p.Rows, []string{"Exposed: ", exp_string})
|
|
||||||
|
|
||||||
open_string := ""
|
|
||||||
for i, op := range open {
|
|
||||||
ported := strings.Join([]string{strconv.Itoa(int(op[0])), strconv.Itoa(int(op[1]))}, " -> ")
|
|
||||||
if i == 0 {
|
|
||||||
open_string = ported
|
|
||||||
} else {
|
|
||||||
open_string = strings.Join([]string{open_string, ported}, ", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.Rows = append(p.Rows, []string{"Open: ", open_string})
|
|
||||||
}
|
|
@ -46,7 +46,6 @@ func (c *Docker) Start() {
|
|||||||
c.ReadCPU(s)
|
c.ReadCPU(s)
|
||||||
c.ReadMem(s)
|
c.ReadMem(s)
|
||||||
c.ReadNet(s)
|
c.ReadNet(s)
|
||||||
c.ReadPorts()
|
|
||||||
c.ReadIO(s)
|
c.ReadIO(s)
|
||||||
c.stream <- c.Metrics
|
c.stream <- c.Metrics
|
||||||
}
|
}
|
||||||
@ -90,27 +89,6 @@ func (c *Docker) ReadMem(stats *api.Stats) {
|
|||||||
c.MemPercent = round((float64(c.MemUsage) / float64(c.MemLimit)) * 100)
|
c.MemPercent = round((float64(c.MemUsage) / float64(c.MemLimit)) * 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Docker) ReadPorts() {
|
|
||||||
containers, err := c.client.ListContainers(api.ListContainersOptions{All: true})
|
|
||||||
if err != nil {
|
|
||||||
log.Infof("Error gathering containers")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, container := range containers {
|
|
||||||
if container.ID == c.id {
|
|
||||||
c.PortsOpen = [][]int64{}
|
|
||||||
c.PortsExposed = []int64{}
|
|
||||||
for _, port := range container.Ports {
|
|
||||||
if port.PublicPort > 0 {
|
|
||||||
c.PortsOpen = append(c.PortsOpen, []int64{port.PrivatePort, port.PublicPort})
|
|
||||||
} else {
|
|
||||||
c.PortsExposed = append(c.PortsExposed, port.PrivatePort)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Docker) ReadNet(stats *api.Stats) {
|
func (c *Docker) ReadNet(stats *api.Stats) {
|
||||||
var rx, tx int64
|
var rx, tx int64
|
||||||
for _, network := range stats.Networks {
|
for _, network := range stats.Networks {
|
||||||
|
@ -18,22 +18,18 @@ type Metrics struct {
|
|||||||
IOBytesRead int64
|
IOBytesRead int64
|
||||||
IOBytesWrite int64
|
IOBytesWrite int64
|
||||||
Pids int
|
Pids int
|
||||||
PortsExposed []int64
|
|
||||||
PortsOpen [][]int64
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMetrics() Metrics {
|
func NewMetrics() Metrics {
|
||||||
return Metrics{
|
return Metrics{
|
||||||
CPUUtil: -1,
|
CPUUtil: -1,
|
||||||
NetTx: -1,
|
NetTx: -1,
|
||||||
NetRx: -1,
|
NetRx: -1,
|
||||||
MemUsage: -1,
|
MemUsage: -1,
|
||||||
MemPercent: -1,
|
MemPercent: -1,
|
||||||
IOBytesRead: -1,
|
IOBytesRead: -1,
|
||||||
IOBytesWrite: -1,
|
IOBytesWrite: -1,
|
||||||
Pids: -1,
|
Pids: -1,
|
||||||
PortsExposed: nil,
|
|
||||||
PortsOpen: nil,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user