├── vendor ├── golang.org │ └── x │ │ └── sys │ │ ├── unix │ │ ├── .gitignore │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── constants.go │ │ ├── syscall_no_getwd.go │ │ ├── zsysnum_solaris_amd64.go │ │ ├── env_unset.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── pagesize_unix.go │ │ ├── flock_linux_32bit.go │ │ ├── asm_solaris_amd64.s │ │ ├── gccgo_linux_amd64.go │ │ ├── race0.go │ │ ├── env_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── asm_linux_arm64.s │ │ ├── str.go │ │ ├── race.go │ │ ├── asm_linux_s390x.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_mips64x.s │ │ ├── flock.go │ │ ├── asm_freebsd_arm.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_darwin_386.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── syscall_solaris_amd64.go │ │ ├── asm_darwin_arm.s │ │ ├── bluetooth_linux.go │ │ ├── asm_darwin_arm64.s │ │ ├── asm_linux_mipsx.s │ │ ├── dev_darwin.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_arm.go │ │ ├── mksysnum_darwin.pl │ │ ├── asm_linux_386.s │ │ ├── dev_netbsd.go │ │ ├── dev_openbsd.go │ │ ├── openbsd_pledge.go │ │ ├── dev_freebsd.go │ │ ├── dev_dragonfly.go │ │ ├── gccgo_c.c │ │ ├── sockcmsg_linux.go │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── zptracearm_linux.go │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_386.go │ │ ├── mksysnum_netbsd.pl │ │ ├── zptracemips_linux.go │ │ ├── zptracemipsle_linux.go │ │ ├── gccgo.go │ │ ├── dev_linux.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_386.go │ │ ├── timestruct.go │ │ ├── syscall.go │ │ └── zptrace386_linux.go │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── PATENTS │ │ └── LICENSE ├── github.com │ ├── spf13 │ │ ├── pflag │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ └── LICENSE │ │ └── cobra │ │ │ ├── command_notwin.go │ │ │ ├── .mailmap │ │ │ ├── command_win.go │ │ │ ├── .travis.yml │ │ │ └── .gitignore │ ├── kr │ │ └── pty │ │ │ ├── .gitignore │ │ │ ├── types.go │ │ │ ├── ztypes_386.go │ │ │ ├── ztypes_arm.go │ │ │ ├── ztypes_amd64.go │ │ │ ├── ztypes_arm64.go │ │ │ ├── ztypes_ppc64.go │ │ │ ├── ztypes_s390x.go │ │ │ ├── ztypes_ppc64le.go │ │ │ ├── pty_unsupported.go │ │ │ ├── ztypes_mipsx.go │ │ │ ├── types_openbsd.go │ │ │ ├── ztypes_freebsd_386.go │ │ │ ├── ztypes_freebsd_arm.go │ │ │ ├── ioctl.go │ │ │ ├── ztypes_openbsd_amd64.go │ │ │ ├── ztypes_freebsd_amd64.go │ │ │ ├── types_freebsd.go │ │ │ ├── ztypes_dragonfly_amd64.go │ │ │ ├── types_dragonfly.go │ │ │ ├── doc.go │ │ │ ├── mktypes.bash │ │ │ ├── run.go │ │ │ ├── pty_openbsd.go │ │ │ ├── License │ │ │ ├── pty_linux.go │ │ │ ├── ioctl_bsd.go │ │ │ ├── pty_darwin.go │ │ │ ├── util.go │ │ │ ├── pty_freebsd.go │ │ │ └── pty_dragonfly.go │ ├── fatih │ │ └── color │ │ │ ├── .travis.yml │ │ │ └── LICENSE.md │ ├── mattn │ │ ├── go-isatty │ │ │ ├── doc.go │ │ │ ├── .travis.yml │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux_ppc64x.go │ │ │ ├── LICENSE │ │ │ └── README.md │ │ ├── go-runewidth │ │ │ ├── runewidth_js.go │ │ │ ├── .travis.yml │ │ │ ├── runewidth_windows.go │ │ │ ├── README.mkd │ │ │ ├── LICENSE │ │ │ └── runewidth_posix.go │ │ └── go-colorable │ │ │ ├── .travis.yml │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ ├── LICENSE │ │ │ ├── noncolorable.go │ │ │ └── README.md │ ├── gyuho │ │ └── dataframe │ │ │ ├── .travis.yml │ │ │ ├── doc.go │ │ │ ├── util.go │ │ │ ├── README.md │ │ │ ├── test │ │ │ ├── value.go │ │ │ ├── value_data_type.go │ │ │ └── value_time.go │ ├── coreos │ │ ├── etcd │ │ │ ├── NOTICE │ │ │ └── pkg │ │ │ │ ├── cpuutil │ │ │ │ ├── doc.go │ │ │ │ └── endian.go │ │ │ │ ├── types │ │ │ │ ├── doc.go │ │ │ │ ├── slice.go │ │ │ │ └── id.go │ │ │ │ └── netutil │ │ │ │ ├── isolate_stub.go │ │ │ │ └── routes.go │ │ └── pkg │ │ │ ├── NOTICE │ │ │ └── capnslog │ │ │ ├── init_windows.go │ │ │ ├── log_hijack.go │ │ │ ├── init.go │ │ │ ├── syslog_formatter.go │ │ │ └── journald_formatter.go │ ├── olekukonko │ │ └── tablewriter │ │ │ ├── .travis.yml │ │ │ ├── LICENCE.md │ │ │ └── csv.go │ ├── dustin │ │ └── go-humanize │ │ │ ├── humanize.go │ │ │ ├── ordinals.go │ │ │ ├── .travis.yml │ │ │ ├── big.go │ │ │ ├── commaf.go │ │ │ ├── ftoa.go │ │ │ └── LICENSE │ └── inconshreveable │ │ └── mousetrap │ │ ├── trap_others.go │ │ ├── LICENSE │ │ ├── README.md │ │ └── trap_windows_1.4.go └── gopkg.in │ └── yaml.v2 │ ├── .travis.yml │ └── LICENSE.libyaml ├── Gopkg.toml ├── etc ├── doc.go ├── mtab_test.go ├── generated.go ├── schema.go └── mtab.go ├── top ├── doc.go ├── top_test.go ├── parse_test.go ├── stream_test.go ├── schema.go └── generated.go ├── inspect ├── doc.go ├── ds_test.go ├── ns_test.go ├── ss_test.go └── ps_test.go ├── proc ├── doc.go ├── list_test.go ├── uptime_test.go ├── net_dev_test.go ├── stat_test.go ├── load_avg_test.go ├── utils.go ├── parse_ip_test.go ├── io_test.go ├── status_test.go ├── list.go ├── uptime.go └── io.go ├── .travis.yml ├── df ├── doc.go ├── df_test.go ├── generated.go └── schema.go ├── scripts ├── update-dep.sh └── update-schema.sh ├── .gitignore ├── tests.sh ├── cmd ├── linux-inspect │ ├── ns.go │ ├── ds.go │ ├── main.go │ ├── ps.go │ └── ss.go ├── generate-df │ └── main.go ├── generate-etc │ └── main.go └── generate-top │ └── main.go ├── pkg ├── timeutil │ └── timeutil.go └── fileutil │ └── fileutil.go ├── README.md └── Dockerfile /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | 3 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | [prune] 2 | go-tests = true 3 | unused-packages = true 4 | -------------------------------------------------------------------------------- /etc/doc.go: -------------------------------------------------------------------------------- 1 | // Package etc represents Linux '/etc'. 2 | package etc 3 | -------------------------------------------------------------------------------- /top/doc.go: -------------------------------------------------------------------------------- 1 | // Package top wraps Linux 'top' command. 2 | package top 3 | -------------------------------------------------------------------------------- /inspect/doc.go: -------------------------------------------------------------------------------- 1 | // Package inspect inspects '/proc/*'. 2 | package inspect 3 | -------------------------------------------------------------------------------- /proc/doc.go: -------------------------------------------------------------------------------- 1 | // Package proc represents Linux '/proc'. 2 | package proc 3 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/.gitignore: -------------------------------------------------------------------------------- 1 | [568].out 2 | _go* 3 | _test* 4 | _obj 5 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.8.x 4 | - tip 5 | 6 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | go: 6 | - 1.11 7 | 8 | script: 9 | - ./tests.sh 10 | -------------------------------------------------------------------------------- /df/doc.go: -------------------------------------------------------------------------------- 1 | // Package df wraps Unix 'df' command. 2 | // Reference https://en.wikipedia.org/wiki/Df_(Unix). 3 | package df 4 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_notwin.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package cobra 4 | 5 | var preExecHookFn func(*Command) 6 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | go: 6 | - tip 7 | 8 | script: 9 | - ./test 10 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/doc.go: -------------------------------------------------------------------------------- 1 | // Package dataframe implements data frame. 2 | package dataframe // import "github.com/gyuho/dataframe" 3 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | import "C" 6 | 7 | type ( 8 | _C_int C.int 9 | _C_uint C.uint 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | - 1.5 6 | - 1.6 7 | - tip 8 | 9 | go_import_path: gopkg.in/yaml.v2 10 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - 1.5 9 | - 1.6 10 | - 1.7 11 | - 1.8 12 | - tip 13 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | package pty 5 | 6 | type ( 7 | _C_int int32 8 | _C_uint uint32 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.mailmap: -------------------------------------------------------------------------------- 1 | Steve Francia 2 | Bjørn Erik Pedersen 3 | Fabiano Franz 4 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_arm64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build arm64 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | // Created by cgo -godefs - DO NOT EDIT 4 | // cgo -godefs types.go 5 | 6 | package pty 7 | 8 | type ( 9 | _C_int int32 10 | _C_uint uint32 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package runewidth 4 | 5 | func IsEastAsian() bool { 6 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /proc/list_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestListPIDs(t *testing.T) { 9 | pids, err := ListPIDs() 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | fmt.Println("ListPIDs:", pids) 14 | } 15 | -------------------------------------------------------------------------------- /proc/uptime_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetUptime(t *testing.T) { 9 | u, err := GetUptime() 10 | if err != nil { 11 | t.Error(err) 12 | } 13 | fmt.Printf("GetUptime: %+v\n", u) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!darwin,!freebsd,!dragonfly,!openbsd 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func open() (pty, tty *os.File, err error) { 10 | return nil, nil, ErrUnsupported 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_mipsx.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types.go 3 | 4 | // +build linux 5 | // +build mips mipsle mips64 mips64le 6 | 7 | package pty 8 | 9 | type ( 10 | _C_int int32 11 | _C_uint uint32 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_openbsd.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #include 7 | #include 8 | #include 9 | */ 10 | import "C" 11 | 12 | type ptmget C.struct_ptmget 13 | 14 | var ioctl_PTMGET = C.PTMGET 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Buf *byte 13 | } 14 | -------------------------------------------------------------------------------- /etc/mtab_test.go: -------------------------------------------------------------------------------- 1 | package etc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetMtab(t *testing.T) { 9 | mss, err := GetMtab() 10 | if err != nil { 11 | t.Error(err) 12 | } 13 | for _, ms := range mss { 14 | fmt.Printf("%+v\n", ms) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/update-dep.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if ! [[ "$0" =~ "scripts/update-dep.sh" ]]; then 6 | echo "must be run from repository root" 7 | exit 255 8 | fi 9 | 10 | go get -v -u github.com/golang/dep/cmd/dep 11 | dep ensure -v 12 | dep prune 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | before_install: 5 | - go get github.com/mattn/goveralls 6 | - go get golang.org/x/tools/cmd/cover 7 | script: 8 | - $HOME/gopath/bin/goveralls -repotoken lAKAWPzcGsD3A8yBX3BGGtRUdJ6CaGERL 9 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import "syscall" 6 | 7 | func ioctl(fd, cmd, ptr uintptr) error { 8 | _, _, e := syscall.Syscall(syscall.SYS_IOCTL, fd, cmd, ptr) 9 | if e != 0 { 10 | return e 11 | } 12 | return nil 13 | } 14 | -------------------------------------------------------------------------------- /proc/net_dev_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetNetDev(t *testing.T) { 9 | nds, err := GetNetDev() 10 | if err != nil { 11 | t.Skip(err) 12 | } 13 | for _, nd := range nds { 14 | fmt.Printf("%+v\n", nd) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 10 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_openbsd.go 3 | 4 | package pty 5 | 6 | type ptmget struct { 7 | Cfd int32 8 | Sfd int32 9 | Cn [16]int8 10 | Sn [16]int8 11 | } 12 | 13 | var ioctl_PTMGET = 0x40287401 14 | -------------------------------------------------------------------------------- /inspect/ds_test.go: -------------------------------------------------------------------------------- 1 | package inspect 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetDS(t *testing.T) { 9 | ds, err := GetDS() 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | hd, rows := ConvertDS(ds...) 14 | txt := StringDS(hd, rows, -1) 15 | fmt.Println(txt) 16 | } 17 | -------------------------------------------------------------------------------- /inspect/ns_test.go: -------------------------------------------------------------------------------- 1 | package inspect 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetNS(t *testing.T) { 9 | ns, err := GetNS() 10 | if err != nil { 11 | t.Skip(err) 12 | } 13 | hd, rows := ConvertNS(ns...) 14 | txt := StringNS(hd, rows, -1) 15 | fmt.Println(txt) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_freebsd.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Len int32 12 | Pad_cgo_0 [4]byte 13 | Buf *byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_freebsd.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #include 7 | #include 8 | */ 9 | import "C" 10 | 11 | const ( 12 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 13 | ) 14 | 15 | type fiodgnameArg C.struct_fiodgname_arg 16 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ztypes_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Created by cgo -godefs - DO NOT EDIT 2 | // cgo -godefs types_dragonfly.go 3 | 4 | package pty 5 | 6 | const ( 7 | _C_SPECNAMELEN = 0x3f 8 | ) 9 | 10 | type fiodgnameArg struct { 11 | Name *byte 12 | Len uint32 13 | Pad_cgo_0 [4]byte 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/humanize.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package humanize converts boring ugly numbers to human-friendly strings and back. 3 | 4 | Durations can be turned into strings such as "3 days ago", numbers 5 | representing sizes like 82854982 into useful strings like, "83 MB" or 6 | "79 MiB" (whichever you prefer). 7 | */ 8 | package humanize 9 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /scripts/update-schema.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if ! [[ "$0" =~ "scripts/update-schema.sh" ]]; then 6 | echo "must be run from repository root" 7 | exit 255 8 | fi 9 | 10 | go run ./cmd/generate-df/main.go 11 | go run ./cmd/generate-etc/main.go 12 | go run ./cmd/generate-proc/main.go 13 | go run ./cmd/generate-top/main.go 14 | -------------------------------------------------------------------------------- /proc/stat_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetStatByPID(t *testing.T) { 9 | s, err := GetStatByPID(1) 10 | if err != nil { 11 | t.Skip(err) 12 | } 13 | if s.Rss != s.RssBytesN { 14 | t.Fatalf("got different Rss; %d != %d", s.Rss, s.RssBytesN) 15 | } 16 | fmt.Printf("GetStatByPID: %+v\n", s) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/types_dragonfly.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package pty 4 | 5 | /* 6 | #define _KERNEL 7 | #include 8 | #include 9 | #include 10 | */ 11 | import "C" 12 | 13 | const ( 14 | _C_SPECNAMELEN = C.SPECNAMELEN /* max length of devicename */ 15 | ) 16 | 17 | type fiodgnameArg C.struct_fiodname_args 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | .Dockerfile 3 | /*.log 4 | 5 | # Ignore everything in vendor/, except for *.go files, 6 | # LICENSE and COPYING. Ignore Go tests. 7 | # https://github.com/golang/dep/issues/120#issuecomment-306518546 8 | vendor/**/* 9 | !vendor/**/ 10 | !vendor/**/*.go 11 | !vendor/**/*.s 12 | !vendor/**/LICENSE* 13 | !vendor/**/COPYING* 14 | vendor/**/*_test.go 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/pflag/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: go 4 | 5 | go: 6 | - 1.7.3 7 | - 1.8.1 8 | - tip 9 | 10 | matrix: 11 | allow_failures: 12 | - go: tip 13 | 14 | install: 15 | - go get github.com/golang/lint/golint 16 | - export PATH=$GOPATH/bin:$PATH 17 | - go install ./... 18 | 19 | script: 20 | - verify/all.sh -v 21 | - go test ./... 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /top/top_test.go: -------------------------------------------------------------------------------- 1 | package top 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | func TestGet(t *testing.T) { 10 | now := time.Now() 11 | rows, err := Get(DefaultExecPath, 0) 12 | if err != nil { 13 | t.Skip(err) 14 | } 15 | for _, elem := range rows { 16 | fmt.Printf("%+v\n", elem) 17 | } 18 | fmt.Printf("found %d entrines in %v", len(rows), time.Since(now)) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /top/parse_test.go: -------------------------------------------------------------------------------- 1 | package top 2 | 3 | import "testing" 4 | 5 | func TestTop_parseMemoryTxt(t *testing.T) { 6 | bts, bs, err := parseMemoryTxt("50.883g") 7 | if err != nil { 8 | t.Fatal(err) 9 | } 10 | if bts != 53687091200 { 11 | t.Fatalf("bytes expected %d, got %d", 53687091200, bts) 12 | } 13 | if bs != "54 GB" { 14 | t.Fatalf("humanized bytes expected '54 GB', got %q", bs) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/command_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package cobra 4 | 5 | import ( 6 | "os" 7 | "time" 8 | 9 | "github.com/inconshreveable/mousetrap" 10 | ) 11 | 12 | var preExecHookFn = preExecHook 13 | 14 | func preExecHook(c *Command) { 15 | if MousetrapHelpText != "" && mousetrap.StartedByExplorer() { 16 | c.Print(MousetrapHelpText) 17 | time.Sleep(5 * time.Second) 18 | os.Exit(1) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/doc.go: -------------------------------------------------------------------------------- 1 | // Package pty provides functions for working with Unix terminals. 2 | package pty 3 | 4 | import ( 5 | "errors" 6 | "os" 7 | ) 8 | 9 | // ErrUnsupported is returned if a function is not 10 | // available on the current platform. 11 | var ErrUnsupported = errors.New("unsupported") 12 | 13 | // Opens a pty and its corresponding tty. 14 | func Open() (pty, tty *os.File, err error) { 15 | return open() 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/mktypes.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | GOOSARCH="${GOOS}_${GOARCH}" 4 | case "$GOOSARCH" in 5 | _* | *_ | _) 6 | echo 'undefined $GOOS_$GOARCH:' "$GOOSARCH" 1>&2 7 | exit 1 8 | ;; 9 | esac 10 | 11 | GODEFS="go tool cgo -godefs" 12 | 13 | $GODEFS types.go |gofmt > ztypes_$GOARCH.go 14 | 15 | case $GOOS in 16 | freebsd|dragonfly|openbsd) 17 | $GODEFS types_$GOOS.go |gofmt > ztypes_$GOOSARCH.go 18 | ;; 19 | esac 20 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/util.go: -------------------------------------------------------------------------------- 1 | package dataframe 2 | 3 | import "os" 4 | 5 | func openToRead(fpath string) (*os.File, error) { 6 | f, err := os.OpenFile(fpath, os.O_RDONLY, 0444) 7 | if err != nil { 8 | return nil, err 9 | } 10 | return f, nil 11 | } 12 | 13 | func openToOverwrite(fpath string) (*os.File, error) { 14 | f, err := os.OpenFile(fpath, os.O_RDWR|os.O_TRUNC|os.O_CREATE, 0777) 15 | if err != nil { 16 | return nil, err 17 | } 18 | return f, nil 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/README.md: -------------------------------------------------------------------------------- 1 | ## dataframe [![Go Report Card](https://goreportcard.com/badge/github.com/gyuho/dataframe?style=flat-square)](https://goreportcard.com/report/github.com/gyuho/dataframe) [![Build Status](https://img.shields.io/travis/gyuho/dataframe.svg?style=flat-square)](https://travis-ci.org/gyuho/dataframe) [![Godoc](https://img.shields.io/badge/godoc-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/gyuho/dataframe) 2 | 3 | Package dataframe implements data frame. 4 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ordinals.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import "strconv" 4 | 5 | // Ordinal gives you the input number in a rank/ordinal format. 6 | // 7 | // Ordinal(3) -> 3rd 8 | func Ordinal(x int) string { 9 | suffix := "th" 10 | switch x % 10 { 11 | case 1: 12 | if x%100 != 11 { 13 | suffix = "st" 14 | } 15 | case 2: 16 | if x%100 != 12 { 17 | suffix = "nd" 18 | } 19 | case 3: 20 | if x%100 != 13 { 21 | suffix = "rd" 22 | } 23 | } 24 | return strconv.Itoa(x) + suffix 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine,!ppc64,!ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /df/df_test.go: -------------------------------------------------------------------------------- 1 | package df 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetDefault(t *testing.T) { 9 | dfs, err := GetDefault("") 10 | if err != nil { 11 | t.Skip(err) 12 | } 13 | for _, df := range dfs { 14 | fmt.Printf("%+v\n", df) 15 | } 16 | 17 | dfs, err = GetDefault(".") 18 | if err != nil { 19 | t.Skip(err) 20 | } 21 | for _, df := range dfs { 22 | fmt.Printf("%+v\n", df) 23 | } 24 | } 25 | 26 | func TestGetDevice(t *testing.T) { 27 | s, err := GetDevice("/boot") 28 | fmt.Println(s, err) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build ppc64 ppc64le 3 | 4 | package isatty 5 | 6 | import ( 7 | "unsafe" 8 | 9 | syscall "golang.org/x/sys/unix" 10 | ) 11 | 12 | const ioctlReadTermios = syscall.TCGETS 13 | 14 | // IsTerminal return true if the file descriptor is terminal. 15 | func IsTerminal(fd uintptr) bool { 16 | var termios syscall.Termios 17 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 18 | return err == 0 19 | } 20 | -------------------------------------------------------------------------------- /inspect/ss_test.go: -------------------------------------------------------------------------------- 1 | package inspect 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetSS(t *testing.T) { 9 | ss, err := GetSS(WithTCP(), WithTopLimit(2)) 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | hd, rows := ConvertSS(ss...) 14 | txt := StringSS(hd, rows, -1) 15 | fmt.Println(txt) 16 | } 17 | 18 | func TestGetSSWithFilter(t *testing.T) { 19 | ss, err := GetSS(WithPID(1)) 20 | if err != nil { 21 | t.Fatal(err) 22 | } 23 | hd, rows := ConvertSS(ss...) 24 | txt := StringSS(hd, rows, -1) 25 | fmt.Println(txt) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.3.x 5 | - 1.5.x 6 | - 1.6.x 7 | - 1.7.x 8 | - 1.8.x 9 | - 1.9.x 10 | - master 11 | matrix: 12 | allow_failures: 13 | - go: master 14 | fast_finish: true 15 | install: 16 | - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). 17 | script: 18 | - go get -t -v ./... 19 | - diff -u <(echo -n) <(gofmt -d -s .) 20 | - go tool vet . 21 | - go test -v -race ./... 22 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | TEST=./...; 4 | FMT="*.go" 5 | 6 | echo "Checking gofmt..." 7 | fmtRes=$(gofmt -l -s -d $FMT) 8 | if [ -n "${fmtRes}" ]; then 9 | echo -e "gofmt checking failed:\n${fmtRes}" 10 | exit 255 11 | fi 12 | echo "Checking govet..." 13 | vetRes=$(go vet $TEST) 14 | if [ -n "${vetRes}" ]; then 15 | echo -e "govet checking failed:\n${vetRes}" 16 | exit 255 17 | fi 18 | 19 | echo "Running tests..."; 20 | go test -v -cover -cpu 1,2,4 $TEST; 21 | go test -v -cover -cpu 1,2,4 -race $TEST; 22 | 23 | echo "Success"; 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_windows.go: -------------------------------------------------------------------------------- 1 | package runewidth 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | var ( 8 | kernel32 = syscall.NewLazyDLL("kernel32") 9 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") 10 | ) 11 | 12 | // IsEastAsian return true if the current locale is CJK 13 | func IsEastAsian() bool { 14 | r1, _, _ := procGetConsoleOutputCP.Call() 15 | if r1 == 0 { 16 | return false 17 | } 18 | 19 | switch int(r1) { 20 | case 932, 51932, 936, 949, 950: 21 | return true 22 | } 23 | 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/trap_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package mousetrap 4 | 5 | // StartedByExplorer returns true if the program was invoked by the user 6 | // double-clicking on the executable from explorer.exe 7 | // 8 | // It is conservative and returns false if any of the internal calls fail. 9 | // It does not guarantee that the program was run from a terminal. It only can tell you 10 | // whether it was launched from explorer.exe 11 | // 12 | // On non-Windows platforms, it always returns false. 13 | func StartedByExplorer() bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/inconshreveable/mousetrap/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Alan Shreve 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | matrix: 4 | include: 5 | - go: 1.7.6 6 | - go: 1.8.3 7 | - go: tip 8 | allow_failures: 9 | - go: tip 10 | 11 | before_install: 12 | - mkdir -p bin 13 | - curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.3/shellcheck 14 | - chmod +x bin/shellcheck 15 | script: 16 | - PATH=$PATH:$PWD/bin go test -v ./... 17 | - go build 18 | - diff -u <(echo -n) <(gofmt -d -s .) 19 | - if [ -z $NOVET ]; then 20 | diff -u <(echo -n) <(go tool vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint'); 21 | fi 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /proc/load_avg_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | func TestGetLoadAvg(t *testing.T) { 10 | txt, err := readLoadAvg() 11 | if err != nil { 12 | t.Fatal(err) 13 | } 14 | lv, err := getLoadAvg(txt) 15 | if err != nil { 16 | t.Error(err) 17 | } 18 | fmt.Printf("%+v with %q\n", lv, txt) 19 | 20 | if !strings.Contains(txt, fmt.Sprint(lv.LoadAvg15Minute)) { 21 | t.Fatalf("'/proc/loadavg' expected LoadAvg15Minute %f, got %q", lv.LoadAvg15Minute, txt) 22 | } 23 | if !strings.Contains(txt, fmt.Sprint(lv.Pid)) { 24 | t.Fatalf("'/proc/loadavg' expected pid %d, got %q", lv.Pid, txt) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/spf13/cobra/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | # Vim files https://github.com/github/gitignore/blob/master/Global/Vim.gitignore 23 | # swap 24 | [._]*.s[a-w][a-z] 25 | [._]s[a-w][a-z] 26 | # session 27 | Session.vim 28 | # temporary 29 | .netrwhist 30 | *~ 31 | # auto-generated tag files 32 | tags 33 | 34 | *.exe 35 | 36 | cobra.test 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /proc/utils.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | func convertStatus(s string) string { 10 | ns := strings.TrimSpace(s) 11 | if len(s) > 1 { 12 | ns = ns[:1] 13 | } 14 | switch ns { 15 | case "D": 16 | return "D (uninterruptible sleep)" 17 | case "R": 18 | return "R (running)" 19 | case "S": 20 | return "S (sleeping)" 21 | case "T": 22 | return "T (stopped by job control signal)" 23 | case "t": 24 | return "t (stopped by debugger during trace)" 25 | case "Z": 26 | return "Z (zombie)" 27 | default: 28 | return fmt.Sprintf("unknown process %q", s) 29 | } 30 | } 31 | 32 | func isInt(s string) bool { 33 | _, err := strconv.Atoi(s) 34 | return err == nil 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /proc/parse_ip_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import "testing" 4 | 5 | func TestParseIP(t *testing.T) { 6 | ipv6, port, err := parseLittleEndianIpv6("4506012640B600C10C1136C5C1EB0C75:B0BA") 7 | if err != nil { 8 | t.Fatal(err) 9 | } 10 | if ipv6 != "750C:EBC1:C536:110C:C100:B640:2601:0645" { 11 | t.Fatalf("ipv6 expected '750C:EBC1:C536:110C:C100:B640:2601:0645', got %s", ipv6) 12 | } 13 | if port != 45242 { 14 | t.Fatalf("port expected '45242', got %d", port) 15 | } 16 | 17 | ipv4, port, err := parseLittleEndianIpv4("0101007F:0035") 18 | if err != nil { 19 | t.Fatal(err) 20 | } 21 | if ipv4 != "127.0.1.1" { 22 | t.Fatalf("ipv4 expected '127.0.1.1', got %s", ipv4) 23 | } 24 | if port != 53 { 25 | t.Fatalf("port expected '53', got %d", port) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if ! [[ "$0" =~ "./tests.sh" ]]; then 5 | echo "must be run from repository root" 6 | exit 255 7 | fi 8 | 9 | IGNORE_PKGS="(vendor)" 10 | TESTS=`find . -name \*_test.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS"` 11 | 12 | echo "Checking gofmt..." $TESTS 13 | fmtRes=$(gofmt -l -s -d $TESTS) 14 | if [[ "${fmtRes}" ]]; then 15 | echo -e "gofmt checking failed:\n${fmtRes}" 16 | exit 255 17 | fi 18 | 19 | echo "Checking govet..." $TESTS 20 | vetRes=$(go vet $TESTS) 21 | if [[ "${vetRes}" ]]; then 22 | echo -e "govet checking failed:\n${vetRes}" 23 | exit 255 24 | fi 25 | 26 | echo "Running tests..." $TESTS 27 | go test -v $TESTS; 28 | go test -v -race $TESTS; 29 | 30 | echo "Success"; 31 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/big.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "math/big" 5 | ) 6 | 7 | // order of magnitude (to a max order) 8 | func oomm(n, b *big.Int, maxmag int) (float64, int) { 9 | mag := 0 10 | m := &big.Int{} 11 | for n.Cmp(b) >= 0 { 12 | n.DivMod(n, b, m) 13 | mag++ 14 | if mag == maxmag && maxmag >= 0 { 15 | break 16 | } 17 | } 18 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 19 | } 20 | 21 | // total order of magnitude 22 | // (same as above, but with no upper limit) 23 | func oom(n, b *big.Int) (float64, int) { 24 | mag := 0 25 | m := &big.Int{} 26 | for n.Cmp(b) >= 0 { 27 | n.DivMod(n, b, m) 28 | mag++ 29 | } 30 | return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag 31 | } 32 | -------------------------------------------------------------------------------- /proc/io_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetIOByPID(t *testing.T) { 9 | fds, err := ListFds() 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | 14 | fd := fds[len(fds)/2] 15 | fmt.Println("Chosen FD:", fd) 16 | 17 | pid, err := pidFromFd(fd) 18 | if err != nil { 19 | t.Fatal(err) 20 | } 21 | fmt.Println("Chosen PID:", pid) 22 | 23 | nm, err := GetProgram(pid) 24 | if err != nil { 25 | t.Skip(err) 26 | } 27 | fmt.Println("GetProgram:", nm) 28 | 29 | ns, err := GetIOByPID(pid) 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | fmt.Printf("GetIOByPID: %+v\n", ns) 34 | 35 | if ns.WriteBytes != ns.WriteBytesBytesN { 36 | t.Fatalf("expected same, got %d, %d", ns.WriteBytes, ns.WriteBytesBytesN) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /top/stream_test.go: -------------------------------------------------------------------------------- 1 | package top 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestTopStartTopStream(t *testing.T) { 11 | pid := int64(os.Getpid()) 12 | 13 | cfg := &Config{ 14 | Exec: DefaultExecPath, 15 | IntervalSecond: 1, 16 | PID: pid, 17 | } 18 | str, err := cfg.StartStream() 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | time.Sleep(2 * time.Second) 24 | 25 | if err = str.Stop(); err != nil { 26 | t.Fatal(err) 27 | } 28 | select { 29 | case err = <-str.ErrChan(): 30 | t.Fatal(err) 31 | default: 32 | fmt.Println("'top' stopped") 33 | } 34 | 35 | rm := str.Latest() 36 | for _, row := range rm { 37 | fmt.Printf("%+v\n", row) 38 | } 39 | fmt.Println("total", len(rm), "processes") 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/cpuutil/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package cpuutil provides facilities for detecting cpu-specific features. 16 | package cpuutil 17 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/types/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package types declares various data types and implements type-checking 16 | // functions. 17 | package types 18 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/run.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "os/exec" 8 | "syscall" 9 | ) 10 | 11 | // Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout, 12 | // and c.Stderr, calls c.Start, and returns the File of the tty's 13 | // corresponding pty. 14 | func Start(c *exec.Cmd) (pty *os.File, err error) { 15 | pty, tty, err := Open() 16 | if err != nil { 17 | return nil, err 18 | } 19 | defer tty.Close() 20 | c.Stdout = tty 21 | c.Stdin = tty 22 | c.Stderr = tty 23 | if c.SysProcAttr == nil { 24 | c.SysProcAttr = &syscall.SysProcAttr{} 25 | } 26 | c.SysProcAttr.Setctty = true 27 | c.SysProcAttr.Setsid = true 28 | err = c.Start() 29 | if err != nil { 30 | pty.Close() 31 | return nil, err 32 | } 33 | return pty, err 34 | } 35 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /proc/status_test.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func TestGetStatusByPID(t *testing.T) { 9 | rs, err := GetStatusByPID(1) 10 | if err != nil { 11 | t.Skip(err) 12 | } 13 | fmt.Println(rs.VmRSS) 14 | fmt.Println(rs.VmRSSBytesN) 15 | fmt.Println(rs.VmRSSParsedBytes) 16 | fmt.Printf("GetStatusByPID: %+v\n", rs) 17 | } 18 | 19 | func TestGetProgram(t *testing.T) { 20 | fds, err := ListFds() 21 | if err != nil { 22 | t.Skip(err) 23 | } 24 | 25 | fd := fds[len(fds)/2] 26 | fmt.Println("Chosen FD:", fd) 27 | 28 | pid, err := pidFromFd(fd) 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | fmt.Println("Chosen PID:", pid) 33 | 34 | nm, err := GetProgram(pid) 35 | if err != nil { 36 | t.Skip(err) 37 | } 38 | fmt.Println("GetProgram:", nm) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /cmd/linux-inspect/ns.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/gyuho/linux-inspect/inspect" 8 | 9 | "github.com/fatih/color" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | var ( 14 | nsCommand = &cobra.Command{ 15 | Use: "ns", 16 | Short: "Inspects '/proc/net/dev'", 17 | RunE: nsCommandFunc, 18 | } 19 | ) 20 | 21 | func nsCommandFunc(cmd *cobra.Command, args []string) error { 22 | color.Set(color.FgMagenta) 23 | fmt.Fprintf(os.Stdout, "\n'ns' to inspect '/proc/net/dev'\n\n") 24 | color.Unset() 25 | 26 | ns, err := inspect.GetNS() 27 | if err != nil { 28 | return err 29 | } 30 | hd, rows := inspect.ConvertNS(ns...) 31 | txt := inspect.StringNS(hd, rows, -1) 32 | fmt.Print(txt) 33 | 34 | color.Set(color.FgGreen) 35 | fmt.Fprintf(os.Stdout, "\nDONE!\n") 36 | color.Unset() 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /cmd/linux-inspect/ds.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/gyuho/linux-inspect/inspect" 8 | 9 | "github.com/fatih/color" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | var ( 14 | dsCommand = &cobra.Command{ 15 | Use: "ds", 16 | Short: "Inspects '/proc/diskstats'", 17 | RunE: dsCommandFunc, 18 | } 19 | ) 20 | 21 | func dsCommandFunc(cmd *cobra.Command, args []string) error { 22 | color.Set(color.FgMagenta) 23 | fmt.Fprintf(os.Stdout, "\n'ds' to inspect '/proc/diskstats'\n\n") 24 | color.Unset() 25 | 26 | ds, err := inspect.GetDS() 27 | if err != nil { 28 | return err 29 | } 30 | hd, rows := inspect.ConvertDS(ds...) 31 | txt := inspect.StringDS(hd, rows, -1) 32 | fmt.Print(txt) 33 | 34 | color.Set(color.FgGreen) 35 | fmt.Fprintf(os.Stdout, "\nDONE!\n") 36 | color.Unset() 37 | 38 | return nil 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Darwin's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of a Darwin device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev >> 24) & 0xff) 13 | } 14 | 15 | // Minor returns the minor component of a Darwin device number. 16 | func Minor(dev uint64) uint32 { 17 | return uint32(dev & 0xffffff) 18 | } 19 | 20 | // Mkdev returns a Darwin device number generated from the given major and minor 21 | // components. 22 | func Mkdev(major, minor uint32) uint64 { 23 | return (uint64(major) << 24) | uint64(minor) 24 | } 25 | -------------------------------------------------------------------------------- /pkg/timeutil/timeutil.go: -------------------------------------------------------------------------------- 1 | // Package timeutil implements time utilities. 2 | package timeutil 3 | 4 | import ( 5 | "strings" 6 | "time" 7 | 8 | humanize "github.com/dustin/go-humanize" 9 | ) 10 | 11 | func NowPST() time.Time { 12 | tzone, err := time.LoadLocation("America/Los_Angeles") 13 | if err != nil { 14 | return time.Now() 15 | } 16 | return time.Now().In(tzone) 17 | } 18 | 19 | func HumanizeDurationMs(ms uint64) string { 20 | s := humanize.Time(time.Now().Add(-1 * time.Duration(ms) * time.Millisecond)) 21 | if s == "now" { 22 | s = "0 seconds" 23 | } 24 | return strings.TrimSpace(strings.Replace(s, " ago", "", -1)) 25 | } 26 | 27 | func HumanizeDurationSecond(sec uint64) string { 28 | s := humanize.Time(time.Now().Add(-1 * time.Duration(sec) * time.Second)) 29 | if s == "now" { 30 | s = "0 seconds" 31 | } 32 | return strings.TrimSpace(strings.Replace(s, " ago", "", -1)) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/init_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package capnslog 16 | 17 | import "os" 18 | 19 | func init() { 20 | initHijack() 21 | 22 | // Go `log` package uses os.Stderr. 23 | SetFormatter(NewPrettyFormatter(os.Stderr, false)) 24 | SetGlobalLogLevel(INFO) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint64(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint64(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = uint32(mode) 20 | k.Flags = uint32(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,openbsd 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: int32(nsec)} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: int32(usec)} 15 | } 16 | 17 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 18 | k.Ident = uint32(fd) 19 | k.Filter = int16(mode) 20 | k.Flags = uint16(flags) 21 | } 22 | 23 | func (iov *Iovec) SetLen(length int) { 24 | iov.Len = uint32(length) 25 | } 26 | 27 | func (msghdr *Msghdr) SetControllen(length int) { 28 | msghdr.Controllen = uint32(length) 29 | } 30 | 31 | func (cmsg *Cmsghdr) SetLen(length int) { 32 | cmsg.Len = uint32(length) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_openbsd.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "unsafe" 7 | ) 8 | 9 | func open() (pty, tty *os.File, err error) { 10 | /* 11 | * from ptm(4): 12 | * The PTMGET command allocates a free pseudo terminal, changes its 13 | * ownership to the caller, revokes the access privileges for all previous 14 | * users, opens the file descriptors for the master and slave devices and 15 | * returns them to the caller in struct ptmget. 16 | */ 17 | 18 | p, err := os.OpenFile("/dev/ptm", os.O_RDWR|syscall.O_CLOEXEC, 0) 19 | if err != nil { 20 | return nil, nil, err 21 | } 22 | defer p.Close() 23 | 24 | var ptm ptmget 25 | if err := ioctl(p.Fd(), uintptr(ioctl_PTMGET), uintptr(unsafe.Pointer(&ptm))); err != nil { 26 | return nil, nil, err 27 | } 28 | 29 | pty = os.NewFile(uintptr(ptm.Cfd), "/dev/ptm") 30 | tty = os.NewFile(uintptr(ptm.Sfd), "/dev/ptm") 31 | 32 | return pty, tty, nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/README.mkd: -------------------------------------------------------------------------------- 1 | go-runewidth 2 | ============ 3 | 4 | [![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) 5 | [![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) 8 | 9 | Provides functions to get fixed width of the character or string. 10 | 11 | Usage 12 | ----- 13 | 14 | ```go 15 | runewidth.StringWidth("つのだ☆HIRO") == 12 16 | ``` 17 | 18 | 19 | Author 20 | ------ 21 | 22 | Yasuhiro Matsumoto 23 | 24 | License 25 | ------- 26 | 27 | under the MIT License: http://mattn.mit-license.org/2013 28 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/commaf.go: -------------------------------------------------------------------------------- 1 | // +build go1.6 2 | 3 | package humanize 4 | 5 | import ( 6 | "bytes" 7 | "math/big" 8 | "strings" 9 | ) 10 | 11 | // BigCommaf produces a string form of the given big.Float in base 10 12 | // with commas after every three orders of magnitude. 13 | func BigCommaf(v *big.Float) string { 14 | buf := &bytes.Buffer{} 15 | if v.Sign() < 0 { 16 | buf.Write([]byte{'-'}) 17 | v.Abs(v) 18 | } 19 | 20 | comma := []byte{','} 21 | 22 | parts := strings.Split(v.Text('f', -1), ".") 23 | pos := 0 24 | if len(parts[0])%3 != 0 { 25 | pos += len(parts[0]) % 3 26 | buf.WriteString(parts[0][:pos]) 27 | buf.Write(comma) 28 | } 29 | for ; pos < len(parts[0]); pos += 3 { 30 | buf.WriteString(parts[0][pos : pos+3]) 31 | buf.Write(comma) 32 | } 33 | buf.Truncate(buf.Len() - 1) 34 | 35 | if len(parts) > 1 { 36 | buf.Write([]byte{'.'}) 37 | buf.WriteString(parts[1]) 38 | } 39 | return buf.String() 40 | } 41 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <> 8) 13 | } 14 | 15 | // Minor returns the minor component of a NetBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xfff00000) >> 12) 19 | return minor 20 | } 21 | 22 | // Mkdev returns a NetBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x000fff00 26 | dev |= (uint64(minor) << 12) & 0xfff00000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/value.go: -------------------------------------------------------------------------------- 1 | package dataframe 2 | 3 | import "time" 4 | 5 | // Value represents the value in data frame. 6 | type Value interface { 7 | // String parses Value to string. It returns false if not possible. 8 | String() (string, bool) 9 | 10 | // Int64 parses Value to int64. It returns false if not possible. 11 | Int64() (int64, bool) 12 | 13 | // Uint64 parses Value to uint64. It returns false if not possible. 14 | Uint64() (uint64, bool) 15 | 16 | // Float64 parses Value to float64. It returns false if not possible. 17 | Float64() (float64, bool) 18 | 19 | // Time parses Value to time.Time based on the layout. It returns false if not possible. 20 | Time(layout string) (time.Time, bool) 21 | 22 | // Duration parses Value to time.Duration. It returns false if not possible. 23 | Duration() (time.Duration, bool) 24 | 25 | // IsNil returns true if the Value is nil. 26 | IsNil() bool 27 | 28 | // EqualTo returns true if the Value is equal to v. 29 | EqualTo(v Value) bool 30 | 31 | // Copy copies Value. 32 | Copy() Value 33 | } 34 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_openbsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in OpenBSD's sys/types.h header. 7 | 8 | package unix 9 | 10 | // Major returns the major component of an OpenBSD device number. 11 | func Major(dev uint64) uint32 { 12 | return uint32((dev & 0x0000ff00) >> 8) 13 | } 14 | 15 | // Minor returns the minor component of an OpenBSD device number. 16 | func Minor(dev uint64) uint32 { 17 | minor := uint32((dev & 0x000000ff) >> 0) 18 | minor |= uint32((dev & 0xffff0000) >> 8) 19 | return minor 20 | } 21 | 22 | // Mkdev returns an OpenBSD device number generated from the given major and minor 23 | // components. 24 | func Mkdev(major, minor uint32) uint64 { 25 | dev := (uint64(major) << 8) & 0x0000ff00 26 | dev |= (uint64(minor) << 8) & 0xffff0000 27 | dev |= (uint64(minor) << 0) & 0x000000ff 28 | return dev 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## linux-inspect 2 | 3 | [![Go Report Card](https://goreportcard.com/badge/github.com/gyuho/linux-inspect?style=flat-square)](https://goreportcard.com/report/github.com/gyuho/linux-inspect) 4 | [![Build Status](https://img.shields.io/travis/gyuho/linux-inspect.svg?style=flat-square)](https://travis-ci.org/gyuho/linux-inspect) 5 | [![Build Status](https://semaphoreci.com/api/v1/gyuho/linux-inspect/branches/master/shields_badge.svg)](https://semaphoreci.com/gyuho/linux-inspect) 6 | [![Godoc](https://img.shields.io/badge/godoc-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/gyuho/linux-inspect) 7 | 8 | linux-inspect implements various Linux inspecting utilities. 9 | 10 | ``` 11 | go get -v github.com/gyuho/linux-inspect/cmd/linux-inspect 12 | ``` 13 | 14 | ``` 15 | Usage: 16 | linux-inspect [command] 17 | 18 | Available Commands: 19 | ds Inspects '/proc/diskstats' 20 | ns Inspects '/proc/net/dev' 21 | ps Inspects '/proc/$PID/status', 'top' command output 22 | ss Inspects '/proc/net/tcp,tcp6' 23 | ``` 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /proc/list.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "io/ioutil" 5 | "path/filepath" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | // ListPIDs reads all PIDs in '/proc'. 11 | func ListPIDs() ([]int64, error) { 12 | ds, err := ioutil.ReadDir("/proc") 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | pids := make([]int64, 0, len(ds)) 18 | for _, f := range ds { 19 | if f.IsDir() && isInt(f.Name()) { 20 | id, err := strconv.ParseInt(f.Name(), 10, 64) 21 | if err != nil { 22 | return nil, err 23 | } 24 | pids = append(pids, id) 25 | } 26 | } 27 | return pids, nil 28 | } 29 | 30 | // ListFds reads '/proc/*/fd/*' to grab process IDs. 31 | func ListFds() ([]string, error) { 32 | // returns the names of all files matching pattern 33 | // or nil if there is no matching file 34 | fs, err := filepath.Glob("/proc/[0-9]*/fd/[0-9]*") 35 | if err != nil { 36 | return nil, err 37 | } 38 | return fs, nil 39 | } 40 | 41 | func pidFromFd(s string) (int64, error) { 42 | // get 5261 from '/proc/5261/fd/69' 43 | return strconv.ParseInt(strings.Split(s, "/")[2], 10, 64) 44 | } 45 | -------------------------------------------------------------------------------- /proc/uptime.go: -------------------------------------------------------------------------------- 1 | package proc 2 | 3 | import ( 4 | "io/ioutil" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/gyuho/linux-inspect/pkg/fileutil" 9 | "github.com/gyuho/linux-inspect/pkg/timeutil" 10 | ) 11 | 12 | // GetUptime reads '/proc/uptime'. 13 | func GetUptime() (Uptime, error) { 14 | f, err := fileutil.OpenToRead("/proc/uptime") 15 | if err != nil { 16 | return Uptime{}, err 17 | } 18 | defer f.Close() 19 | 20 | b, err := ioutil.ReadAll(f) 21 | if err != nil { 22 | return Uptime{}, err 23 | } 24 | fields := strings.Fields(strings.TrimSpace(string(b))) 25 | 26 | u := Uptime{} 27 | if len(fields) > 0 { 28 | v, err := strconv.ParseFloat(fields[0], 64) 29 | if err != nil { 30 | return Uptime{}, err 31 | } 32 | u.UptimeTotal = v 33 | u.UptimeTotalParsedTime = timeutil.HumanizeDurationSecond(uint64(v)) 34 | } 35 | if len(fields) > 1 { 36 | v, err := strconv.ParseFloat(fields[1], 64) 37 | if err != nil { 38 | return Uptime{}, err 39 | } 40 | u.UptimeIdle = v 41 | u.UptimeIdleParsedTime = timeutil.HumanizeDurationSecond(uint64(v)) 42 | } 43 | return u, nil 44 | } 45 | -------------------------------------------------------------------------------- /cmd/linux-inspect/main.go: -------------------------------------------------------------------------------- 1 | // linux-inspect inspects Linux processes, sockets (ps, ss, netstat). 2 | // 3 | // Usage: 4 | // linux-inspect [command] 5 | // 6 | // Available Commands: 7 | // ds Inspects '/proc/diskstats' 8 | // ns Inspects '/proc/net/dev' 9 | // ps Inspects '/proc/$PID/stat,status' 10 | // ss Inspects '/proc/net/tcp,tcp6' 11 | // 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "os" 17 | 18 | "github.com/spf13/cobra" 19 | ) 20 | 21 | var ( 22 | command = &cobra.Command{ 23 | Use: "linux-inspect", 24 | Short: "linux-inspect inspects Linux processes, sockets (ps, ss, netstat).", 25 | SuggestFor: []string{"linux-inspects", "linuxinspect", "linux-inspec"}, 26 | } 27 | ) 28 | 29 | func init() { 30 | command.AddCommand(dsCommand) 31 | command.AddCommand(nsCommand) 32 | command.AddCommand(psCommand) 33 | command.AddCommand(ssCommand) 34 | } 35 | 36 | func init() { 37 | cobra.EnablePrefixMatching = true 38 | } 39 | 40 | func main() { 41 | if err := command.Execute(); err != nil { 42 | fmt.Fprintln(os.Stdout, err) 43 | os.Exit(1) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/gyuho/dataframe/value_data_type.go: -------------------------------------------------------------------------------- 1 | package dataframe 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // TimeDefaultLayout is used to parse time.Time. 9 | var TimeDefaultLayout = "2006-01-02 15:04:05 -0700 MST" 10 | 11 | // DATA_TYPE defines dataframe data types. 12 | type DATA_TYPE uint8 13 | 14 | const ( 15 | // STRING represents Go string or bytes. 16 | STRING DATA_TYPE = iota 17 | 18 | // TIME represents Go time.Time type. 19 | TIME 20 | ) 21 | 22 | func (dt DATA_TYPE) String() string { 23 | switch dt { 24 | case STRING: 25 | return "STRING" 26 | case TIME: 27 | return "TIME" 28 | default: 29 | panic(fmt.Errorf("DATA_TYPE %d is unknown", dt)) 30 | } 31 | } 32 | 33 | // ReflectTypeOf returns the DATA_TYPE. 34 | func ReflectTypeOf(v interface{}) DATA_TYPE { 35 | switch v.(type) { 36 | case time.Time: 37 | return TIME 38 | default: 39 | return STRING 40 | } 41 | } 42 | 43 | // ToValue converts to Value. 44 | func ToValue(v interface{}) Value { 45 | switch ReflectTypeOf(v) { 46 | case TIME: 47 | return NewTimeValue(v) 48 | default: 49 | return NewStringValue(v) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/olekukonko/tablewriter/LICENCE.md: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 by Oleku Konko 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/License: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 Keith Rarick 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without limitation 7 | the rights to use, copy, modify, merge, publish, distribute, 8 | sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall 13 | be included in all copies or substantial portions of the 14 | Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 17 | KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 18 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 19 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 20 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 22 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in FreeBSD's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a FreeBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a FreeBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a FreeBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/ftoa.go: -------------------------------------------------------------------------------- 1 | package humanize 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | ) 7 | 8 | func stripTrailingZeros(s string) string { 9 | offset := len(s) - 1 10 | for offset > 0 { 11 | if s[offset] == '.' { 12 | offset-- 13 | break 14 | } 15 | if s[offset] != '0' { 16 | break 17 | } 18 | offset-- 19 | } 20 | return s[:offset+1] 21 | } 22 | 23 | func stripTrailingDigits(s string, digits int) string { 24 | if i := strings.Index(s, "."); i >= 0 { 25 | if digits <= 0 { 26 | return s[:i] 27 | } 28 | i++ 29 | if i+digits >= len(s) { 30 | return s 31 | } 32 | return s[:i+digits] 33 | } 34 | return s 35 | } 36 | 37 | // Ftoa converts a float to a string with no trailing zeros. 38 | func Ftoa(num float64) string { 39 | return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) 40 | } 41 | 42 | // FtoaWithDigits converts a float to a string but limits the resulting string 43 | // to the given number of decimal places, and no trailing zeros. 44 | func FtoaWithDigits(num float64, digits int) string { 45 | return stripTrailingZeros(stripTrailingDigits(strconv.FormatFloat(num, 'f', 6, 64), digits)) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/color/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used in Dragonfly's sys/types.h header. 7 | // 8 | // The information below is extracted and adapted from sys/types.h: 9 | // 10 | // Minor gives a cookie instead of an index since in order to avoid changing the 11 | // meanings of bits 0-15 or wasting time and space shifting bits 16-31 for 12 | // devices that don't use them. 13 | 14 | package unix 15 | 16 | // Major returns the major component of a DragonFlyBSD device number. 17 | func Major(dev uint64) uint32 { 18 | return uint32((dev >> 8) & 0xff) 19 | } 20 | 21 | // Minor returns the minor component of a DragonFlyBSD device number. 22 | func Minor(dev uint64) uint32 { 23 | return uint32(dev & 0xffff00ff) 24 | } 25 | 26 | // Mkdev returns a DragonFlyBSD device number generated from the given major and 27 | // minor components. 28 | func Mkdev(major, minor uint32) uint64 { 29 | return (uint64(major) << 8) | uint64(minor) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/log_hijack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package capnslog 16 | 17 | import ( 18 | "log" 19 | ) 20 | 21 | func initHijack() { 22 | pkg := NewPackageLogger("log", "") 23 | w := packageWriter{pkg} 24 | log.SetFlags(0) 25 | log.SetPrefix("") 26 | log.SetOutput(w) 27 | } 28 | 29 | type packageWriter struct { 30 | pl *PackageLogger 31 | } 32 | 33 | func (p packageWriter) Write(b []byte) (int, error) { 34 | if p.pl.level < INFO { 35 | return 0, nil 36 | } 37 | p.pl.internalLog(calldepth+2, INFO, string(b)) 38 | return len(b), nil 39 | } 40 | -------------------------------------------------------------------------------- /etc/schema.go: -------------------------------------------------------------------------------- 1 | package etc 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/gyuho/linux-inspect/schema" 7 | ) 8 | 9 | // MtabSchema represents '/etc/mtab'. 10 | // Reference https://en.wikipedia.org/wiki/Fstab 11 | // and https://en.wikipedia.org/wiki/Mtab). 12 | var MtabSchema = schema.RawData{ 13 | IsYAML: false, 14 | Columns: []schema.Column{ 15 | {Name: "file-system", Godoc: "file system", Kind: reflect.String}, 16 | {Name: "mounted-on", Godoc: "'mounted on'", Kind: reflect.String}, 17 | {Name: "file-system-type", Godoc: "file system type", Kind: reflect.String}, 18 | {Name: "options", Godoc: "file system type", Kind: reflect.String}, 19 | {Name: "dump", Godoc: "number indicating whether and how often the file system should be backed up by the dump program; a zero indicates the file system will never be automatically backed up", Kind: reflect.Int}, 20 | {Name: "pass", Godoc: "number indicating the order in which the fsck program will check the devices for errors at boot time; this is 1 for the root file system and either 2 (meaning check after root) or 0 (do not check) for all other devices", Kind: reflect.Int}, 21 | }, 22 | ColumnsToParse: map[string]schema.RawDataType{}, 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/cpuutil/endian.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package cpuutil 16 | 17 | import ( 18 | "encoding/binary" 19 | "unsafe" 20 | ) 21 | 22 | const intWidth int = int(unsafe.Sizeof(0)) 23 | 24 | var byteOrder binary.ByteOrder 25 | 26 | // ByteOrder returns the byte order for the CPU's native endianness. 27 | func ByteOrder() binary.ByteOrder { return byteOrder } 28 | 29 | func init() { 30 | var i int = 0x1 31 | if v := (*[intWidth]byte)(unsafe.Pointer(&i)); v[0] == 0 { 32 | byteOrder = binary.BigEndian 33 | } else { 34 | byteOrder = binary.LittleEndian 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/dustin/go-humanize/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005-2008 Dustin Sallings 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | 22 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_linux.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "os" 5 | "strconv" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func open() (pty, tty *os.File, err error) { 11 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 12 | if err != nil { 13 | return nil, nil, err 14 | } 15 | // In case of error after this point, make sure we close the ptmx fd. 16 | defer func() { 17 | if err != nil { 18 | _ = p.Close() // Best effort. 19 | } 20 | }() 21 | 22 | sname, err := ptsname(p) 23 | if err != nil { 24 | return nil, nil, err 25 | } 26 | 27 | if err := unlockpt(p); err != nil { 28 | return nil, nil, err 29 | } 30 | 31 | t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) 32 | if err != nil { 33 | return nil, nil, err 34 | } 35 | return p, t, nil 36 | } 37 | 38 | func ptsname(f *os.File) (string, error) { 39 | var n _C_uint 40 | err := ioctl(f.Fd(), syscall.TIOCGPTN, uintptr(unsafe.Pointer(&n))) 41 | if err != nil { 42 | return "", err 43 | } 44 | return "/dev/pts/" + strconv.Itoa(int(n)), nil 45 | } 46 | 47 | func unlockpt(f *os.File) error { 48 | var u _C_int 49 | // use TIOCSPTLCK with a zero valued arg to clear the slave pty lock 50 | return ioctl(f.Fd(), syscall.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))) 51 | } 52 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:17.10 2 | 3 | ENV ROOT_DIR / 4 | WORKDIR ${ROOT_DIR} 5 | ENV HOME /root 6 | 7 | RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \ 8 | && apt-get -y update \ 9 | && apt-get -y install \ 10 | build-essential \ 11 | gcc \ 12 | apt-utils \ 13 | software-properties-common \ 14 | curl \ 15 | python \ 16 | git \ 17 | tar \ 18 | bash \ 19 | apt-transport-https \ 20 | libssl-dev \ 21 | && rm /bin/sh \ 22 | && ln -s /bin/bash /bin/sh \ 23 | && ls -l $(which bash) \ 24 | && echo "root ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \ 25 | && apt-get -y clean \ 26 | && rm -rf /var/lib/apt/lists/* \ 27 | && apt-get -y update \ 28 | && apt-get -y upgrade \ 29 | && apt-get -y dist-upgrade \ 30 | && apt-get -y update \ 31 | && apt-get -y upgrade \ 32 | && apt-get -y autoremove \ 33 | && apt-get -y autoclean 34 | 35 | ENV GOROOT /usr/local/go 36 | ENV GOPATH /go 37 | ENV PATH ${GOPATH}/bin:${GOROOT}/bin:${PATH} 38 | ENV GO_VERSION REPLACE_ME_GO_VERSION 39 | ENV GO_DOWNLOAD_URL https://storage.googleapis.com/golang 40 | RUN rm -rf ${GOROOT} \ 41 | && curl -s ${GO_DOWNLOAD_URL}/go${GO_VERSION}.linux-amd64.tar.gz | tar -v -C /usr/local/ -xz \ 42 | && mkdir -p ${GOPATH}/src ${GOPATH}/bin \ 43 | && go version 44 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/ioctl_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package pty 4 | 5 | // from 6 | const ( 7 | _IOC_VOID uintptr = 0x20000000 8 | _IOC_OUT uintptr = 0x40000000 9 | _IOC_IN uintptr = 0x80000000 10 | _IOC_IN_OUT uintptr = _IOC_OUT | _IOC_IN 11 | _IOC_DIRMASK = _IOC_VOID | _IOC_OUT | _IOC_IN 12 | 13 | _IOC_PARAM_SHIFT = 13 14 | _IOC_PARAM_MASK = (1 << _IOC_PARAM_SHIFT) - 1 15 | ) 16 | 17 | func _IOC_PARM_LEN(ioctl uintptr) uintptr { 18 | return (ioctl >> 16) & _IOC_PARAM_MASK 19 | } 20 | 21 | func _IOC(inout uintptr, group byte, ioctl_num uintptr, param_len uintptr) uintptr { 22 | return inout | (param_len&_IOC_PARAM_MASK)<<16 | uintptr(group)<<8 | ioctl_num 23 | } 24 | 25 | func _IO(group byte, ioctl_num uintptr) uintptr { 26 | return _IOC(_IOC_VOID, group, ioctl_num, 0) 27 | } 28 | 29 | func _IOR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 30 | return _IOC(_IOC_OUT, group, ioctl_num, param_len) 31 | } 32 | 33 | func _IOW(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 34 | return _IOC(_IOC_IN, group, ioctl_num, param_len) 35 | } 36 | 37 | func _IOWR(group byte, ioctl_num uintptr, param_len uintptr) uintptr { 38 | return _IOC(_IOC_IN_OUT, group, ioctl_num, param_len) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for DragonFly from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_dragonfly.pl " . join(' ', @ARGV); 17 | 18 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /cmd/generate-top/main.go: -------------------------------------------------------------------------------- 1 | // generate-top generates 'top' struct based on the schema. 2 | package main 3 | 4 | import ( 5 | "bytes" 6 | "fmt" 7 | "os" 8 | "os/exec" 9 | "path/filepath" 10 | 11 | "github.com/gyuho/linux-inspect/pkg/fileutil" 12 | "github.com/gyuho/linux-inspect/pkg/timeutil" 13 | "github.com/gyuho/linux-inspect/schema" 14 | "github.com/gyuho/linux-inspect/top" 15 | ) 16 | 17 | func main() { 18 | wd, err := os.Getwd() 19 | if err != nil { 20 | panic(err) 21 | } 22 | exp := filepath.Join(os.Getenv("GOPATH"), "src/github.com/gyuho/linux-inspect") 23 | if wd != exp { 24 | panic(fmt.Errorf("must be run in repo root %q, but run at %q", exp, wd)) 25 | } 26 | 27 | buf := new(bytes.Buffer) 28 | buf.WriteString(`package top 29 | 30 | // updated at ` + timeutil.NowPST().String() + ` 31 | 32 | `) 33 | 34 | // 'top' 35 | buf.WriteString(`// Row represents a row in 'top' command output. 36 | type Row struct { 37 | `) 38 | buf.WriteString(schema.Generate(top.RowSchema)) 39 | buf.WriteString("}\n\n") 40 | 41 | txt := buf.String() 42 | if err := fileutil.ToFile(txt, filepath.Join(os.Getenv("GOPATH"), "src/github.com/gyuho/linux-inspect/top/generated.go")); err != nil { 43 | panic(err) 44 | } 45 | if err := os.Chdir(filepath.Join(os.Getenv("GOPATH"), "src/github.com/gyuho/linux-inspect/top")); err != nil { 46 | panic(err) 47 | } 48 | if err := exec.Command("go", "fmt", "./...").Run(); err != nil { 49 | panic(err) 50 | } 51 | 52 | fmt.Println("DONE") 53 | } 54 | -------------------------------------------------------------------------------- /top/schema.go: -------------------------------------------------------------------------------- 1 | package top 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/gyuho/linux-inspect/schema" 7 | ) 8 | 9 | // RowSchema represents a row in 'top' command output. 10 | // Reference http://man7.org/linux/man-pages/man1/top.1.html. 11 | var RowSchema = schema.RawData{ 12 | IsYAML: false, 13 | Columns: []schema.Column{ 14 | {Name: "PID", Godoc: "pid of the process", Kind: reflect.Int64}, 15 | {Name: "USER", Godoc: "user name", Kind: reflect.String}, 16 | {Name: "PR", Godoc: "priority", Kind: reflect.String}, 17 | {Name: "NI", Godoc: "nice value of the task", Kind: reflect.String}, 18 | {Name: "VIRT", Godoc: "total amount of virtual memory used by the task (in KiB)", Kind: reflect.String}, 19 | {Name: "RES", Godoc: "non-swapped physical memory a task is using (in KiB)", Kind: reflect.String}, 20 | {Name: "SHR", Godoc: "amount of shared memory available to a task, not all of which is typically resident (in KiB)", Kind: reflect.String}, 21 | {Name: "S", Godoc: "process status", Kind: reflect.String}, 22 | {Name: "CPUPercent", Godoc: "%CPU", Kind: reflect.Float64}, 23 | {Name: "MEMPercent", Godoc: "%MEM", Kind: reflect.Float64}, 24 | {Name: "TIME", Godoc: "CPU time (TIME+)", Kind: reflect.String}, 25 | {Name: "COMMAND", Godoc: "command", Kind: reflect.String}, 26 | }, 27 | ColumnsToParse: map[string]schema.RawDataType{ 28 | "S": schema.TypeStatus, 29 | "VIRT": schema.TypeBytes, 30 | "RES": schema.TypeBytes, 31 | "SHR": schema.TypeBytes, 32 | }, 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/etcd/pkg/types/id.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The etcd Authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | import ( 18 | "strconv" 19 | ) 20 | 21 | // ID represents a generic identifier which is canonically 22 | // stored as a uint64 but is typically represented as a 23 | // base-16 string for input/output 24 | type ID uint64 25 | 26 | func (i ID) String() string { 27 | return strconv.FormatUint(uint64(i), 16) 28 | } 29 | 30 | // IDFromString attempts to create an ID from a base-16 string. 31 | func IDFromString(s string) (ID, error) { 32 | i, err := strconv.ParseUint(s, 16, 64) 33 | return ID(i), err 34 | } 35 | 36 | // IDSlice implements the sort interface 37 | type IDSlice []ID 38 | 39 | func (p IDSlice) Len() int { return len(p) } 40 | func (p IDSlice) Less(i, j int) bool { return uint64(p[i]) < uint64(p[j]) } 41 | func (p IDSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 23 | k.Ident = uint32(fd) 24 | k.Filter = int16(mode) 25 | k.Flags = uint16(flags) 26 | } 27 | 28 | func (iov *Iovec) SetLen(length int) { 29 | iov.Len = uint32(length) 30 | } 31 | 32 | func (msghdr *Msghdr) SetControllen(length int) { 33 | msghdr.Controllen = uint32(length) 34 | } 35 | 36 | func (cmsg *Cmsghdr) SetLen(length int) { 37 | cmsg.Len = uint32(length) 38 | } 39 | 40 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 41 | var writtenOut uint64 = 0 42 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 43 | 44 | written = int(writtenOut) 45 | 46 | if e1 != 0 { 47 | err = e1 48 | } 49 | return 50 | } 51 | 52 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 53 | -------------------------------------------------------------------------------- /inspect/ps_test.go: -------------------------------------------------------------------------------- 1 | package inspect 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "testing" 7 | 8 | "github.com/gyuho/linux-inspect/top" 9 | ) 10 | 11 | func TestGetPS(t *testing.T) { 12 | ns, err := GetPS(WithTopLimit(3)) 13 | if err != nil { 14 | t.Skip(err) 15 | } 16 | hd, rows := ConvertPS(ns...) 17 | txt := StringPS(hd, rows, -1) 18 | fmt.Println(txt) 19 | } 20 | 21 | func TestGetPSWithFilter(t *testing.T) { 22 | pid := int64(os.Getpid()) 23 | 24 | ns, err := GetPS(WithPID(pid)) 25 | if err != nil { 26 | t.Skip(err) 27 | } 28 | hd, rows := ConvertPS(ns...) 29 | txt := StringPS(hd, rows, -1) 30 | fmt.Println(txt) 31 | } 32 | 33 | func TestGetPSWithTopStream(t *testing.T) { 34 | pid := int64(os.Getpid()) 35 | 36 | cfg := &top.Config{ 37 | Exec: top.DefaultExecPath, 38 | IntervalSecond: 1, 39 | PID: pid, 40 | } 41 | str, err := cfg.StartStream() 42 | if err != nil { 43 | t.Skip(err) 44 | } 45 | 46 | ns, err := GetPS(WithPID(pid), WithTopStream(str)) 47 | if err != nil { 48 | t.Skip(err) 49 | } 50 | hd, rows := ConvertPS(ns...) 51 | txt := StringPS(hd, rows, -1) 52 | fmt.Println("ps:") 53 | fmt.Println(txt) 54 | 55 | if err = str.Stop(); err != nil { 56 | t.Fatal(err) 57 | } 58 | select { 59 | case err = <-str.ErrChan(): 60 | t.Fatal(err) 61 | default: 62 | fmt.Println("'top' stopped") 63 | } 64 | 65 | rm := str.Latest() 66 | for _, row := range rm { 67 | fmt.Printf("%+v\n", row) 68 | } 69 | fmt.Println("total", len(rm), "processes") 70 | } 71 | -------------------------------------------------------------------------------- /top/generated.go: -------------------------------------------------------------------------------- 1 | package top 2 | 3 | // updated at 2017-12-21 12:15:58.06223 -0800 PST 4 | 5 | // Row represents a row in 'top' command output. 6 | type Row struct { 7 | // PID is pid of the process. 8 | PID int64 `column:"pid"` 9 | // USER is user name. 10 | USER string `column:"user"` 11 | // PR is priority. 12 | PR string `column:"pr"` 13 | // NI is nice value of the task. 14 | NI string `column:"ni"` 15 | // VIRT is total amount of virtual memory used by the task (in KiB). 16 | VIRT string `column:"virt"` 17 | VIRTBytesN uint64 `column:"virt_bytes_n"` 18 | VIRTParsedBytes string `column:"virt_parsed_bytes"` 19 | // RES is non-swapped physical memory a task is using (in KiB). 20 | RES string `column:"res"` 21 | RESBytesN uint64 `column:"res_bytes_n"` 22 | RESParsedBytes string `column:"res_parsed_bytes"` 23 | // SHR is amount of shared memory available to a task, not all of which is typically resident (in KiB). 24 | SHR string `column:"shr"` 25 | SHRBytesN uint64 `column:"shr_bytes_n"` 26 | SHRParsedBytes string `column:"shr_parsed_bytes"` 27 | // S is process status. 28 | S string `column:"s"` 29 | SParsedStatus string `column:"s_parsed_status"` 30 | // CPUPercent is %CPU. 31 | CPUPercent float64 `column:"cpupercent"` 32 | // MEMPercent is %MEM. 33 | MEMPercent float64 `column:"mempercent"` 34 | // TIME is CPU time (TIME+). 35 | TIME string `column:"time"` 36 | // COMMAND is command. 37 | COMMAND string `column:"command"` 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for OpenBSD from master list 7 | # (for example, /usr/src/sys/kern/syscalls.master). 8 | 9 | use strict; 10 | 11 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 12 | print STDERR "GOARCH or GOOS not defined in environment\n"; 13 | exit 1; 14 | } 15 | 16 | my $command = "mksysnum_netbsd.pl " . join(' ', @ARGV); 17 | 18 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '13' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print < 1 && (charset[0] != 'u' || 53 | strings.HasPrefix(locale, "ja") || 54 | strings.HasPrefix(locale, "ko") || 55 | strings.HasPrefix(locale, "zh")) { 56 | return true 57 | } 58 | return false 59 | } 60 | 61 | // IsEastAsian return true if the current locale is CJK 62 | func IsEastAsian() bool { 63 | locale := os.Getenv("LC_CTYPE") 64 | if locale == "" { 65 | locale = os.Getenv("LANG") 66 | } 67 | 68 | // ignore C locale 69 | if locale == "POSIX" || locale == "C" { 70 | return false 71 | } 72 | if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') { 73 | return false 74 | } 75 | 76 | return isEastAsian(locale) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := (uint64(major) & 0x00000fff) << 8 38 | dev |= (uint64(major) & 0xfffff000) << 32 39 | dev |= (uint64(minor) & 0x000000ff) << 0 40 | dev |= (uint64(minor) & 0xffffff00) << 12 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/syslog_formatter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // +build !windows 16 | 17 | package capnslog 18 | 19 | import ( 20 | "fmt" 21 | "log/syslog" 22 | ) 23 | 24 | func NewSyslogFormatter(w *syslog.Writer) Formatter { 25 | return &syslogFormatter{w} 26 | } 27 | 28 | func NewDefaultSyslogFormatter(tag string) (Formatter, error) { 29 | w, err := syslog.New(syslog.LOG_DEBUG, tag) 30 | if err != nil { 31 | return nil, err 32 | } 33 | return NewSyslogFormatter(w), nil 34 | } 35 | 36 | type syslogFormatter struct { 37 | w *syslog.Writer 38 | } 39 | 40 | func (s *syslogFormatter) Format(pkg string, l LogLevel, _ int, entries ...interface{}) { 41 | for _, entry := range entries { 42 | str := fmt.Sprint(entry) 43 | switch l { 44 | case CRITICAL: 45 | s.w.Crit(str) 46 | case ERROR: 47 | s.w.Err(str) 48 | case WARNING: 49 | s.w.Warning(str) 50 | case NOTICE: 51 | s.w.Notice(str) 52 | case INFO: 53 | s.w.Info(str) 54 | case DEBUG: 55 | s.w.Debug(str) 56 | case TRACE: 57 | s.w.Debug(str) 58 | default: 59 | panic("Unhandled loglevel") 60 | } 61 | } 62 | } 63 | 64 | func (s *syslogFormatter) Flush() { 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/util.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pty 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // InheritSize applies the terminal size of master to slave. This should be run 12 | // in a signal handler for syscall.SIGWINCH to automatically resize the slave when 13 | // the master receives a window size change notification. 14 | func InheritSize(master, slave *os.File) error { 15 | size, err := GetsizeFull(master) 16 | if err != nil { 17 | return err 18 | } 19 | err = Setsize(slave, size) 20 | if err != nil { 21 | return err 22 | } 23 | return nil 24 | } 25 | 26 | // Setsize resizes t to s. 27 | func Setsize(t *os.File, ws *Winsize) error { 28 | return windowRectCall(ws, t.Fd(), syscall.TIOCSWINSZ) 29 | } 30 | 31 | // GetsizeFull returns the full terminal size description. 32 | func GetsizeFull(t *os.File) (size *Winsize, err error) { 33 | var ws Winsize 34 | err = windowRectCall(&ws, t.Fd(), syscall.TIOCGWINSZ) 35 | return &ws, err 36 | } 37 | 38 | // Getsize returns the number of rows (lines) and cols (positions 39 | // in each line) in terminal t. 40 | func Getsize(t *os.File) (rows, cols int, err error) { 41 | ws, err := GetsizeFull(t) 42 | return int(ws.Rows), int(ws.Cols), err 43 | } 44 | 45 | // Winsize describes the terminal size. 46 | type Winsize struct { 47 | Rows uint16 // ws_row: Number of rows (in cells) 48 | Cols uint16 // ws_col: Number of columns (in cells) 49 | X uint16 // ws_xpixel: Width in pixels 50 | Y uint16 // ws_ypixel: Height in pixels 51 | } 52 | 53 | func windowRectCall(ws *Winsize, fd, a2 uintptr) error { 54 | _, _, errno := syscall.Syscall( 55 | syscall.SYS_IOCTL, 56 | fd, 57 | a2, 58 | uintptr(unsafe.Pointer(ws)), 59 | ) 60 | if errno != 0 { 61 | return syscall.Errno(errno) 62 | } 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /cmd/linux-inspect/ps.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/gyuho/linux-inspect/inspect" 8 | "github.com/gyuho/linux-inspect/top" 9 | 10 | "github.com/fatih/color" 11 | "github.com/spf13/cobra" 12 | ) 13 | 14 | type psFlags struct { 15 | topExecPath string 16 | limit int 17 | 18 | program string 19 | pid int64 20 | } 21 | 22 | var ( 23 | psCommand = &cobra.Command{ 24 | Use: "ps", 25 | Short: "Inspects '/proc/$PID/status', 'top' command output", 26 | RunE: psCommandFunc, 27 | } 28 | psCmdFlag psFlags 29 | ) 30 | 31 | func init() { 32 | psCommand.PersistentFlags().StringVarP(&psCmdFlag.topExecPath, "top-exec", "t", "", "Specify the top command path.") 33 | psCommand.PersistentFlags().IntVarP(&psCmdFlag.limit, "limit", "l", 5, "Limit the number results to return.") 34 | 35 | psCommand.PersistentFlags().StringVarP(&psCmdFlag.program, "program", "s", "", "Specify the program name.") 36 | psCommand.PersistentFlags().Int64VarP(&psCmdFlag.pid, "pid", "p", -1, "Specify the PID.") 37 | } 38 | 39 | func psCommandFunc(cmd *cobra.Command, args []string) error { 40 | color.Set(color.FgMagenta) 41 | fmt.Fprintf(os.Stdout, "\n'ps' to inspect '/proc/$PID/status', 'top' command outpu\n\n") 42 | color.Unset() 43 | 44 | if psCmdFlag.topExecPath == "" { 45 | psCmdFlag.topExecPath = top.DefaultExecPath 46 | } 47 | pss, err := inspect.GetPS( 48 | inspect.WithProgram(psCmdFlag.program), 49 | inspect.WithPID(psCmdFlag.pid), 50 | inspect.WithTopExecPath(psCmdFlag.topExecPath), 51 | inspect.WithTopLimit(psCmdFlag.limit), 52 | ) 53 | if err != nil { 54 | return err 55 | } 56 | hd, rows := inspect.ConvertPS(pss...) 57 | txt := inspect.StringPS(hd, rows, -1) 58 | fmt.Print(txt) 59 | 60 | color.Set(color.FgGreen) 61 | fmt.Fprintf(os.Stdout, "\nDONE!\n") 62 | color.Unset() 63 | 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_freebsd.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "syscall" 7 | "unsafe" 8 | ) 9 | 10 | func posixOpenpt(oflag int) (fd int, err error) { 11 | r0, _, e1 := syscall.Syscall(syscall.SYS_POSIX_OPENPT, uintptr(oflag), 0, 0) 12 | fd = int(r0) 13 | if e1 != 0 { 14 | err = e1 15 | } 16 | return fd, err 17 | } 18 | 19 | func open() (pty, tty *os.File, err error) { 20 | fd, err := posixOpenpt(syscall.O_RDWR | syscall.O_CLOEXEC) 21 | if err != nil { 22 | return nil, nil, err 23 | } 24 | p := os.NewFile(uintptr(fd), "/dev/pts") 25 | // In case of error after this point, make sure we close the pts fd. 26 | defer func() { 27 | if err != nil { 28 | _ = p.Close() // Best effort. 29 | } 30 | }() 31 | 32 | sname, err := ptsname(p) 33 | if err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | t, err := os.OpenFile("/dev/"+sname, os.O_RDWR, 0) 38 | if err != nil { 39 | return nil, nil, err 40 | } 41 | return p, t, nil 42 | } 43 | 44 | func isptmaster(fd uintptr) (bool, error) { 45 | err := ioctl(fd, syscall.TIOCPTMASTER, 0) 46 | return err == nil, err 47 | } 48 | 49 | var ( 50 | emptyFiodgnameArg fiodgnameArg 51 | ioctlFIODGNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 52 | ) 53 | 54 | func ptsname(f *os.File) (string, error) { 55 | master, err := isptmaster(f.Fd()) 56 | if err != nil { 57 | return "", err 58 | } 59 | if !master { 60 | return "", syscall.EINVAL 61 | } 62 | 63 | const n = _C_SPECNAMELEN + 1 64 | var ( 65 | buf = make([]byte, n) 66 | arg = fiodgnameArg{Len: n, Buf: (*byte)(unsafe.Pointer(&buf[0]))} 67 | ) 68 | if err := ioctl(f.Fd(), ioctlFIODGNAME, uintptr(unsafe.Pointer(&arg))); err != nil { 69 | return "", err 70 | } 71 | 72 | for i, c := range buf { 73 | if c == 0 { 74 | return string(buf[:i]), nil 75 | } 76 | } 77 | return "", errors.New("FIODGNAME string not NUL-terminated") 78 | } 79 | -------------------------------------------------------------------------------- /df/generated.go: -------------------------------------------------------------------------------- 1 | package df 2 | 3 | // updated at 2017-12-21 12:15:54.764438 -0800 PST 4 | 5 | // Row is 'df' command output row in Linux. 6 | type Row struct { 7 | // FileSystem is file system ('source'). 8 | FileSystem string `column:"file_system"` 9 | // Device is device name. 10 | Device string `column:"device"` 11 | // MountedOn is 'mounted on' ('target'). 12 | MountedOn string `column:"mounted_on"` 13 | // FileSystemType is file system type ('fstype'). 14 | FileSystemType string `column:"file_system_type"` 15 | // File is file name if specified on the command line ('file'). 16 | File string `column:"file"` 17 | // Inodes is total number of inodes ('itotal'). 18 | Inodes int64 `column:"inodes"` 19 | // Ifree is number of available inodes ('iavail'). 20 | Ifree int64 `column:"ifree"` 21 | // Iused is number of used inodes ('iused'). 22 | Iused int64 `column:"iused"` 23 | // IusedPercent is percentage of iused divided by itotal ('ipcent'). 24 | IusedPercent string `column:"iused_percent"` 25 | // TotalBlocks is total number of 1K-blocks ('size'). 26 | TotalBlocks int64 `column:"total_blocks"` 27 | TotalBlocksBytesN int64 `column:"total_blocks_bytes_n"` 28 | TotalBlocksParsedBytes string `column:"total_blocks_parsed_bytes"` 29 | // AvailableBlocks is number of available 1K-blocks ('avail'). 30 | AvailableBlocks int64 `column:"available_blocks"` 31 | AvailableBlocksBytesN int64 `column:"available_blocks_bytes_n"` 32 | AvailableBlocksParsedBytes string `column:"available_blocks_parsed_bytes"` 33 | // UsedBlocks is number of used 1K-blocks ('used'). 34 | UsedBlocks int64 `column:"used_blocks"` 35 | UsedBlocksBytesN int64 `column:"used_blocks_bytes_n"` 36 | UsedBlocksParsedBytes string `column:"used_blocks_parsed_bytes"` 37 | // UsedBlocksPercent is percentage of used-blocks divided by total-blocks ('pcent'). 38 | UsedBlocksPercent string `column:"used_blocks_percent"` 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/kr/pty/pty_dragonfly.go: -------------------------------------------------------------------------------- 1 | package pty 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strings" 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | // same code as pty_darwin.go 12 | func open() (pty, tty *os.File, err error) { 13 | p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) 14 | if err != nil { 15 | return nil, nil, err 16 | } 17 | // In case of error after this point, make sure we close the ptmx fd. 18 | defer func() { 19 | if err != nil { 20 | _ = p.Close() // Best effort. 21 | } 22 | }() 23 | 24 | sname, err := ptsname(p) 25 | if err != nil { 26 | return nil, nil, err 27 | } 28 | 29 | if err := grantpt(p); err != nil { 30 | return nil, nil, err 31 | } 32 | 33 | if err := unlockpt(p); err != nil { 34 | return nil, nil, err 35 | } 36 | 37 | t, err := os.OpenFile(sname, os.O_RDWR, 0) 38 | if err != nil { 39 | return nil, nil, err 40 | } 41 | return p, t, nil 42 | } 43 | 44 | func grantpt(f *os.File) error { 45 | _, err := isptmaster(f.Fd()) 46 | return err 47 | } 48 | 49 | func unlockpt(f *os.File) error { 50 | _, err := isptmaster(f.Fd()) 51 | return err 52 | } 53 | 54 | func isptmaster(fd uintptr) (bool, error) { 55 | err := ioctl(fd, syscall.TIOCISPTMASTER, 0) 56 | return err == nil, err 57 | } 58 | 59 | var ( 60 | emptyFiodgnameArg fiodgnameArg 61 | ioctl_FIODNAME = _IOW('f', 120, unsafe.Sizeof(emptyFiodgnameArg)) 62 | ) 63 | 64 | func ptsname(f *os.File) (string, error) { 65 | name := make([]byte, _C_SPECNAMELEN) 66 | fa := fiodgnameArg{Name: (*byte)(unsafe.Pointer(&name[0])), Len: _C_SPECNAMELEN, Pad_cgo_0: [4]byte{0, 0, 0, 0}} 67 | 68 | err := ioctl(f.Fd(), ioctl_FIODNAME, uintptr(unsafe.Pointer(&fa))) 69 | if err != nil { 70 | return "", err 71 | } 72 | 73 | for i, c := range name { 74 | if c == 0 { 75 | s := "/dev/" + string(name[:i]) 76 | return strings.Replace(s, "ptm", "pts", -1), nil 77 | } 78 | } 79 | return "", errors.New("TIOCPTYGNAME string not NUL-terminated") 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/coreos/pkg/capnslog/journald_formatter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // +build !windows 16 | 17 | package capnslog 18 | 19 | import ( 20 | "errors" 21 | "fmt" 22 | "os" 23 | "path/filepath" 24 | 25 | "github.com/coreos/go-systemd/journal" 26 | ) 27 | 28 | func NewJournaldFormatter() (Formatter, error) { 29 | if !journal.Enabled() { 30 | return nil, errors.New("No systemd detected") 31 | } 32 | return &journaldFormatter{}, nil 33 | } 34 | 35 | type journaldFormatter struct{} 36 | 37 | func (j *journaldFormatter) Format(pkg string, l LogLevel, _ int, entries ...interface{}) { 38 | var pri journal.Priority 39 | switch l { 40 | case CRITICAL: 41 | pri = journal.PriCrit 42 | case ERROR: 43 | pri = journal.PriErr 44 | case WARNING: 45 | pri = journal.PriWarning 46 | case NOTICE: 47 | pri = journal.PriNotice 48 | case INFO: 49 | pri = journal.PriInfo 50 | case DEBUG: 51 | pri = journal.PriDebug 52 | case TRACE: 53 | pri = journal.PriDebug 54 | default: 55 | panic("Unhandled loglevel") 56 | } 57 | msg := fmt.Sprint(entries...) 58 | tags := map[string]string{ 59 | "PACKAGE": pkg, 60 | "SYSLOG_IDENTIFIER": filepath.Base(os.Args[0]), 61 | } 62 | err := journal.Send(msg, pri, tags) 63 | if err != nil { 64 | fmt.Fprintln(os.Stderr, err) 65 | } 66 | } 67 | 68 | func (j *journaldFormatter) Flush() {} 69 | -------------------------------------------------------------------------------- /df/schema.go: -------------------------------------------------------------------------------- 1 | package df 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/gyuho/linux-inspect/schema" 7 | ) 8 | 9 | // RowSchema represents 'df' command output row 10 | // (See https://en.wikipedia.org/wiki/Df_(Unix) 11 | // and https://www.gnu.org/software/coreutils/manual/html_node/df-invocation.html 12 | // and 'df --all --sync --block-size=1024 --output=source,target,fstype,file,itotal,iavail,iused,ipcent,size,avail,used,pcent' 13 | // and the output unit is kilobytes). 14 | var RowSchema = schema.RawData{ 15 | IsYAML: false, 16 | Columns: []schema.Column{ 17 | {Name: "file-system", Godoc: "file system ('source')", Kind: reflect.String}, 18 | {Name: "device", Godoc: "device name", Kind: reflect.String}, 19 | {Name: "mounted-on", Godoc: "'mounted on' ('target')", Kind: reflect.String}, 20 | {Name: "file-system-type", Godoc: "file system type ('fstype')", Kind: reflect.String}, 21 | {Name: "file", Godoc: "file name if specified on the command line ('file')", Kind: reflect.String}, 22 | 23 | {Name: "inodes", Godoc: "total number of inodes ('itotal')", Kind: reflect.Int64}, 24 | {Name: "ifree", Godoc: "number of available inodes ('iavail')", Kind: reflect.Int64}, 25 | {Name: "iused", Godoc: "number of used inodes ('iused')", Kind: reflect.Int64}, 26 | {Name: "iused-percent", Godoc: "percentage of iused divided by itotal ('ipcent')", Kind: reflect.String}, 27 | 28 | {Name: "total-blocks", Godoc: "total number of 1K-blocks ('size')", Kind: reflect.Int64}, 29 | {Name: "available-blocks", Godoc: "number of available 1K-blocks ('avail')", Kind: reflect.Int64}, 30 | {Name: "used-blocks", Godoc: "number of used 1K-blocks ('used')", Kind: reflect.Int64}, 31 | {Name: "used-blocks-percent", Godoc: "percentage of used-blocks divided by total-blocks ('pcent')", Kind: reflect.String}, 32 | }, 33 | ColumnsToParse: map[string]schema.RawDataType{ 34 | "total-blocks": schema.TypeBytes, 35 | "available-blocks": schema.TypeBytes, 36 | "used-blocks": schema.TypeBytes, 37 | }, 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: sec, Nsec: nsec} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: sec, Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = sec 29 | tv.Usec = usec 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func setTimespec(sec, nsec int64) Timespec { 13 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 14 | } 15 | 16 | func setTimeval(sec, usec int64) Timeval { 17 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 18 | } 19 | 20 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 21 | func Gettimeofday(tv *Timeval) (err error) { 22 | // The tv passed to gettimeofday must be non-nil 23 | // but is otherwise unused. The answers come back 24 | // in the two registers. 25 | sec, usec, err := gettimeofday(tv) 26 | tv.Sec = int32(sec) 27 | tv.Usec = int32(usec) 28 | return err 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var length = uint64(count) 51 | 52 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 53 | 54 | written = int(length) 55 | 56 | if e1 != 0 { 57 | err = e1 58 | } 59 | return 60 | } 61 | 62 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 63 | 64 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 65 | // of darwin/arm the syscall is called sysctl instead of __sysctl. 66 | const SYS___SYSCTL = SYS_SYSCTL 67 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func setTimespec(sec, nsec int64) Timespec { 15 | return Timespec{Sec: int32(sec), Nsec: int32(nsec)} 16 | } 17 | 18 | func setTimeval(sec, usec int64) Timeval { 19 | return Timeval{Sec: int32(sec), Usec: int32(usec)} 20 | } 21 | 22 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 23 | func Gettimeofday(tv *Timeval) (err error) { 24 | // The tv passed to gettimeofday must be non-nil 25 | // but is otherwise unused. The answers come back 26 | // in the two registers. 27 | sec, usec, err := gettimeofday(tv) 28 | tv.Sec = int32(sec) 29 | tv.Usec = int32(usec) 30 | return err 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var length = uint64(count) 53 | 54 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 55 | 56 | written = int(length) 57 | 58 | if e1 != 0 { 59 | err = e1 60 | } 61 | return 62 | } 63 | 64 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 65 | 66 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 67 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 68 | const SYS___SYSCTL = SYS_SYSCTL 69 | -------------------------------------------------------------------------------- /cmd/linux-inspect/ss.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/gyuho/linux-inspect/inspect" 8 | 9 | "github.com/fatih/color" 10 | "github.com/spf13/cobra" 11 | ) 12 | 13 | type ssFlags struct { 14 | topExecPath string 15 | limit int 16 | 17 | program string 18 | protocol string 19 | localPort int64 20 | } 21 | 22 | var ( 23 | ssCommand = &cobra.Command{ 24 | Use: "ss", 25 | Short: "Inspects '/proc/net/tcp,tcp6'", 26 | RunE: ssCommandFunc, 27 | } 28 | ssCmdFlag = ssFlags{} 29 | ) 30 | 31 | func init() { 32 | ssCommand.PersistentFlags().StringVarP(&ssCmdFlag.topExecPath, "top-exec", "t", "", "Specify the top command path.") 33 | ssCommand.PersistentFlags().IntVarP(&ssCmdFlag.limit, "limit", "l", 5, "Limit the number results to return.") 34 | 35 | ssCommand.PersistentFlags().StringVarP(&ssCmdFlag.protocol, "protocol", "c", "tcp", "Specify the protocol ('tcp' or 'tcp6').") 36 | ssCommand.PersistentFlags().StringVarP(&ssCmdFlag.program, "program", "s", "", "Specify the program name.") 37 | ssCommand.PersistentFlags().Int64VarP(&ssCmdFlag.localPort, "local-port", "p", -1, "Specify the local port.") 38 | } 39 | 40 | func ssCommandFunc(cmd *cobra.Command, args []string) error { 41 | color.Set(color.FgMagenta) 42 | fmt.Fprintf(os.Stdout, "\n'ss' to inspect '/proc/net/tcp,tcp6'\n\n") 43 | color.Unset() 44 | 45 | topt := inspect.WithTCP() 46 | if ssCmdFlag.protocol == "tcp6" { 47 | topt = inspect.WithTCP6() 48 | } else if ssCmdFlag.protocol != "tcp" { 49 | fmt.Fprintf(os.Stderr, "unknown protocol %q\n", ssCmdFlag.protocol) 50 | os.Exit(233) 51 | } 52 | sss, err := inspect.GetSS( 53 | topt, 54 | inspect.WithTopExecPath(ssCmdFlag.topExecPath), 55 | inspect.WithTopLimit(ssCmdFlag.limit), 56 | inspect.WithProgram(ssCmdFlag.program), 57 | inspect.WithLocalPort(ssCmdFlag.localPort), 58 | ) 59 | if err != nil { 60 | return err 61 | } 62 | hd, rows := inspect.ConvertSS(sss...) 63 | txt := inspect.StringSS(hd, rows, -1) 64 | fmt.Print(txt) 65 | 66 | color.Set(color.FgGreen) 67 | fmt.Fprintf(os.Stdout, "\nDONE!\n") 68 | color.Unset() 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/timestruct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | // TimespecToNsec converts a Timespec value into a number of 10 | // nanoseconds since the Unix epoch. 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | // NsecToTimespec takes a number of nanoseconds since the Unix epoch 14 | // and returns the corresponding Timespec value. 15 | func NsecToTimespec(nsec int64) Timespec { 16 | sec := nsec / 1e9 17 | nsec = nsec % 1e9 18 | if nsec < 0 { 19 | nsec += 1e9 20 | sec-- 21 | } 22 | return setTimespec(sec, nsec) 23 | } 24 | 25 | // TimevalToNsec converts a Timeval value into a number of nanoseconds 26 | // since the Unix epoch. 27 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 28 | 29 | // NsecToTimeval takes a number of nanoseconds since the Unix epoch 30 | // and returns the corresponding Timeval value. 31 | func NsecToTimeval(nsec int64) Timeval { 32 | nsec += 999 // round up to microsecond 33 | usec := nsec % 1e9 / 1e3 34 | sec := nsec / 1e9 35 | if usec < 0 { 36 | usec += 1e6 37 | sec-- 38 | } 39 | return setTimeval(sec, usec) 40 | } 41 | 42 | // Unix returns ts as the number of seconds and nanoseconds elapsed since the 43 | // Unix epoch. 44 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 45 | return int64(ts.Sec), int64(ts.Nsec) 46 | } 47 | 48 | // Unix returns tv as the number of seconds and nanoseconds elapsed since the 49 | // Unix epoch. 50 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 51 | return int64(tv.Sec), int64(tv.Usec) * 1000 52 | } 53 | 54 | // Nano returns ts as the number of nanoseconds elapsed since the Unix epoch. 55 | func (ts *Timespec) Nano() int64 { 56 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 57 | } 58 | 59 | // Nano returns tv as the number of nanoseconds elapsed since the Unix epoch. 60 | func (tv *Timeval) Nano() int64 { 61 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 62 | } 63 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zptrace386_linux.go: -------------------------------------------------------------------------------- 1 | // Code generated by linux/mkall.go generatePtracePair(386, amd64). DO NOT EDIT. 2 | 3 | // +build linux 4 | // +build 386 amd64 5 | 6 | package unix 7 | 8 | import "unsafe" 9 | 10 | // PtraceRegs386 is the registers used by 386 binaries. 11 | type PtraceRegs386 struct { 12 | Ebx int32 13 | Ecx int32 14 | Edx int32 15 | Esi int32 16 | Edi int32 17 | Ebp int32 18 | Eax int32 19 | Xds int32 20 | Xes int32 21 | Xfs int32 22 | Xgs int32 23 | Orig_eax int32 24 | Eip int32 25 | Xcs int32 26 | Eflags int32 27 | Esp int32 28 | Xss int32 29 | } 30 | 31 | // PtraceGetRegs386 fetches the registers used by 386 binaries. 32 | func PtraceGetRegs386(pid int, regsout *PtraceRegs386) error { 33 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 34 | } 35 | 36 | // PtraceSetRegs386 sets the registers used by 386 binaries. 37 | func PtraceSetRegs386(pid int, regs *PtraceRegs386) error { 38 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 39 | } 40 | 41 | // PtraceRegsAmd64 is the registers used by amd64 binaries. 42 | type PtraceRegsAmd64 struct { 43 | R15 uint64 44 | R14 uint64 45 | R13 uint64 46 | R12 uint64 47 | Rbp uint64 48 | Rbx uint64 49 | R11 uint64 50 | R10 uint64 51 | R9 uint64 52 | R8 uint64 53 | Rax uint64 54 | Rcx uint64 55 | Rdx uint64 56 | Rsi uint64 57 | Rdi uint64 58 | Orig_rax uint64 59 | Rip uint64 60 | Cs uint64 61 | Eflags uint64 62 | Rsp uint64 63 | Ss uint64 64 | Fs_base uint64 65 | Gs_base uint64 66 | Ds uint64 67 | Es uint64 68 | Fs uint64 69 | Gs uint64 70 | } 71 | 72 | // PtraceGetRegsAmd64 fetches the registers used by amd64 binaries. 73 | func PtraceGetRegsAmd64(pid int, regsout *PtraceRegsAmd64) error { 74 | return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) 75 | } 76 | 77 | // PtraceSetRegsAmd64 sets the registers used by amd64 binaries. 78 | func PtraceSetRegsAmd64(pid int, regs *PtraceRegsAmd64) error { 79 | return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) 80 | } 81 | --------------------------------------------------------------------------------