mirror of
https://github.com/bcicen/ctop.git
synced 2025-12-06 23:26:45 +08:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c971d26d42 | ||
|
|
de380ff810 | ||
|
|
e7e2478468 | ||
|
|
42c80c2395 | ||
|
|
d22bbc3420 | ||
|
|
bdfb98265d | ||
|
|
af1908fb27 | ||
|
|
73a976c6fe | ||
|
|
2bcfc365f7 | ||
|
|
ecc7bf4081 | ||
|
|
68e4c32c1b | ||
|
|
a63f05b430 | ||
|
|
41c04fefa2 |
4
Makefile
4
Makefile
@@ -29,10 +29,8 @@ image:
|
|||||||
|
|
||||||
release:
|
release:
|
||||||
mkdir release
|
mkdir release
|
||||||
go get github.com/progrium/gh-release/...
|
|
||||||
cp _build/* release
|
cp _build/* release
|
||||||
cd release; sha256sum --quiet --check sha256sums.txt
|
cd release; sha256sum --quiet --check sha256sums.txt
|
||||||
gh-release create bcicen/$(NAME) $(VERSION) \
|
gh release create $(VERSION) -d -t $(VERSION) *
|
||||||
$(shell git rev-parse --abbrev-ref HEAD) $(VERSION)
|
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
|
|||||||
22
README.md
22
README.md
@@ -17,10 +17,24 @@ as well as a [single container view][single_view] for inspecting a specific cont
|
|||||||
|
|
||||||
Fetch the [latest release](https://github.com/bcicen/ctop/releases) for your platform:
|
Fetch the [latest release](https://github.com/bcicen/ctop/releases) for your platform:
|
||||||
|
|
||||||
#### Linux
|
#### Debian/Ubuntu
|
||||||
|
|
||||||
|
Maintained by a [third party](https://packages.azlux.fr/)
|
||||||
|
```bash
|
||||||
|
echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list
|
||||||
|
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install docker-ctop
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Arch
|
||||||
|
|
||||||
|
`ctop` is available for Arch in the [AUR](https://aur.archlinux.org/packages/ctop-bin/)
|
||||||
|
|
||||||
|
#### Linux (Generic)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.4/ctop-0.7.4-linux-amd64 -O /usr/local/bin/ctop
|
sudo wget https://github.com/bcicen/ctop/releases/download/v0.7.5/ctop-0.7.5-linux-amd64 -O /usr/local/bin/ctop
|
||||||
sudo chmod +x /usr/local/bin/ctop
|
sudo chmod +x /usr/local/bin/ctop
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -31,7 +45,7 @@ brew install ctop
|
|||||||
```
|
```
|
||||||
or
|
or
|
||||||
```bash
|
```bash
|
||||||
sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.4/ctop-0.7.4-darwin-amd64
|
sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/download/v0.7.5/ctop-0.7.5-darwin-amd64
|
||||||
sudo chmod +x /usr/local/bin/ctop
|
sudo chmod +x /usr/local/bin/ctop
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -44,8 +58,6 @@ docker run --rm -ti \
|
|||||||
quay.io/vektorlab/ctop:latest
|
quay.io/vektorlab/ctop:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
`ctop` is also available for Arch in the [AUR](https://aur.archlinux.org/packages/ctop-bin/)
|
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Build steps can be found [here][build].
|
Build steps can be found [here][build].
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ func New(id string, collector collector.Collector, manager manager.Manager) *Con
|
|||||||
return &Container{
|
return &Container{
|
||||||
Metrics: models.NewMetrics(),
|
Metrics: models.NewMetrics(),
|
||||||
Id: id,
|
Id: id,
|
||||||
Meta: models.NewMeta("id", id),
|
Meta: models.NewMeta("id", id[:12]),
|
||||||
Widgets: widgets,
|
Widgets: widgets,
|
||||||
updater: widgets,
|
updater: widgets,
|
||||||
collector: collector,
|
collector: collector,
|
||||||
|
|||||||
@@ -18,11 +18,7 @@ func NewNameCol() CompactCol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *NameCol) SetMeta(m models.Meta) {
|
func (w *NameCol) SetMeta(m models.Meta) {
|
||||||
w.Text = m.Get("name")
|
w.setText(m.Get("name"))
|
||||||
// truncate container id
|
|
||||||
if len(w.Text) > 12 {
|
|
||||||
w.Text = w.Text[:12]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CIDCol struct {
|
type CIDCol struct {
|
||||||
@@ -30,14 +26,13 @@ type CIDCol struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewCIDCol() CompactCol {
|
func NewCIDCol() CompactCol {
|
||||||
return &CIDCol{NewTextCol("CID")}
|
c := &CIDCol{NewTextCol("CID")}
|
||||||
|
c.fWidth = 12
|
||||||
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *CIDCol) SetMeta(m models.Meta) {
|
func (w *CIDCol) SetMeta(m models.Meta) {
|
||||||
w.Text = m.Get("id")
|
w.setText(m.Get("id"))
|
||||||
if len(w.Text) > 12 {
|
|
||||||
w.Text = w.Text[:12]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type NetCol struct {
|
type NetCol struct {
|
||||||
@@ -50,7 +45,7 @@ func NewNetCol() CompactCol {
|
|||||||
|
|
||||||
func (w *NetCol) SetMetrics(m models.Metrics) {
|
func (w *NetCol) SetMetrics(m models.Metrics) {
|
||||||
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.NetRx), cwidgets.ByteFormat64Short(m.NetTx))
|
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.NetRx), cwidgets.ByteFormat64Short(m.NetTx))
|
||||||
w.Text = label
|
w.setText(label)
|
||||||
}
|
}
|
||||||
|
|
||||||
type IOCol struct {
|
type IOCol struct {
|
||||||
@@ -63,7 +58,7 @@ func NewIOCol() CompactCol {
|
|||||||
|
|
||||||
func (w *IOCol) SetMetrics(m models.Metrics) {
|
func (w *IOCol) SetMetrics(m models.Metrics) {
|
||||||
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.IOBytesRead), cwidgets.ByteFormat64Short(m.IOBytesWrite))
|
label := fmt.Sprintf("%s / %s", cwidgets.ByteFormat64Short(m.IOBytesRead), cwidgets.ByteFormat64Short(m.IOBytesWrite))
|
||||||
w.Text = label
|
w.setText(label)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PIDCol struct {
|
type PIDCol struct {
|
||||||
@@ -77,7 +72,7 @@ func NewPIDCol() CompactCol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *PIDCol) SetMetrics(m models.Metrics) {
|
func (w *PIDCol) SetMetrics(m models.Metrics) {
|
||||||
w.Text = fmt.Sprintf("%d", m.Pids)
|
w.setText(fmt.Sprintf("%d", m.Pids))
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextCol struct {
|
type TextCol struct {
|
||||||
@@ -91,7 +86,12 @@ func NewTextCol(header string) *TextCol {
|
|||||||
p.Border = false
|
p.Border = false
|
||||||
p.Height = 1
|
p.Height = 1
|
||||||
p.Width = 20
|
p.Width = 20
|
||||||
return &TextCol{p, header, 0}
|
|
||||||
|
return &TextCol{
|
||||||
|
Par: p,
|
||||||
|
header: header,
|
||||||
|
fWidth: 0,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *TextCol) Highlight() {
|
func (w *TextCol) Highlight() {
|
||||||
@@ -106,8 +106,16 @@ func (w *TextCol) UnHighlight() {
|
|||||||
w.TextBgColor = ui.ThemeAttr("par.text.bg")
|
w.TextBgColor = ui.ThemeAttr("par.text.bg")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *TextCol) Reset() { w.Text = "-" }
|
// TextCol implements CompactCol
|
||||||
|
func (w *TextCol) Reset() { w.setText("-") }
|
||||||
func (w *TextCol) SetMeta(models.Meta) {}
|
func (w *TextCol) SetMeta(models.Meta) {}
|
||||||
func (w *TextCol) SetMetrics(models.Metrics) {}
|
func (w *TextCol) SetMetrics(models.Metrics) {}
|
||||||
func (w *TextCol) Header() string { return w.header }
|
func (w *TextCol) Header() string { return w.header }
|
||||||
func (w *TextCol) FixedWidth() int { return w.fWidth }
|
func (w *TextCol) FixedWidth() int { return w.fWidth }
|
||||||
|
|
||||||
|
func (w *TextCol) setText(s string) {
|
||||||
|
if w.fWidth > 0 && len(s) > w.fWidth {
|
||||||
|
s = s[0:w.fWidth]
|
||||||
|
}
|
||||||
|
w.Text = s
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,14 +13,13 @@ type Info struct {
|
|||||||
data map[string]string
|
data map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewInfo(id string) *Info {
|
func NewInfo() *Info {
|
||||||
p := ui.NewTable()
|
p := ui.NewTable()
|
||||||
p.Height = 4
|
p.Height = 4
|
||||||
p.Width = colWidth[0]
|
p.Width = colWidth[0]
|
||||||
p.FgColor = ui.ThemeAttr("par.text.fg")
|
p.FgColor = ui.ThemeAttr("par.text.fg")
|
||||||
p.Separator = false
|
p.Separator = false
|
||||||
i := &Info{p, make(map[string]string)}
|
i := &Info{p, make(map[string]string)}
|
||||||
i.Set("id", id)
|
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,9 @@ type Single struct {
|
|||||||
Width int
|
Width int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSingle(id string) *Single {
|
func NewSingle() *Single {
|
||||||
if len(id) > 12 {
|
|
||||||
id = id[:12]
|
|
||||||
}
|
|
||||||
return &Single{
|
return &Single{
|
||||||
Info: NewInfo(id),
|
Info: NewInfo(),
|
||||||
Net: NewNet(),
|
Net: NewNet(),
|
||||||
Cpu: NewCpu(),
|
Cpu: NewCpu(),
|
||||||
Mem: NewMem(),
|
Mem: NewMem(),
|
||||||
|
|||||||
2
grid.go
2
grid.go
@@ -83,7 +83,7 @@ func SingleView() MenuFn {
|
|||||||
ui.DefaultEvtStream.ResetHandlers()
|
ui.DefaultEvtStream.ResetHandlers()
|
||||||
defer ui.DefaultEvtStream.ResetHandlers()
|
defer ui.DefaultEvtStream.ResetHandlers()
|
||||||
|
|
||||||
ex := single.NewSingle(c.Id)
|
ex := single.NewSingle()
|
||||||
c.SetUpdater(ex)
|
c.SetUpdater(ex)
|
||||||
|
|
||||||
ex.Align()
|
ex.Align()
|
||||||
|
|||||||
Reference in New Issue
Block a user