Compare commits

..

9 Commits

Author SHA1 Message Date
bradley
59f00dd6aa Merge pull request #296 from utix/patch-1
Fix running icon
2022-08-01 06:32:57 -05:00
bradley
06265407b2 Merge pull request #306 from jnishwanth/patch-1
updated README.md
2022-08-01 06:24:33 -05:00
bradley
a08150ea9c Merge pull request #303 from wdiazux/master
Fix apt-key is deprecated
2022-08-01 06:23:25 -05:00
Alex Stelmachonak
6bf41ea05f Add Windows-specific intructions and badge for scoop (#295) 2022-08-01 07:21:06 -04:00
Jeya Nishwanth
3dff9970ad updated README.md
`ctop` has been added to the arch community repository. Hence can be installed without the AUR now!
2022-06-12 03:07:41 +05:30
William Diaz
458ef62f80 Required packages to set up the repository 2022-05-21 23:06:07 -06:00
William Diaz
a821deb3b4 Fix apt-key is deprecated 2022-05-21 22:48:46 -06:00
Aurélien Lajoie
dacd3be920 Fix running icon
Use ▶ for running status
2022-04-26 19:10:52 +02:00
Bradley Cicenas
222a7d77b2 Squashed commit of the following:
commit 9968c504a5
Author: Florian Vahl <florian@flova.de>
Date:   Tue Feb 1 00:37:31 2022 +0100

    Fix formating (Spaces -> Tabs)

commit 6b8840647e
Author: Florian <florian@flova.de>
Date:   Tue Feb 1 00:27:44 2022 +0100

    Use better duration formating

commit 815dc6ec84
Author: Florian <florian@flova.de>
Date:   Tue Feb 1 00:27:04 2022 +0100

    Fix date formating in 'created' col

commit 05b17798f8
Author: Florian <florian@flova.de>
Date:   Tue Feb 1 00:26:08 2022 +0100

    Add fix from #275 for uptime of running containers
2022-03-30 14:13:10 -04:00
5 changed files with 31 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
# #
![release][release] ![homebrew][homebrew] ![macports][macports] ![release][release] ![homebrew][homebrew] ![macports][macports] ![scoop][scoop]
Top-like interface for container metrics Top-like interface for container metrics
@@ -21,15 +21,23 @@ Fetch the [latest release](https://github.com/bcicen/ctop/releases) for your pla
Maintained by a [third party](https://packages.azlux.fr/) Maintained by a [third party](https://packages.azlux.fr/)
```bash ```bash
echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list sudo apt-get install ca-certificates curl gnupg lsb-release
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add - curl -fsSL https://azlux.fr/repo.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/azlux-archive-keyring.gpg
sudo apt update echo \
sudo apt install docker-ctop "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian \
$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/azlux.list >/dev/null
sudo apt-get update
sudo apt-get install docker-ctop
``` ```
#### Arch #### Arch
`ctop` is available for Arch in the [AUR](https://aur.archlinux.org/packages/ctop-bin/) ```bash
sudo pacman -S ctop
```
_`ctop` is also available for Arch in the [AUR](https://aur.archlinux.org/packages/ctop-bin/)_
#### Linux (Generic) #### Linux (Generic)
@@ -53,6 +61,14 @@ sudo curl -Lo /usr/local/bin/ctop https://github.com/bcicen/ctop/releases/downlo
sudo chmod +x /usr/local/bin/ctop sudo chmod +x /usr/local/bin/ctop
``` ```
#### Windows
`ctop` is available in [scoop](https://scoop.sh/):
```powershell
scoop install ctop
```
#### Docker #### Docker
```bash ```bash
@@ -112,6 +128,7 @@ Option | Description
[release]: https://img.shields.io/github/release/bcicen/ctop.svg "ctop" [release]: https://img.shields.io/github/release/bcicen/ctop.svg "ctop"
[homebrew]: https://img.shields.io/homebrew/v/ctop.svg "ctop" [homebrew]: https://img.shields.io/homebrew/v/ctop.svg "ctop"
[macports]: https://repology.org/badge/version-for-repo/macports/ctop.svg?header=macports "ctop" [macports]: https://repology.org/badge/version-for-repo/macports/ctop.svg?header=macports "ctop"
[scoop]: https://img.shields.io/scoop/v/ctop?bucket=main "ctop"
## Alternatives ## Alternatives

View File

@@ -7,6 +7,7 @@ import (
"time" "time"
"github.com/op/go-logging" "github.com/op/go-logging"
"github.com/hako/durafmt"
"github.com/bcicen/ctop/connector/collector" "github.com/bcicen/ctop/connector/collector"
"github.com/bcicen/ctop/connector/manager" "github.com/bcicen/ctop/connector/manager"
@@ -187,7 +188,7 @@ func (cm *Docker) refresh(c *container.Container) {
if webPort != "" { if webPort != "" {
c.SetMeta("Web Port", webPort) c.SetMeta("Web Port", webPort)
} }
c.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006")) c.SetMeta("created", insp.Created.Format("Mon Jan 02 15:04:05 2006"))
c.SetMeta("uptime", calcUptime(insp)) c.SetMeta("uptime", calcUptime(insp))
c.SetMeta("health", insp.State.Health.Status) c.SetMeta("health", insp.State.Health.Status)
c.SetMeta("[ENV-VAR]", strings.Join(insp.Config.Env, ";")) c.SetMeta("[ENV-VAR]", strings.Join(insp.Config.Env, ";"))
@@ -209,11 +210,11 @@ func (cm *Docker) inspect(id string) (insp *api.Container, found bool, failed bo
func calcUptime(insp *api.Container) string { func calcUptime(insp *api.Container) string {
endTime := insp.State.FinishedAt endTime := insp.State.FinishedAt
if endTime.IsZero() { if endTime.IsZero() || insp.State.Running {
endTime = time.Now() endTime = time.Now()
} }
uptime := endTime.Sub(insp.State.StartedAt) uptime := endTime.Sub(insp.State.StartedAt)
return uptime.Truncate(time.Second).String() return durafmt.Parse(uptime).LimitFirstN(1).String()
} }
// Mark all container IDs for refresh // Mark all container IDs for refresh

View File

@@ -54,7 +54,7 @@ func (s *Status) setState(val string) {
case "created": case "created":
mark = "◉" mark = "◉"
case "running": case "running":
mark = "" mark = ""
color = ui.ThemeAttr("status.ok") color = ui.ThemeAttr("status.ok")
case "exited": case "exited":
mark = "⏹" mark = "⏹"

1
go.mod
View File

@@ -5,6 +5,7 @@ require (
github.com/c9s/goprocinfo v0.0.0-20170609001544-b34328d6e0cd github.com/c9s/goprocinfo v0.0.0-20170609001544-b34328d6e0cd
github.com/fsouza/go-dockerclient v1.7.0 github.com/fsouza/go-dockerclient v1.7.0
github.com/gizak/termui v2.3.1-0.20180817033724-8d4faad06196+incompatible github.com/gizak/termui v2.3.1-0.20180817033724-8d4faad06196+incompatible
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b // indirect
github.com/jgautheron/codename-generator v0.0.0-20150829203204-16d037c7cc3c github.com/jgautheron/codename-generator v0.0.0-20150829203204-16d037c7cc3c
github.com/mattn/go-runewidth v0.0.2 github.com/mattn/go-runewidth v0.0.2
github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d github.com/nsf/termbox-go v0.0.0-20190121233118-02980233997d

2
go.sum
View File

@@ -78,6 +78,8 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4=
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0=
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=