Migrate to go 1.11 modules

This commit is contained in:
Caleb Bassi 2018-09-18 12:05:40 -07:00
parent 5b5ccfc2f5
commit bb36706e86
46 changed files with 71 additions and 1643 deletions

112
Gopkg.lock generated
View File

@ -1,112 +0,0 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
digest = "1:e92f5581902c345eb4ceffdcd4a854fb8f73cf436d47d837d1ec98ef1fe0a214"
name = "github.com/StackExchange/wmi"
packages = ["."]
pruneopts = "UT"
revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338"
version = "1.0.0"
[[projects]]
branch = "master"
digest = "1:850651510b171e8b3ebf5177ed0e58c33cacda59d98f073a9893c812f335e6c2"
name = "github.com/cjbassi/drawille-go"
packages = ["."]
pruneopts = "UT"
revision = "ad535d0f92cd951308cdb80675e05c62c6b8b296"
[[projects]]
branch = "master"
digest = "1:cab6e0b0389cc0c280a46f57e37346a1ee7266a70763077a0f75e4ee54f964ba"
name = "github.com/cjbassi/termui"
packages = ["."]
pruneopts = "UT"
revision = "5edfcb3a441fd26a4a9491f220476caf3fe61020"
[[projects]]
branch = "master"
digest = "1:289fa52f4d9e9c817a003324bc14e9339b996dbe02b9f6cfc57a9383e5365287"
name = "github.com/docopt/docopt-go"
packages = ["."]
pruneopts = "UT"
revision = "ee0de3bc6815ee19d4a46c7eb90f829db0e014b1"
[[projects]]
digest = "1:64a5a67c69b70c2420e607a8545d674a23778ed9c3e80607bfd17b77c6c87f6a"
name = "github.com/go-ole/go-ole"
packages = [
".",
"oleutil",
]
pruneopts = "UT"
revision = "a41e3c4b706f6ae8dfbff342b06e40fa4d2d0506"
version = "v1.2.1"
[[projects]]
digest = "1:e2d1d410fb367567c2b53ed9e2d719d3c1f0891397bb2fa49afd747cfbf1e8e4"
name = "github.com/mattn/go-runewidth"
packages = ["."]
pruneopts = "UT"
revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
version = "v0.0.2"
[[projects]]
branch = "master"
digest = "1:c986a0cc791e523b3304cd2ba2ade1f18f6232d42a4f8503f9cb74c487a98a01"
name = "github.com/nsf/termbox-go"
packages = ["."]
pruneopts = "UT"
revision = "3e24a7b6661e09b87a9f49d693034219f81602fa"
[[projects]]
branch = "master"
digest = "1:f70f984dee39da9cebae65e4ae6dc69f7ee93dc2285ecef7c07eed84d9172f95"
name = "github.com/shirou/gopsutil"
packages = [
"cpu",
"disk",
"host",
"internal/common",
"mem",
"net",
"process",
]
pruneopts = "T"
revision = "68ff0e299699630e174f9afaebb4b8c99d0520dc"
[[projects]]
branch = "master"
digest = "1:99c6a6dab47067c9b898e8c8b13d130c6ab4ffbcc4b7cc6236c2cd0b1e344f5b"
name = "github.com/shirou/w32"
packages = ["."]
pruneopts = "UT"
revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b"
[[projects]]
branch = "master"
digest = "1:4eb196f937ca6319f4095e0373b346aeeb4e3377e0200e7bb51daac0b5ec964c"
name = "golang.org/x/sys"
packages = [
"unix",
"windows",
]
pruneopts = "UT"
revision = "3b87a42e500a6dc65dae1a55d0b641295971163e"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
input-imports = [
"github.com/cjbassi/termui",
"github.com/docopt/docopt-go",
"github.com/shirou/gopsutil/cpu",
"github.com/shirou/gopsutil/disk",
"github.com/shirou/gopsutil/host",
"github.com/shirou/gopsutil/mem",
"github.com/shirou/gopsutil/net",
"github.com/shirou/gopsutil/process",
]
solver-name = "gps-cdcl"
solver-version = 1

View File

@ -1,19 +0,0 @@
[[constraint]]
name = "github.com/cjbassi/termui"
branch = "master"
[[constraint]]
name = "github.com/docopt/docopt-go"
branch = "master"
[[constraint]]
name = "github.com/shirou/gopsutil"
branch = "master"
[prune]
go-tests = true
unused-packages = true
[[prune.project]]
name = "github.com/shirou/gopsutil"
unused-packages = false

17
go.mod Normal file
View File

@ -0,0 +1,17 @@
module github.com/cjbassi/gotop
require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd // indirect
github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/mattn/go-runewidth v0.0.2 // indirect
github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 // indirect
github.com/stretchr/testify v1.2.2 // indirect
golang.org/x/sys v0.0.0-20180406135729-3b87a42e500a // indirect
)

26
go.sum Normal file
View File

@ -0,0 +1,26 @@
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd h1:nSJpATLVvFa19BEHX4ys+VGNWfI4FUGMweEI6QXs8wg=
github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd/go.mod h1:vjcQJUZJYD3MeVGhtZXSMnCHfUNZxsyYzJt90eCYxK4=
github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f h1:t8d9FIPBeDHClPJBkB8yJyIBcMIxzdMAY2xB1vWHi48=
github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f/go.mod h1:rqXckrwz+i0fH/zNwU6AdBNULHwmZsgehnSlhKP5i2Q=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/mattn/go-runewidth v0.0.2 h1:UnlwIPBGaTZfPQ6T1IGzPI0EkYAQmT9fAEJ/poFC63o=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e h1:w2JDz0jtOlFFdvtUXISyYPFwmbZnwKL1mRDT0tKDvuk=
github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e/go.mod h1:IuKpRQcYE1Tfu+oAQqaLisqDeXgjyyltCfsaoYN18NQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699 h1:AJW3z3AIDXJBKlPs1bhA0pb0rYKyTv+rzHE/spMC72Y=
github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+DfgoHVedieIzIXE8uylPue0U=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20180406135729-3b87a42e500a h1:DwI0ihryIiWlRUKL/ii7Snvn4LiL9TvMoVZq3qMbffg=
golang.org/x/sys v0.0.0-20180406135729-3b87a42e500a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

0
vendor/github.com/nsf/termbox-go/collect_terminfo.py generated vendored Executable file → Normal file
View File

View File

@ -1,5 +0,0 @@
*~
#*
_obj
*.tmp
.idea

View File

@ -1,33 +0,0 @@
.PHONY: help check
.DEFAULT_GOAL := help
SUBPKGS=cpu disk docker host internal load mem net process
help: ## Show help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
check: ## Check
errcheck -ignore="Close|Run|Write" ./...
golint ./... | egrep -v 'underscores|HttpOnly|should have comment|comment on exported|CamelCase|VM|UID' && exit 1 || exit 0
BUILD_FAIL_PATTERN=grep -v "exec format error" | grep "build failed" && exit 1 || exit 0
build_test: ## test only buildable
# Supported operating systems
GOOS=linux GOARCH=amd64 go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=linux GOARCH=386 go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=linux GOARCH=arm go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=linux GOARCH=arm64 go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=freebsd go test ./... | $(BUILD_FAIL_PATTERN)
CGO_ENABLED=0 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=windows go test ./... | $(BUILD_FAIL_PATTERN)
# Operating systems supported for building only (not implemented error if used)
GOOS=solaris go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=dragonfly go test ./... | $(BUILD_FAIL_PATTERN)
GOOS=netbsd go test ./... | $(BUILD_FAIL_PATTERN)
# cross build to OpenBSD not worked since process has "C"
# GOOS=openbsd go test ./... | $(BUILD_FAIL_PATTERN)
ifeq ($(shell uname -s), Darwin)
CGO_ENABLED=1 GOOS=darwin go test ./... | $(BUILD_FAIL_PATTERN)
endif
@echo 'Successfully built on all known operating systems'

View File

@ -1,322 +0,0 @@
gopsutil: psutil for golang
==============================
.. image:: https://circleci.com/gh/shirou/gopsutil.svg?&style=shield
:target: https://circleci.com/gh/shirou/gopsutil
.. image:: https://coveralls.io/repos/shirou/gopsutil/badge.svg?branch=master
:target: https://coveralls.io/r/shirou/gopsutil?branch=master
.. image:: https://godoc.org/github.com/shirou/gopsutil?status.svg
:target: http://godoc.org/github.com/shirou/gopsutil
This is a port of psutil (https://github.com/giampaolo/psutil). The challenge is porting all
psutil functions on some architectures.
Breaking Changes! golang 1.8 is required
-------------------------------------------
After v2.17.04, golang 1.8 is required to build.
Tag semantics
-------------------------
gopsutil tag policy is almost same as Semantic Versioning, but automatically increase like Ubuntu versioning.
for example, `v2.17.04` means
- v2: major version
- 17: release year, 2017
- 04: release month
gopsutil aims to keep backwards-compatiblity until major version change.
Taged at every end of month, but there are only a few commits, it can be skipped.
Available Architectures
------------------------------------
- FreeBSD i386/amd64/arm
- Linux i386/amd64/arm(raspberry pi)
- Windows/amd64
- Darwin i386/amd64
- OpenBSD amd64 (Thank you @mpfz0r!)
- Solaris amd64 (developed and tested on SmartOS/Illumos, Thank you @jen20!)
All works are implemented without cgo by porting c struct to golang struct.
Usage
---------
Note: gopsutil v2 breaks compatibility. If you want to stay with compatibility, please use v1 branch and vendoring.
.. code:: go
package main
import (
"fmt"
"github.com/shirou/gopsutil/mem"
)
func main() {
v, _ := mem.VirtualMemory()
// almost every return value is a struct
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
// convert to JSON. String() is also implemented
fmt.Println(v)
}
The output is below.
::
Total: 3179569152, Free:284233728, UsedPercent:84.508194%
{"total":3179569152,"available":492572672,"used":2895335424,"usedPercent":84.50819439828305, (snip...)}
You can set an alternative location to :code:`/proc` by setting the :code:`HOST_PROC` environment variable.
You can set an alternative location to :code:`/sys` by setting the :code:`HOST_SYS` environment variable.
You can set an alternative location to :code:`/etc` by setting the :code:`HOST_ETC` environment variable.
You can set an alternative location to :code:`/var` by setting the :code:`HOST_VAR` environment variable.
Documentation
------------------------
see http://godoc.org/github.com/shirou/gopsutil
Requirements
-----------------
- go1.7 or above is required.
More Info
--------------------
Several methods have been added which are not present in psutil, but will provide useful information.
- host/HostInfo() (linux)
- Hostname
- Uptime
- Procs
- OS (ex: "linux")
- Platform (ex: "ubuntu", "arch")
- PlatformFamily (ex: "debian")
- PlatformVersion (ex: "Ubuntu 13.10")
- VirtualizationSystem (ex: "LXC")
- VirtualizationRole (ex: "guest"/"host")
- IOCounters
- Label (linux only) The registered `device mapper name <https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm>`_
- cpu/CPUInfo() (linux, freebsd)
- CPU (ex: 0, 1, ...)
- VendorID (ex: "GenuineIntel")
- Family
- Model
- Stepping
- PhysicalID
- CoreID
- Cores (ex: 2)
- ModelName (ex: "Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz")
- Mhz
- CacheSize
- Flags (ex: "fpu vme de pse tsc msr pae mce cx8 ...")
- Microcode
- load/LoadAvg() (linux, freebsd)
- Load1
- Load5
- Load15
- docker/GetDockerIDList() (linux only)
- container id list ([]string)
- docker/CgroupCPU() (linux only)
- user
- system
- docker/CgroupMem() (linux only)
- various status
- net_protocols (linux only)
- system wide stats on network protocols (i.e IP, TCP, UDP, etc.)
- sourced from /proc/net/snmp
- iptables nf_conntrack (linux only)
- system wide stats on netfilter conntrack module
- sourced from /proc/sys/net/netfilter/nf_conntrack_count
Some codes are ported from Ohai. many thanks.
Current Status
------------------
- x: work
- b: almost works, but something is broken
=================== ====== ======= ======= ====== ======= =======
name Linux FreeBSD OpenBSD MacOSX Windows Solaris
cpu_times x x x x x
cpu_count x x x x x
cpu_percent x x x x x
cpu_times_percent x x x x x
virtual_memory x x x x x b
swap_memory x x x x
disk_partitions x x x x x
disk_io_counters x x x
disk_usage x x x x x
net_io_counters x x x b x
boot_time x x x x x
users x x x x x
pids x x x x x
pid_exists x x x x x
net_connections x x x
net_protocols x
net_if_addrs
net_if_stats
netfilter_conntrack x
=================== ====== ======= ======= ====== =======
Process class
^^^^^^^^^^^^^^^
================ ===== ======= ======= ====== =======
name Linux FreeBSD OpenBSD MacOSX Windows
pid x x x x x
ppid x x x x x
name x x x x x
cmdline x x x x
create_time x x
status x x x x
cwd x
exe x x x x
uids x x x x
gids x x x x
terminal x x x x
io_counters x x x x
nice x x x x x
num_fds x
num_ctx_switches x
num_threads x x x x x
cpu_times x x
memory_info x x x x x
memory_info_ex x
memory_maps x
open_files x
send_signal x x x x
suspend x x x x
resume x x x x
terminate x x x x x
kill x x x x
username x x x x x
ionice
rlimit x
num_handlers
threads x
cpu_percent x x x
cpu_affinity
memory_percent
parent x x x x
children x x x x x
connections x x x
is_running
================ ===== ======= ======= ====== =======
Original Metrics
^^^^^^^^^^^^^^^^^^^
================== ===== ======= ======= ====== ======= =======
item Linux FreeBSD OpenBSD MacOSX Windows Solaris
**HostInfo**
hostname x x x x x x
uptime x x x x x
proces x x x x
os x x x x x x
platform x x x x x
platformfamily x x x x x
virtualization x
**CPU**
VendorID x x x x x x
Family x x x x x x
Model x x x x x x
Stepping x x x x x x
PhysicalID x x
CoreID x x
Cores x x x
ModelName x x x x x x
Microcode x x
**LoadAvg**
Load1 x x x x
Load5 x x x x
Load15 x x x x
**GetDockerID**
container id x no no no no
**CgroupsCPU**
user x no no no no
system x no no no no
**CgroupsMem**
various x no no no no
================== ===== ======= ======= ====== ======= =======
- future work
- process_iter
- wait_procs
- Process class
- as_dict
- wait
License
------------
New BSD License (same as psutil)
Related Works
-----------------------
I have been influenced by the following great works:
- psutil: https://github.com/giampaolo/psutil
- dstat: https://github.com/dagwieers/dstat
- gosigar: https://github.com/cloudfoundry/gosigar/
- goprocinfo: https://github.com/c9s/goprocinfo
- go-ps: https://github.com/mitchellh/go-ps
- ohai: https://github.com/opscode/ohai/
- bosun: https://github.com/bosun-monitor/bosun/tree/master/cmd/scollector/collectors
- mackerel: https://github.com/mackerelio/mackerel-agent/tree/master/metrics
How to Contribute
---------------------------
1. Fork it
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create new Pull Request
My English is terrible, so documentation or correcting comments are also
welcome.

View File

@ -1,13 +0,0 @@
machine:
timezone:
Asia/Tokyo
pre:
- sudo chown -R ubuntu:ubuntu /usr/local/go/pkg/
test:
override:
- GOOS=linux GOARCH=amd64 go test -v ./...
- GOOS=linux GOARCH=386 go get -v ./...
- GOOS=linux GOARCH=arm GOARM=7 go get -v ./...
- GOOS=freebsd GOARCH=amd64 go get -v ./...
- GOOS=windows GOARCH=amd64 go get -v ./...
- GOOS=darwin GOARCH=amd64 go get -v ./...

View File

@ -1,26 +0,0 @@
#/bin/sh
# see http://www.songmu.jp/riji/entry/2015-01-15-goveralls-multi-package.html
set -e
# cleanup
cleanup() {
if [ $tmpprof != "" ] && [ -f $tmpprof ]; then
rm -f $tmpprof
fi
exit
}
trap cleanup INT QUIT TERM EXIT
# メインの処理
prof=${1:-".profile.cov"}
echo "mode: count" > $prof
gopath1=$(echo $GOPATH | cut -d: -f1)
for pkg in $(go list ./...); do
tmpprof=$gopath1/src/$pkg/profile.tmp
go test -covermode=count -coverprofile=$tmpprof $pkg
if [ -f $tmpprof ]; then
cat $tmpprof | tail -n +2 >> $prof
rm $tmpprof
fi
done

View File

@ -1,43 +0,0 @@
Copyright (c) 1992-2016 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 11.0-RELEASE-p2 #0: Mon Oct 24 06:55:27 UTC 2016
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0)
VT(vga): resolution 640x480
CPU: Intel(R) Core(TM) i3 CPU 550 @ 3.20GHz (3192.07-MHz K8-class CPU)
Origin="GenuineIntel" Id=0x20655 Family=0x6 Model=0x25 Stepping=5
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
Features2=0x9ae3bd<SSE3,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,POPCNT>
AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>
AMD Features2=0x1<LAHF>
VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
TSC: P-state invariant, performance statistics
real memory = 8589934592 (8192 MB)
avail memory = 8046452736 (7673 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <INTEL DH55HC >
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s) x 2 hardware threads
random: unblocking device.
ioapic0 <Version 2.0> irqs 0-23 on motherboard
random: entropy device external interface
kbd1 at kbdmux0
netmap: loaded module
module_register_init: MOD_LOAD (vesa, 0xffffffff8101c970, 0) error 19
vtvga0: <VT VGA driver> on motherboard
cryptosoft0: <software crypto> on motherboard
aesni0: No AESNI support.
acpi0: <INTEL DH55HC> on motherboard
acpi0: Power Button (fixed)
cpu0: <ACPI CPU> on acpi0
ACPI BIOS Warning (bug): Incorrect checksum in table [SSDT] - 0x3F, should be 0x1F (20160527/tbprint-229)
cpu1: <ACPI CPU> on acpi0
cpu2: <ACPI CPU> on acpi0
cpu3: <ACPI CPU> on acpi0
attimer0: <AT timer> port 0x40-0x43 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
atrtc0: <AT realtime clock> port 0x70-0x71 irq 8 on acpi0
Event timer "RTC" frequency 32768 Hz quality 0

View File

@ -1,38 +0,0 @@
Copyright (c) 1992-2016 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 10.3-RELEASE-p4 #0: Sat May 28 12:23:44 UTC 2016
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
CPU: Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz (3700.09-MHz K8-class CPU)
Origin="GenuineIntel" Id=0x306e4 Family=0x6 Model=0x3e Stepping=4
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
Features2=0x7fbee3ff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,PCID,DCA,SSE4.1,SSE4.2,x2APIC,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
AMD Features2=0x1<LAHF>
Structured Extended Features=0x281<FSGSBASE,SMEP,ERMS>
XSAVE Features=0x1<XSAVEOPT>
VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr
TSC: P-state invariant, performance statistics
real memory = 34368126976 (32776 MB)
avail memory = 33228333056 (31689 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: < >
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 SMT threads
cpu0 (BSP): APIC ID: 0
cpu1 (AP): APIC ID: 1
cpu2 (AP): APIC ID: 2
cpu3 (AP): APIC ID: 3
cpu4 (AP): APIC ID: 4
cpu5 (AP): APIC ID: 5
cpu6 (AP): APIC ID: 6
cpu7 (AP): APIC ID: 7
random: <Software, Yarrow> initialized
ioapic0 <Version 2.0> irqs 0-23 on motherboard
ioapic1 <Version 2.0> irqs 24-47 on motherboard
kbd1 at kbdmux0
cryptosoft0: <software crypto> on motherboard
aesni0: <AES-CBC,AES-XTS> on motherboard
acpi0: <SUPERM SMCI--MB> on motherboard

View File

@ -1,45 +0,0 @@
Copyright (c) 1992-2011 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 8.2-RELEASE #1: Sat Mar 5 23:03:14 CET 2011
root@host1:/usr/obj/usr/src/sys/MYKERNEL amd64
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Xeon(R) CPU E5420 @ 2.50GHz (2500.11-MHz K8-class CPU)
Origin = "GenuineIntel" Id = 0x10676 Family = 6 Model = 17 Stepping = 6
Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
Features2=0xce3bd<SSE3,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,CX16,xTPR,PDCM,DCA,SSE4.1>
AMD Features=0x20100800<SYSCALL,NX,LM>
AMD Features2=0x1<LAHF>
TSC: P-state invariant
real memory = 17179869184 (16384 MB)
avail memory = 16531587072 (15765 MB)
ACPI APIC Table: <PTLTD APIC >
FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
FreeBSD/SMP: 2 package(s) x 4 core(s)
cpu0 (BSP): APIC ID: 0
cpu1 (AP): APIC ID: 1
cpu2 (AP): APIC ID: 2
cpu3 (AP): APIC ID: 3
cpu4 (AP): APIC ID: 4
cpu5 (AP): APIC ID: 5
cpu6 (AP): APIC ID: 6
cpu7 (AP): APIC ID: 7
ioapic0 <Version 2.0> irqs 0-23 on motherboard
ioapic1 <Version 2.0> irqs 24-47 on motherboard
kbd1 at kbdmux0
acpi0: <PTLTD XSDT> on motherboard
acpi0: [ITHREAD]
acpi0: Power Button (fixed)
unknown: I/O range not supported
Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
cpu2: <ACPI CPU> on acpi0
cpu3: <ACPI CPU> on acpi0
cpu4: <ACPI CPU> on acpi0
cpu5: <ACPI CPU> on acpi0
cpu6: <ACPI CPU> on acpi0
cpu7: <ACPI CPU> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0

View File

@ -1,12 +0,0 @@
cpu 23644 6695 4764 134931750 22115 0 473 5892 0 0
cpu0 6418 888 1230 33730755 5043 0 4 1046 0 0
cpu1 6858 4870 1632 33716510 12327 0 235 1765 0 0
cpu2 4859 622 915 33742072 2312 0 25 1546 0 0
cpu3 5507 314 986 33742411 2432 0 208 1534 0 0
intr 32552791 35 9 0 0 2335 0 3 0 2 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3107077 2985327 15704 0 6672 0 3218027 3063711 11558 0 6151 0 2160633 2194945 15838 0 6565 0 1595129 2134446 15337 0 5715 0 157 112837 717318 710764 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ctxt 41317767
btime 1505515383
processes 41562
procs_running 1
procs_blocked 0
softirq 5433315 0 1644387 67542 1428221 0 0 12270 1573783 0 707112

View File

@ -1,4 +0,0 @@
64-bit amd64 applications
rdseed adx avx2 fma bmi2 bmi1 rdrand f16c vmx avx xsave pclmulqdq
aes movbe sse4.2 sse4.1 ssse3 popcnt tscp cx16 sse3 sse2 sse fxsr
mmx cmov amd_sysc cx8 tsc fpu

View File

@ -1,3 +0,0 @@
The physical processor has 1 virtual processor (0)
x86 (GenuineIntel 406E3 family 6 model 78 step 3 clock 3312 MHz)
Intel(r) Core(tm) i7-6567U CPU @ 3.30GHz

View File

@ -1,4 +0,0 @@
64-bit amd64 applications
rdseed adx avx2 fma bmi2 bmi1 rdrand f16c vmx avx xsave pclmulqdq
aes movbe sse4.2 sse4.1 ssse3 popcnt tscp cx16 sse3 sse2 sse fxsr
mmx cmov amd_sysc cx8 tsc fpu

View File

@ -1,6 +0,0 @@
The physical processor has 1 virtual processor (0)
x86 (GenuineIntel 406E3 family 6 model 78 step 3 clock 3312 MHz)
Intel(r) Core(tm) i7-6567U CPU @ 3.30GHz
The physical processor has 1 virtual processor (1)
x86 (GenuineIntel 406E3 family 6 model 78 step 3 clock 3312 MHz)
Intel(r) Core(tm) i7-6567U CPU @ 3.30GHz

View File

@ -1,3 +0,0 @@
64-bit amd64 applications
vmx avx xsave pclmulqdq aes sse4.2 sse4.1 ssse3 popcnt tscp cx16
sse3 sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu

View File

@ -1,22 +0,0 @@
The physical processor has 8 cores and 16 virtual processors (0-7 16-23)
The core has 2 virtual processors (0 16)
The core has 2 virtual processors (1 17)
The core has 2 virtual processors (2 18)
The core has 2 virtual processors (3 19)
The core has 2 virtual processors (4 20)
The core has 2 virtual processors (5 21)
The core has 2 virtual processors (6 22)
The core has 2 virtual processors (7 23)
x86 (GenuineIntel 206D7 family 6 model 45 step 7 clock 2600 MHz)
Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz
The physical processor has 8 cores and 16 virtual processors (8-15 24-31)
The core has 2 virtual processors (8 24)
The core has 2 virtual processors (9 25)
The core has 2 virtual processors (10 26)
The core has 2 virtual processors (11 27)
The core has 2 virtual processors (12 28)
The core has 2 virtual processors (13 29)
The core has 2 virtual processors (14 30)
The core has 2 virtual processors (15 31)
x86 (GenuineIntel 206D7 family 6 model 45 step 7 clock 2600 MHz)
Intel(r) Xeon(r) CPU E5-2670 0 @ 2.60GHz

View File

@ -1 +0,0 @@
package gopsutil

View File

@ -1,66 +0,0 @@
package docker
import (
"encoding/json"
"errors"
"github.com/shirou/gopsutil/internal/common"
)
var ErrDockerNotAvailable = errors.New("docker not available")
var ErrCgroupNotAvailable = errors.New("cgroup not available")
var invoke common.Invoker = common.Invoke{}
type CgroupMemStat struct {
ContainerID string `json:"containerID"`
Cache uint64 `json:"cache"`
RSS uint64 `json:"rss"`
RSSHuge uint64 `json:"rssHuge"`
MappedFile uint64 `json:"mappedFile"`
Pgpgin uint64 `json:"pgpgin"`
Pgpgout uint64 `json:"pgpgout"`
Pgfault uint64 `json:"pgfault"`
Pgmajfault uint64 `json:"pgmajfault"`
InactiveAnon uint64 `json:"inactiveAnon"`
ActiveAnon uint64 `json:"activeAnon"`
InactiveFile uint64 `json:"inactiveFile"`
ActiveFile uint64 `json:"activeFile"`
Unevictable uint64 `json:"unevictable"`
HierarchicalMemoryLimit uint64 `json:"hierarchicalMemoryLimit"`
TotalCache uint64 `json:"totalCache"`
TotalRSS uint64 `json:"totalRss"`
TotalRSSHuge uint64 `json:"totalRssHuge"`
TotalMappedFile uint64 `json:"totalMappedFile"`
TotalPgpgIn uint64 `json:"totalPgpgin"`
TotalPgpgOut uint64 `json:"totalPgpgout"`
TotalPgFault uint64 `json:"totalPgfault"`
TotalPgMajFault uint64 `json:"totalPgmajfault"`
TotalInactiveAnon uint64 `json:"totalInactiveAnon"`
TotalActiveAnon uint64 `json:"totalActiveAnon"`
TotalInactiveFile uint64 `json:"totalInactiveFile"`
TotalActiveFile uint64 `json:"totalActiveFile"`
TotalUnevictable uint64 `json:"totalUnevictable"`
MemUsageInBytes uint64 `json:"memUsageInBytes"`
MemMaxUsageInBytes uint64 `json:"memMaxUsageInBytes"`
MemLimitInBytes uint64 `json:"memoryLimitInBbytes"`
MemFailCnt uint64 `json:"memoryFailcnt"`
}
func (m CgroupMemStat) String() string {
s, _ := json.Marshal(m)
return string(s)
}
type CgroupDockerStat struct {
ContainerID string `json:"containerID"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
Running bool `json:"running"`
}
func (c CgroupDockerStat) String() string {
s, _ := json.Marshal(c)
return string(s)
}

View File

@ -1,268 +0,0 @@
// +build linux
package docker
import (
"context"
"fmt"
"os"
"os/exec"
"path"
"strconv"
"strings"
cpu "github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/internal/common"
)
// GetDockerStat returns a list of Docker basic stats.
// This requires certain permission.
func GetDockerStat() ([]CgroupDockerStat, error) {
return GetDockerStatWithContext(context.Background())
}
func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
path, err := exec.LookPath("docker")
if err != nil {
return nil, ErrDockerNotAvailable
}
out, err := invoke.CommandWithContext(ctx, path, "ps", "-a", "--no-trunc", "--format", "{{.ID}}|{{.Image}}|{{.Names}}|{{.Status}}")
if err != nil {
return []CgroupDockerStat{}, err
}
lines := strings.Split(string(out), "\n")
ret := make([]CgroupDockerStat, 0, len(lines))
for _, l := range lines {
if l == "" {
continue
}
cols := strings.Split(l, "|")
if len(cols) != 4 {
continue
}
names := strings.Split(cols[2], ",")
stat := CgroupDockerStat{
ContainerID: cols[0],
Name: names[0],
Image: cols[1],
Status: cols[3],
Running: strings.Contains(cols[3], "Up"),
}
ret = append(ret, stat)
}
return ret, nil
}
// GetDockerIDList returnes a list of DockerID.
// This requires certain permission.
func GetDockerIDList() ([]string, error) {
return GetDockerIDListWithContext(context.Background())
}
func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
path, err := exec.LookPath("docker")
if err != nil {
return nil, ErrDockerNotAvailable
}
out, err := invoke.CommandWithContext(ctx, path, "ps", "-q", "--no-trunc")
if err != nil {
return []string{}, err
}
lines := strings.Split(string(out), "\n")
ret := make([]string, 0, len(lines))
for _, l := range lines {
if l == "" {
continue
}
ret = append(ret, l)
}
return ret, nil
}
// CgroupCPU returnes specified cgroup id CPU status.
// containerID is same as docker id if you use docker.
// If you use container via systemd.slice, you could use
// containerID = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
func CgroupCPU(containerID string, base string) (*cpu.TimesStat, error) {
return CgroupCPUWithContext(context.Background(), containerID, base)
}
func CgroupCPUWithContext(ctx context.Context, containerID string, base string) (*cpu.TimesStat, error) {
statfile := getCgroupFilePath(containerID, base, "cpuacct", "cpuacct.stat")
lines, err := common.ReadLines(statfile)
if err != nil {
return nil, err
}
// empty containerID means all cgroup
if len(containerID) == 0 {
containerID = "all"
}
ret := &cpu.TimesStat{CPU: containerID}
for _, line := range lines {
fields := strings.Split(line, " ")
if fields[0] == "user" {
user, err := strconv.ParseFloat(fields[1], 64)
if err == nil {
ret.User = float64(user)
}
}
if fields[0] == "system" {
system, err := strconv.ParseFloat(fields[1], 64)
if err == nil {
ret.System = float64(system)
}
}
}
return ret, nil
}
func CgroupCPUDocker(containerid string) (*cpu.TimesStat, error) {
return CgroupCPUDockerWithContext(context.Background(), containerid)
}
func CgroupCPUDockerWithContext(ctx context.Context, containerid string) (*cpu.TimesStat, error) {
return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker"))
}
func CgroupMem(containerID string, base string) (*CgroupMemStat, error) {
return CgroupMemWithContext(context.Background(), containerID, base)
}
func CgroupMemWithContext(ctx context.Context, containerID string, base string) (*CgroupMemStat, error) {
statfile := getCgroupFilePath(containerID, base, "memory", "memory.stat")
// empty containerID means all cgroup
if len(containerID) == 0 {
containerID = "all"
}
lines, err := common.ReadLines(statfile)
if err != nil {
return nil, err
}
ret := &CgroupMemStat{ContainerID: containerID}
for _, line := range lines {
fields := strings.Split(line, " ")
v, err := strconv.ParseUint(fields[1], 10, 64)
if err != nil {
continue
}
switch fields[0] {
case "cache":
ret.Cache = v
case "rss":
ret.RSS = v
case "rssHuge":
ret.RSSHuge = v
case "mappedFile":
ret.MappedFile = v
case "pgpgin":
ret.Pgpgin = v
case "pgpgout":
ret.Pgpgout = v
case "pgfault":
ret.Pgfault = v
case "pgmajfault":
ret.Pgmajfault = v
case "inactiveAnon":
ret.InactiveAnon = v
case "activeAnon":
ret.ActiveAnon = v
case "inactiveFile":
ret.InactiveFile = v
case "activeFile":
ret.ActiveFile = v
case "unevictable":
ret.Unevictable = v
case "hierarchicalMemoryLimit":
ret.HierarchicalMemoryLimit = v
case "totalCache":
ret.TotalCache = v
case "totalRss":
ret.TotalRSS = v
case "totalRssHuge":
ret.TotalRSSHuge = v
case "totalMappedFile":
ret.TotalMappedFile = v
case "totalPgpgin":
ret.TotalPgpgIn = v
case "totalPgpgout":
ret.TotalPgpgOut = v
case "totalPgfault":
ret.TotalPgFault = v
case "totalPgmajfault":
ret.TotalPgMajFault = v
case "totalInactiveAnon":
ret.TotalInactiveAnon = v
case "totalActiveAnon":
ret.TotalActiveAnon = v
case "totalInactiveFile":
ret.TotalInactiveFile = v
case "totalActiveFile":
ret.TotalActiveFile = v
case "totalUnevictable":
ret.TotalUnevictable = v
}
}
r, err := getCgroupMemFile(containerID, base, "memory.usage_in_bytes")
if err == nil {
ret.MemUsageInBytes = r
}
r, err = getCgroupMemFile(containerID, base, "memory.max_usage_in_bytes")
if err == nil {
ret.MemMaxUsageInBytes = r
}
r, err = getCgroupMemFile(containerID, base, "memoryLimitInBbytes")
if err == nil {
ret.MemLimitInBytes = r
}
r, err = getCgroupMemFile(containerID, base, "memoryFailcnt")
if err == nil {
ret.MemFailCnt = r
}
return ret, nil
}
func CgroupMemDocker(containerID string) (*CgroupMemStat, error) {
return CgroupMemDockerWithContext(context.Background(), containerID)
}
func CgroupMemDockerWithContext(ctx context.Context, containerID string) (*CgroupMemStat, error) {
return CgroupMem(containerID, common.HostSys("fs/cgroup/memory/docker"))
}
// getCgroupFilePath constructs file path to get targetted stats file.
func getCgroupFilePath(containerID, base, target, file string) string {
if len(base) == 0 {
base = common.HostSys(fmt.Sprintf("fs/cgroup/%s/docker", target))
}
statfile := path.Join(base, containerID, file)
if _, err := os.Stat(statfile); os.IsNotExist(err) {
statfile = path.Join(
common.HostSys(fmt.Sprintf("fs/cgroup/%s/system.slice", target)), "docker-"+containerID+".scope", file)
}
return statfile
}
// getCgroupMemFile reads a cgroup file and return the contents as uint64.
func getCgroupMemFile(containerID, base, file string) (uint64, error) {
statfile := getCgroupFilePath(containerID, base, "memory", file)
lines, err := common.ReadLines(statfile)
if err != nil {
return 0, err
}
if len(lines) != 1 {
return 0, fmt.Errorf("wrong format file: %s", statfile)
}
return strconv.ParseUint(lines[0], 10, 64)
}

View File

@ -1,65 +0,0 @@
// +build !linux
package docker
import (
"context"
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/internal/common"
)
// GetDockerStat returns a list of Docker basic stats.
// This requires certain permission.
func GetDockerStat() ([]CgroupDockerStat, error) {
return GetDockerStatWithContext(context.Background())
}
func GetDockerStatWithContext(ctx context.Context) ([]CgroupDockerStat, error) {
return nil, ErrDockerNotAvailable
}
// GetDockerIDList returnes a list of DockerID.
// This requires certain permission.
func GetDockerIDList() ([]string, error) {
return GetDockerIDListWithContext(context.Background())
}
func GetDockerIDListWithContext(ctx context.Context) ([]string, error) {
return nil, ErrDockerNotAvailable
}
// CgroupCPU returnes specified cgroup id CPU status.
// containerid is same as docker id if you use docker.
// If you use container via systemd.slice, you could use
// containerid = docker-<container id>.scope and base=/sys/fs/cgroup/cpuacct/system.slice/
func CgroupCPU(containerid string, base string) (*cpu.TimesStat, error) {
return CgroupCPUWithContext(context.Background(), containerid, base)
}
func CgroupCPUWithContext(ctx context.Context, containerid string, base string) (*cpu.TimesStat, error) {
return nil, ErrCgroupNotAvailable
}
func CgroupCPUDocker(containerid string) (*cpu.TimesStat, error) {
return CgroupCPUDockerWithContext(context.Background(), containerid)
}
func CgroupCPUDockerWithContext(ctx context.Context, containerid string) (*cpu.TimesStat, error) {
return CgroupCPU(containerid, common.HostSys("fs/cgroup/cpuacct/docker"))
}
func CgroupMem(containerid string, base string) (*CgroupMemStat, error) {
return CgroupMemWithContext(context.Background(), containerid, base)
}
func CgroupMemWithContext(ctx context.Context, containerid string, base string) (*CgroupMemStat, error) {
return nil, ErrCgroupNotAvailable
}
func CgroupMemDocker(containerid string) (*CgroupMemStat, error) {
return CgroupMemDockerWithContext(context.Background(), containerid)
}
func CgroupMemDockerWithContext(ctx context.Context, containerid string) (*CgroupMemStat, error) {
return CgroupMem(containerid, common.HostSys("fs/cgroup/memory/docker"))
}

View File

@ -1,31 +0,0 @@
package load
import (
"encoding/json"
"github.com/shirou/gopsutil/internal/common"
)
var invoke common.Invoker = common.Invoke{}
type AvgStat struct {
Load1 float64 `json:"load1"`
Load5 float64 `json:"load5"`
Load15 float64 `json:"load15"`
}
func (l AvgStat) String() string {
s, _ := json.Marshal(l)
return string(s)
}
type MiscStat struct {
ProcsRunning int `json:"procsRunning"`
ProcsBlocked int `json:"procsBlocked"`
Ctxt int `json:"ctxt"`
}
func (m MiscStat) String() string {
s, _ := json.Marshal(m)
return string(s)
}

View File

@ -1,68 +0,0 @@
// +build freebsd openbsd
package load
import (
"context"
"os/exec"
"strings"
"unsafe"
"golang.org/x/sys/unix"
)
func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}
func AvgWithContext(ctx context.Context) (*AvgStat, error) {
// This SysctlRaw method borrowed from
// https://github.com/prometheus/node_exporter/blob/master/collector/loadavg_freebsd.go
type loadavg struct {
load [3]uint32
scale int
}
b, err := unix.SysctlRaw("vm.loadavg")
if err != nil {
return nil, err
}
load := *(*loadavg)(unsafe.Pointer((&b[0])))
scale := float64(load.scale)
ret := &AvgStat{
Load1: float64(load.load[0]) / scale,
Load5: float64(load.load[1]) / scale,
Load15: float64(load.load[2]) / scale,
}
return ret, nil
}
// Misc returns miscellaneous host-wide statistics.
// darwin use ps command to get process running/blocked count.
// Almost same as Darwin implementation, but state is different.
func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
bin, err := exec.LookPath("ps")
if err != nil {
return nil, err
}
out, err := invoke.CommandWithContext(ctx, bin, "axo", "state")
if err != nil {
return nil, err
}
lines := strings.Split(string(out), "\n")
ret := MiscStat{}
for _, l := range lines {
if strings.Contains(l, "R") {
ret.ProcsRunning++
} else if strings.Contains(l, "D") {
ret.ProcsBlocked++
}
}
return &ret, nil
}

View File

@ -1,76 +0,0 @@
// +build darwin
package load
import (
"context"
"os/exec"
"strconv"
"strings"
"github.com/shirou/gopsutil/internal/common"
)
func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}
func AvgWithContext(ctx context.Context) (*AvgStat, error) {
values, err := common.DoSysctrlWithContext(ctx, "vm.loadavg")
if err != nil {
return nil, err
}
load1, err := strconv.ParseFloat(values[0], 64)
if err != nil {
return nil, err
}
load5, err := strconv.ParseFloat(values[1], 64)
if err != nil {
return nil, err
}
load15, err := strconv.ParseFloat(values[2], 64)
if err != nil {
return nil, err
}
ret := &AvgStat{
Load1: float64(load1),
Load5: float64(load5),
Load15: float64(load15),
}
return ret, nil
}
// Misc returnes miscellaneous host-wide statistics.
// darwin use ps command to get process running/blocked count.
// Almost same as FreeBSD implementation, but state is different.
// U means 'Uninterruptible Sleep'.
func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
bin, err := exec.LookPath("ps")
if err != nil {
return nil, err
}
out, err := invoke.CommandWithContext(ctx, bin, "axo", "state")
if err != nil {
return nil, err
}
lines := strings.Split(string(out), "\n")
ret := MiscStat{}
for _, l := range lines {
if strings.Contains(l, "R") {
ret.ProcsRunning++
} else if strings.Contains(l, "U") {
// uninterruptible sleep == blocked
ret.ProcsBlocked++
}
}
return &ret, nil
}

View File

@ -1,25 +0,0 @@
// +build !darwin,!linux,!freebsd,!openbsd,!windows
package load
import (
"context"
"github.com/shirou/gopsutil/internal/common"
)
func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}
func AvgWithContext(ctx context.Context) (*AvgStat, error) {
return nil, common.ErrNotImplementedError
}
func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
return nil, common.ErrNotImplementedError
}

View File

@ -1,87 +0,0 @@
// +build linux
package load
import (
"context"
"io/ioutil"
"strconv"
"strings"
"github.com/shirou/gopsutil/internal/common"
)
func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}
func AvgWithContext(ctx context.Context) (*AvgStat, error) {
filename := common.HostProc("loadavg")
line, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
values := strings.Fields(string(line))
load1, err := strconv.ParseFloat(values[0], 64)
if err != nil {
return nil, err
}
load5, err := strconv.ParseFloat(values[1], 64)
if err != nil {
return nil, err
}
load15, err := strconv.ParseFloat(values[2], 64)
if err != nil {
return nil, err
}
ret := &AvgStat{
Load1: load1,
Load5: load5,
Load15: load15,
}
return ret, nil
}
// Misc returnes miscellaneous host-wide statistics.
// Note: the name should be changed near future.
func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
filename := common.HostProc("stat")
out, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
ret := &MiscStat{}
lines := strings.Split(string(out), "\n")
for _, line := range lines {
fields := strings.Fields(line)
if len(fields) != 2 {
continue
}
v, err := strconv.ParseInt(fields[1], 10, 64)
if err != nil {
continue
}
switch fields[0] {
case "procs_running":
ret.ProcsRunning = int(v)
case "procs_blocked":
ret.ProcsBlocked = int(v)
case "ctxt":
ret.Ctxt = int(v)
default:
continue
}
}
return ret, nil
}

View File

@ -1,29 +0,0 @@
// +build windows
package load
import (
"context"
"github.com/shirou/gopsutil/internal/common"
)
func Avg() (*AvgStat, error) {
return AvgWithContext(context.Background())
}
func AvgWithContext(ctx context.Context) (*AvgStat, error) {
ret := AvgStat{}
return &ret, common.ErrNotImplementedError
}
func Misc() (*MiscStat, error) {
return MiscWithContext(context.Background())
}
func MiscWithContext(ctx context.Context) (*MiscStat, error) {
ret := MiscStat{}
return &ret, common.ErrNotImplementedError
}

View File

@ -1,37 +0,0 @@
DIRS="cpu disk docker host load mem net process"
GOOS=`uname | tr '[:upper:]' '[:lower:]'`
ARCH=`uname -m`
case $ARCH in
amd64)
GOARCH="amd64"
;;
x86_64)
GOARCH="amd64"
;;
i386)
GOARCH="386"
;;
i686)
GOARCH="386"
;;
arm)
GOARCH="arm"
;;
*)
echo "unknown arch: $ARCH"
exit 1
esac
for DIR in $DIRS
do
if [ -e ${DIR}/types_${GOOS}.go ]; then
echo "// +build $GOOS" > ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
echo "// +build $GOARCH" >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
go tool cgo -godefs ${DIR}/types_${GOOS}.go >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go
fi
done

View File

@ -1,10 +0,0 @@
PID
245
247
248
249
254
262
264
265
267

View File

@ -1,134 +0,0 @@
# This script is a helper of migration to gopsutil v2 using gorename
#
# go get golang.org/x/tools/cmd/gorename
IFS=$'\n'
## Part 1. rename Functions to pass golint. ex) cpu.CPUTimesStat -> cpu.TimesStat
#
# Note:
# process has IOCounters() for file IO, and also NetIOCounters() for Net IO.
# This scripts replace process.NetIOCounters() to IOCounters().
# So you need hand-fixing process.
TARGETS=`cat <<EOF
CPUTimesStat -> TimesStat
CPUInfoStat -> InfoStat
CPUTimes -> Times
CPUInfo -> Info
CPUCounts -> Counts
CPUPercent -> Percent
DiskUsageStat -> UsageStat
DiskPartitionStat -> PartitionStat
DiskIOCountersStat -> IOCountersStat
DiskPartitions -> Partitions
DiskIOCounters -> IOCounters
DiskUsage -> Usage
HostInfoStat -> InfoStat
HostInfo -> Info
GetVirtualization -> Virtualization
GetPlatformInformation -> PlatformInformation
LoadAvgStat -> AvgStat
LoadAvg -> Avg
NetIOCountersStat -> IOCountersStat
NetConnectionStat -> ConnectionStat
NetProtoCountersStat -> ProtoCountersStat
NetInterfaceAddr -> InterfaceAddr
NetInterfaceStat -> InterfaceStat
NetFilterStat -> FilterStat
NetInterfaces -> Interfaces
getNetIOCountersAll -> getIOCountersAll
NetIOCounters -> IOCounters
NetIOCountersByFile -> IOCountersByFile
NetProtoCounters -> ProtoCounters
NetFilterCounters -> FilterCounters
NetConnections -> Connections
NetConnectionsPid -> ConnectionsPid
Uid -> UID
Id -> ID
convertCpuTimes -> convertCPUTimes
EOF`
for T in $TARGETS
do
echo $T
gofmt -w -r "$T" ./*.go
done
###### Part 2 rename JSON key name
## Google JSOn style
## https://google.github.io/styleguide/jsoncstyleguide.xml
sed -i "" 's/guest_nice/guestNice/g' cpu/*.go
sed -i "" 's/vendor_id/vendorId/g' cpu/*.go
sed -i "" 's/physical_id/physicalId/g' cpu/*.go
sed -i "" 's/model_name/modelName/g' cpu/*.go
sed -i "" 's/cache_size/cacheSize/g' cpu/*.go
sed -i "" 's/core_id/coreId/g' cpu/*.go
sed -i "" 's/inodes_total/inodesTotal/g' disk/*.go
sed -i "" 's/inodes_used/inodesUsed/g' disk/*.go
sed -i "" 's/inodes_free/inodesFree/g' disk/*.go
sed -i "" 's/inodes_used_percent/inodesUsedPercent/g' disk/*.go
sed -i "" 's/read_count/readCount/g' disk/*.go
sed -i "" 's/write_count/writeCount/g' disk/*.go
sed -i "" 's/read_bytes/readBytes/g' disk/*.go
sed -i "" 's/write_bytes/writeBytes/g' disk/*.go
sed -i "" 's/read_time/readTime/g' disk/*.go
sed -i "" 's/write_time/writeTime/g' disk/*.go
sed -i "" 's/io_time/ioTime/g' disk/*.go
sed -i "" 's/serial_number/serialNumber/g' disk/*.go
sed -i "" 's/used_percent/usedPercent/g' disk/*.go
sed -i "" 's/inodesUsed_percent/inodesUsedPercent/g' disk/*.go
sed -i "" 's/total_cache/totalCache/g' docker/*.go
sed -i "" 's/total_rss_huge/totalRssHuge/g' docker/*.go
sed -i "" 's/total_rss/totalRss/g' docker/*.go
sed -i "" 's/total_mapped_file/totalMappedFile/g' docker/*.go
sed -i "" 's/total_pgpgin/totalPgpgin/g' docker/*.go
sed -i "" 's/total_pgpgout/totalPgpgout/g' docker/*.go
sed -i "" 's/total_pgfault/totalPgfault/g' docker/*.go
sed -i "" 's/total_pgmajfault/totalPgmajfault/g' docker/*.go
sed -i "" 's/total_inactive_anon/totalInactiveAnon/g' docker/*.go
sed -i "" 's/total_active_anon/totalActiveAnon/g' docker/*.go
sed -i "" 's/total_inactive_file/totalInactiveFile/g' docker/*.go
sed -i "" 's/total_active_file/totalActiveFile/g' docker/*.go
sed -i "" 's/total_unevictable/totalUnevictable/g' docker/*.go
sed -i "" 's/mem_usage_in_bytes/memUsageInBytes/g' docker/*.go
sed -i "" 's/mem_max_usage_in_bytes/memMaxUsageInBytes/g' docker/*.go
sed -i "" 's/memory.limit_in_bytes/memoryLimitInBbytes/g' docker/*.go
sed -i "" 's/memory.failcnt/memoryFailcnt/g' docker/*.go
sed -i "" 's/mapped_file/mappedFile/g' docker/*.go
sed -i "" 's/container_id/containerID/g' docker/*.go
sed -i "" 's/rss_huge/rssHuge/g' docker/*.go
sed -i "" 's/inactive_anon/inactiveAnon/g' docker/*.go
sed -i "" 's/active_anon/activeAnon/g' docker/*.go
sed -i "" 's/inactive_file/inactiveFile/g' docker/*.go
sed -i "" 's/active_file/activeFile/g' docker/*.go
sed -i "" 's/hierarchical_memory_limit/hierarchicalMemoryLimit/g' docker/*.go
sed -i "" 's/boot_time/bootTime/g' host/*.go
sed -i "" 's/platform_family/platformFamily/g' host/*.go
sed -i "" 's/platform_version/platformVersion/g' host/*.go
sed -i "" 's/virtualization_system/virtualizationSystem/g' host/*.go
sed -i "" 's/virtualization_role/virtualizationRole/g' host/*.go
sed -i "" 's/used_percent/usedPercent/g' mem/*.go
sed -i "" 's/bytes_sent/bytesSent/g' net/*.go
sed -i "" 's/bytes_recv/bytesRecv/g' net/*.go
sed -i "" 's/packets_sent/packetsSent/g' net/*.go
sed -i "" 's/packets_recv/packetsRecv/g' net/*.go
sed -i "" 's/conntrack_count/conntrackCount/g' net/*.go
sed -i "" 's/conntrack_max/conntrackMax/g' net/*.go
sed -i "" 's/read_count/readCount/g' process/*.go
sed -i "" 's/write_count/writeCount/g' process/*.go
sed -i "" 's/read_bytes/readBytes/g' process/*.go
sed -i "" 's/write_bytes/writeBytes/g' process/*.go
sed -i "" 's/shared_clean/sharedClean/g' process/*.go
sed -i "" 's/shared_dirty/sharedDirty/g' process/*.go
sed -i "" 's/private_clean/privateClean/g' process/*.go
sed -i "" 's/private_dirty/privateDirty/g' process/*.go

View File

@ -1,36 +0,0 @@
Windows memo
=====================
Size
----------
DWORD
32-bit unsigned integer
DWORDLONG
64-bit unsigned integer
DWORD_PTR
unsigned long type for pointer precision
DWORD32
32-bit unsigned integer
DWORD64
64-bit unsigned integer
HALF_PTR
_WIN64 = int, else short
INT
32-bit signed integer
INT_PTR
_WIN64 = __int64 else int
LONG
32-bit signed integer
LONGLONG
64-bit signed integer
LONG_PTR
_WIN64 = __int64 else long
SHORT
16-bit integer
SIZE_T
maximum number of bytes to which a pointer can point. typedef ULONG_PTR SIZE_T;
SSIZE_T
signed version of SIZE_T. typedef LONG_PTR SSIZE_T;
WORD
16-bit unsigned integer

0
vendor/golang.org/x/sys/unix/mkall.sh generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mkerrors.sh generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksyscall.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksyscall_solaris.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysctl_openbsd.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysnum_darwin.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysnum_dragonfly.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysnum_freebsd.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysnum_netbsd.pl generated vendored Executable file → Normal file
View File

0
vendor/golang.org/x/sys/unix/mksysnum_openbsd.pl generated vendored Executable file → Normal file
View File

28
vendor/modules.txt vendored Normal file
View File

@ -0,0 +1,28 @@
# github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6
github.com/StackExchange/wmi
# github.com/cjbassi/drawille-go v0.0.0-20180329221028-ad535d0f92cd
github.com/cjbassi/drawille-go
# github.com/cjbassi/termui v0.0.0-20180823181054-5edfcb3a441f
github.com/cjbassi/termui
# github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/docopt/docopt-go
# github.com/go-ole/go-ole v1.2.1
github.com/go-ole/go-ole
github.com/go-ole/go-ole/oleutil
# github.com/mattn/go-runewidth v0.0.2
github.com/mattn/go-runewidth
# github.com/nsf/termbox-go v0.0.0-20180407224525-3e24a7b6661e
github.com/nsf/termbox-go
# github.com/shirou/gopsutil v0.0.0-20180811135056-68ff0e299699
github.com/shirou/gopsutil/cpu
github.com/shirou/gopsutil/disk
github.com/shirou/gopsutil/host
github.com/shirou/gopsutil/mem
github.com/shirou/gopsutil/net
github.com/shirou/gopsutil/process
github.com/shirou/gopsutil/internal/common
# github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4
github.com/shirou/w32
# golang.org/x/sys v0.0.0-20180406135729-3b87a42e500a
golang.org/x/sys/unix
golang.org/x/sys/windows