Compare commits

...

10 Commits
v0.7 ... v0.7.1

Author SHA1 Message Date
Bradley Cicenas
5261444265 v0.7.1 2018-03-09 05:19:34 +00:00
Bradley Cicenas
b3aa291182 update termbox-go dependency 2018-03-09 05:15:55 +00:00
Bradley Cicenas
051b474bf0 dep updates 2018-02-23 13:57:59 +09:30
Bradley Cicenas
fac6632459 build image from go 1.10 2018-02-22 14:58:21 +09:30
Bradley Cicenas
1c7cf98e58 handle window resize in help dialog 2018-02-02 15:21:33 +00:00
Bradley Cicenas
44a54e070d combine conditionals 2018-02-01 16:55:23 +00:00
Bradley Cicenas
10b9a6c013 include windows build 2018-01-31 17:05:54 +00:00
Bradley Cicenas
a3b67e4607 add available connectors to help dialog 2018-01-30 07:54:13 -03:00
Bradley Cicenas
ac1ce18143 refactor enabled connectors 2018-01-29 12:47:10 +00:00
bradley
01a305d326 Update README.md
escape brackets
2018-01-11 15:58:37 -03:00
17 changed files with 56 additions and 46 deletions

View File

@@ -1,4 +1,4 @@
FROM quay.io/vektorcloud/go:1.9 FROM quay.io/vektorcloud/go:1.10
RUN apk add --no-cache make RUN apk add --no-cache make

14
Gopkg.lock generated
View File

@@ -6,6 +6,12 @@
packages = [".","winterm"] packages = [".","winterm"]
revision = "fa152c58bc15761d0200cb75fe958b89a9d4888e" revision = "fa152c58bc15761d0200cb75fe958b89a9d4888e"
[[projects]]
name = "github.com/BurntSushi/toml"
packages = ["."]
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
version = "v0.3.0"
[[projects]] [[projects]]
name = "github.com/Microsoft/go-winio" name = "github.com/Microsoft/go-winio"
packages = ["."] packages = ["."]
@@ -57,10 +63,10 @@
revision = "318513eb1ab27495afbc67f671ba1080513d8aa0" revision = "318513eb1ab27495afbc67f671ba1080513d8aa0"
[[projects]] [[projects]]
branch = "barchart-numfmt" branch = "master"
name = "github.com/gizak/termui" name = "github.com/gizak/termui"
packages = ["."] packages = ["."]
revision = "ea10e6ccee219e572ffad0ac1909f1a17f6db7d6" revision = "cdc199d7ea432fd8187db35f0247285d6f5b0267"
source = "https://github.com/bcicen/termui" source = "https://github.com/bcicen/termui"
[[projects]] [[projects]]
@@ -106,7 +112,7 @@
[[projects]] [[projects]]
name = "github.com/nsf/termbox-go" name = "github.com/nsf/termbox-go"
packages = ["."] packages = ["."]
revision = "91bae1bb5fa9ee504905ecbe7043fa30e92feaa3" revision = "e2050e41c8847748ec5288741c0b19a8cb26d084"
[[projects]] [[projects]]
branch = "master" branch = "master"
@@ -154,6 +160,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "cf4dacc32111b22d72ac23189b826c8316ec265e55bf987338c7a00633af788e" inputs-digest = "f46f5c696ecb0b0c42a38dac512df21fc1f5fb2bfda888434e005e69d1b6273b"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View File

@@ -26,7 +26,7 @@
revision = "318513eb1ab27495afbc67f671ba1080513d8aa0" revision = "318513eb1ab27495afbc67f671ba1080513d8aa0"
[[constraint]] [[constraint]]
branch = "barchart-numfmt" branch = "master"
name = "github.com/gizak/termui" name = "github.com/gizak/termui"
source = "https://github.com/bcicen/termui" source = "https://github.com/bcicen/termui"

View File

@@ -20,6 +20,7 @@ build-all:
GOOS=linux GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-amd64 GOOS=linux GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-amd64
GOOS=linux GOARCH=arm go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm GOOS=linux GOARCH=arm go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm
GOOS=linux GOARCH=arm64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm64 GOOS=linux GOARCH=arm64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-linux-arm64
GOOS=windows GOARCH=amd64 go build -tags release -ldflags $(LD_FLAGS) -o _build/ctop-$(VERSION)-windows-amd64
cd _build; sha256sum * > sha256sums.txt cd _build; sha256sum * > sha256sums.txt
image: image:

View File

@@ -63,7 +63,7 @@ While running, use `S` to save the current filters, sort field, and other option
Option | Description Option | Description
--- | --- --- | ---
-a | show active containers only -a | show active containers only
-f <string> | set an initial filter string -f \<string\> | set an initial filter string
-h | display help dialog -h | display help dialog
-i | invert default colors -i | invert default colors
-r | reverse container sort order -r | reverse container sort order
@@ -75,7 +75,7 @@ Option | Description
Key | Action Key | Action
--- | --- --- | ---
<enter> | Open container menu \<enter\> | Open container menu
a | Toggle display of all (running and non-running) containers a | Toggle display of all (running and non-running) containers
f | Filter displayed containers (`esc` to clear when open) f | Filter displayed containers (`esc` to clear when open)
H | Toggle ctop header H | Toggle ctop header

View File

@@ -1 +1 @@
0.7 0.7.1

View File

@@ -1,4 +1,4 @@
// +build !darwin // +build linux
package collector package collector

View File

@@ -1,4 +1,4 @@
// +build !darwin // +build linux
package collector package collector

View File

@@ -11,6 +11,8 @@ import (
api "github.com/fsouza/go-dockerclient" api "github.com/fsouza/go-dockerclient"
) )
func init() { enabled["docker"] = NewDocker }
type Docker struct { type Docker struct {
client *api.Client client *api.Client
containers map[string]*container.Container containers map[string]*container.Container

View File

@@ -1,7 +0,0 @@
// +build !linux
package connector
var enabled = map[string]func() Connector{
"docker": NewDocker,
}

View File

@@ -1,8 +0,0 @@
// +build !darwin
package connector
var enabled = map[string]func() Connector{
"docker": NewDocker,
"runc": NewRunc,
}

View File

@@ -2,22 +2,31 @@ package connector
import ( import (
"fmt" "fmt"
"sort"
"github.com/bcicen/ctop/container" "github.com/bcicen/ctop/container"
"github.com/bcicen/ctop/logging" "github.com/bcicen/ctop/logging"
) )
var log = logging.Init() var (
log = logging.Init()
enabled = make(map[string]func() Connector)
)
// return names for all enabled connectors on the current platform
func Enabled() (a []string) {
for k, _ := range enabled {
a = append(a, k)
}
sort.Strings(a)
return a
}
func ByName(s string) (Connector, error) { func ByName(s string) (Connector, error) {
if _, ok := enabled[s]; !ok { if cfn, ok := enabled[s]; ok {
msg := fmt.Sprintf("invalid connector type \"%s\"\nconnector must be one of:", s) return cfn(), nil
for k, _ := range enabled {
msg += fmt.Sprintf("\n %s", k)
} }
return nil, fmt.Errorf(msg) return nil, fmt.Errorf("invalid connector type \"%s\"", s)
}
return enabled[s](), nil
} }
type Connector interface { type Connector interface {

View File

@@ -14,11 +14,13 @@ import (
"github.com/nu7hatch/gouuid" "github.com/nu7hatch/gouuid"
) )
func init() { enabled["mock"] = NewMock }
type Mock struct { type Mock struct {
containers container.Containers containers container.Containers
} }
func NewMock() *Mock { func NewMock() Connector {
cs := &Mock{} cs := &Mock{}
go cs.Init() go cs.Init()
go cs.Loop() go cs.Loop()

View File

@@ -1,4 +1,4 @@
// +build !darwin // +build linux
package connector package connector
@@ -17,6 +17,8 @@ import (
"github.com/opencontainers/runc/libcontainer/cgroups/systemd" "github.com/opencontainers/runc/libcontainer/cgroups/systemd"
) )
func init() { enabled["runc"] = NewRunc }
type RuncOpts struct { type RuncOpts struct {
root string // runc root path root string // runc root path
systemdCgroups bool // use systemd cgroups systemdCgroups bool // use systemd cgroups

View File

@@ -23,10 +23,7 @@ func NewCompactGrid() *CompactGrid {
func (cg *CompactGrid) Align() { func (cg *CompactGrid) Align() {
y := cg.Y y := cg.Y
if cg.Offset >= len(cg.Rows) { if cg.Offset >= len(cg.Rows) || cg.Offset < 0 {
cg.Offset = 0
}
if cg.Offset < 0 {
cg.Offset = 0 cg.Offset = 0
} }

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os" "os"
"runtime" "runtime"
"strings"
"github.com/bcicen/ctop/config" "github.com/bcicen/ctop/config"
"github.com/bcicen/ctop/connector" "github.com/bcicen/ctop/connector"
@@ -138,7 +139,7 @@ func panicExit() {
} }
} }
var helpMsg = `ctop - container metric viewer var helpMsg = `ctop - interactive container viewer
usage: ctop [options] usage: ctop [options]
@@ -148,4 +149,6 @@ options:
func printHelp() { func printHelp() {
fmt.Println(helpMsg) fmt.Println(helpMsg)
flag.PrintDefaults() flag.PrintDefaults()
fmt.Printf("\navailable connectors: ")
fmt.Println(strings.Join(connector.Enabled(), ", "))
} }

View File

@@ -37,7 +37,10 @@ func HelpMenu() MenuFn {
m := menu.NewMenu() m := menu.NewMenu()
m.BorderLabel = "Help" m.BorderLabel = "Help"
m.AddItems(helpDialog...) m.AddItems(helpDialog...)
ui.Handle("/sys/wnd/resize", func(e ui.Event) {
ui.Clear()
ui.Render(m) ui.Render(m)
})
ui.Handle("/sys/kbd/", func(ui.Event) { ui.Handle("/sys/kbd/", func(ui.Event) {
ui.StopLoop() ui.StopLoop()
}) })