├── .travis.yml ├── screenshot.png ├── collector ├── vendor │ └── github.com │ │ └── fsouza │ │ └── go-dockerclient │ │ ├── .gitignore │ │ ├── external │ │ ├── github.com │ │ │ ├── docker │ │ │ │ ├── docker │ │ │ │ │ ├── pkg │ │ │ │ │ │ ├── archive │ │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ │ ├── copy_windows.go │ │ │ │ │ │ │ ├── copy_unix.go │ │ │ │ │ │ │ ├── time_unsupported.go │ │ │ │ │ │ │ ├── time_linux.go │ │ │ │ │ │ │ ├── changes_windows.go │ │ │ │ │ │ │ ├── changes_unix.go │ │ │ │ │ │ │ ├── whiteouts.go │ │ │ │ │ │ │ ├── wrap.go │ │ │ │ │ │ │ ├── archive_windows.go │ │ │ │ │ │ │ ├── changes_other.go │ │ │ │ │ │ │ ├── example_changes.go │ │ │ │ │ │ │ └── archive_unix.go │ │ │ │ │ │ ├── ioutils │ │ │ │ │ │ │ ├── scheduler.go │ │ │ │ │ │ │ ├── temp_unix.go │ │ │ │ │ │ │ ├── scheduler_gccgo.go │ │ │ │ │ │ │ ├── temp_windows.go │ │ │ │ │ │ │ ├── fmt.go │ │ │ │ │ │ │ ├── writers.go │ │ │ │ │ │ │ └── writeflusher.go │ │ │ │ │ │ ├── fileutils │ │ │ │ │ │ │ ├── fileutils_windows.go │ │ │ │ │ │ │ └── fileutils_unix.go │ │ │ │ │ │ ├── system │ │ │ │ │ │ │ ├── utimes_darwin.go │ │ │ │ │ │ │ ├── meminfo_unsupported.go │ │ │ │ │ │ │ ├── errors.go │ │ │ │ │ │ │ ├── path_windows.go │ │ │ │ │ │ │ ├── syscall_unix.go │ │ │ │ │ │ │ ├── umask_windows.go │ │ │ │ │ │ │ ├── umask.go │ │ │ │ │ │ │ ├── path_unix.go │ │ │ │ │ │ │ ├── utimes_unsupported.go │ │ │ │ │ │ │ ├── chtimes_unix.go │ │ │ │ │ │ │ ├── mknod_windows.go │ │ │ │ │ │ │ ├── stat_openbsd.go │ │ │ │ │ │ │ ├── stat_solaris.go │ │ │ │ │ │ │ ├── xattrs_unsupported.go │ │ │ │ │ │ │ ├── stat_unsupported.go │ │ │ │ │ │ │ ├── lstat.go │ │ │ │ │ │ │ ├── meminfo.go │ │ │ │ │ │ │ ├── filesys.go │ │ │ │ │ │ │ ├── lstat_windows.go │ │ │ │ │ │ │ ├── utimes_freebsd.go │ │ │ │ │ │ │ ├── stat_freebsd.go │ │ │ │ │ │ │ ├── chtimes_windows.go │ │ │ │ │ │ │ ├── utimes_linux.go │ │ │ │ │ │ │ ├── mknod.go │ │ │ │ │ │ │ ├── stat_linux.go │ │ │ │ │ │ │ ├── stat_windows.go │ │ │ │ │ │ │ ├── syscall_windows.go │ │ │ │ │ │ │ ├── chtimes.go │ │ │ │ │ │ │ ├── stat.go │ │ │ │ │ │ │ ├── meminfo_windows.go │ │ │ │ │ │ │ ├── meminfo_linux.go │ │ │ │ │ │ │ ├── xattrs_linux.go │ │ │ │ │ │ │ ├── filesys_windows.go │ │ │ │ │ │ │ └── events_windows.go │ │ │ │ │ │ ├── promise │ │ │ │ │ │ │ └── promise.go │ │ │ │ │ │ ├── idtools │ │ │ │ │ │ │ ├── usergroupadd_unsupported.go │ │ │ │ │ │ │ ├── idtools_windows.go │ │ │ │ │ │ │ └── idtools_unix.go │ │ │ │ │ │ ├── longpath │ │ │ │ │ │ │ └── longpath.go │ │ │ │ │ │ └── homedir │ │ │ │ │ │ │ └── homedir.go │ │ │ │ │ └── opts │ │ │ │ │ │ ├── hosts_windows.go │ │ │ │ │ │ ├── opts_unix.go │ │ │ │ │ │ ├── hosts_unix.go │ │ │ │ │ │ ├── ip.go │ │ │ │ │ │ ├── envfile.go │ │ │ │ │ │ └── opts_windows.go │ │ │ │ └── go-units │ │ │ │ │ ├── circle.yml │ │ │ │ │ ├── README.md │ │ │ │ │ ├── MAINTAINERS │ │ │ │ │ ├── duration.go │ │ │ │ │ ├── size.go │ │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ │ └── ulimit.go │ │ │ ├── opencontainers │ │ │ │ └── runc │ │ │ │ │ └── libcontainer │ │ │ │ │ └── user │ │ │ │ │ ├── MAINTAINERS │ │ │ │ │ ├── lookup_unsupported.go │ │ │ │ │ ├── lookup_unix.go │ │ │ │ │ └── lookup.go │ │ │ ├── Sirupsen │ │ │ │ └── logrus │ │ │ │ │ ├── terminal_bsd.go │ │ │ │ │ ├── terminal_linux.go │ │ │ │ │ ├── terminal_solaris.go │ │ │ │ │ ├── terminal_notwindows.go │ │ │ │ │ ├── doc.go │ │ │ │ │ ├── writer.go │ │ │ │ │ ├── terminal_windows.go │ │ │ │ │ ├── json_formatter.go │ │ │ │ │ ├── LICENSE │ │ │ │ │ ├── hooks.go │ │ │ │ │ ├── CHANGELOG.md │ │ │ │ │ ├── formatter.go │ │ │ │ │ └── logrus.go │ │ │ └── hashicorp │ │ │ │ └── go-cleanhttp │ │ │ │ ├── cleanhttp.go │ │ │ │ └── README.md │ │ └── golang.org │ │ │ └── x │ │ │ └── sys │ │ │ └── unix │ │ │ ├── asm.s │ │ │ ├── constants.go │ │ │ ├── syscall_no_getwd.go │ │ │ ├── zsysnum_solaris_amd64.go │ │ │ ├── env_unset.go │ │ │ ├── flock_linux_32bit.go │ │ │ ├── asm_solaris_amd64.s │ │ │ ├── gccgo_linux_amd64.go │ │ │ ├── race0.go │ │ │ ├── env_unix.go │ │ │ ├── asm_linux_arm64.s │ │ │ ├── str.go │ │ │ ├── race.go │ │ │ ├── asm_linux_ppc64x.s │ │ │ ├── asm_linux_arm.s │ │ │ ├── asm_freebsd_arm.s │ │ │ ├── asm_netbsd_arm.s │ │ │ ├── asm_darwin_386.s │ │ │ ├── asm_dragonfly_386.s │ │ │ ├── asm_freebsd_386.s │ │ │ ├── asm_linux_amd64.s │ │ │ ├── asm_netbsd_386.s │ │ │ ├── asm_openbsd_386.s │ │ │ ├── asm_darwin_amd64.s │ │ │ ├── asm_freebsd_amd64.s │ │ │ ├── asm_netbsd_amd64.s │ │ │ ├── asm_openbsd_amd64.s │ │ │ ├── asm_dragonfly_amd64.s │ │ │ ├── asm_darwin_arm.s │ │ │ ├── asm_darwin_arm64.s │ │ │ ├── flock.go │ │ │ ├── mksysnum_darwin.pl │ │ │ ├── asm_linux_386.s │ │ │ ├── syscall_solaris_amd64.go │ │ │ ├── gccgo_c.c │ │ │ ├── syscall_openbsd_amd64.go │ │ │ ├── sockcmsg_linux.go │ │ │ ├── syscall_netbsd_386.go │ │ │ ├── syscall_netbsd_amd64.go │ │ │ ├── syscall_netbsd_arm.go │ │ │ ├── syscall_openbsd_386.go │ │ │ ├── mksysnum_dragonfly.pl │ │ │ ├── mksysnum_openbsd.pl │ │ │ ├── mksysnum_netbsd.pl │ │ │ ├── mksysnum_linux.pl │ │ │ ├── gccgo.go │ │ │ ├── syscall_freebsd_amd64.go │ │ │ ├── syscall_dragonfly_amd64.go │ │ │ ├── syscall_freebsd_arm.go │ │ │ ├── syscall_freebsd_386.go │ │ │ ├── syscall_dragonfly_386.go │ │ │ ├── mksysnum_freebsd.pl │ │ │ ├── syscall_darwin_arm.go │ │ │ ├── syscall_darwin_arm64.go │ │ │ ├── syscall_darwin_386.go │ │ │ ├── syscall_darwin_amd64.go │ │ │ ├── syscall.go │ │ │ └── sockcmsg_unix.go │ │ ├── DOCKER-LICENSE │ │ ├── .travis.yml │ │ ├── change.go │ │ ├── Makefile │ │ ├── LICENSE │ │ ├── signal.go │ │ ├── tls.go │ │ ├── README.markdown │ │ └── tar.go ├── Godeps │ ├── Readme │ └── Godeps.json ├── stats.go ├── cmd │ └── collectd-docker-collector │ │ └── main.go ├── collector.go └── writer.go ├── Dockerfile ├── docker ├── collectd.conf.tpl ├── run.sh └── build.sh └── LICENSE /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.6 5 | - tip 6 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobrik/collectd-docker/HEAD/screenshot.png -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/.gitignore: -------------------------------------------------------------------------------- 1 | # temporary symlink for testing 2 | testing/data/symlink 3 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/README.md: -------------------------------------------------------------------------------- 1 | This code provides helper functions for dealing with archive files. 2 | -------------------------------------------------------------------------------- /collector/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | 3 | COPY . /go/src/github.com/bobrik/collectd-docker 4 | 5 | RUN /go/src/github.com/bobrik/collectd-docker/docker/build.sh 6 | 7 | ENTRYPOINT ["/run.sh"] 8 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/scheduler.go: -------------------------------------------------------------------------------- 1 | // +build !gccgo 2 | 3 | package ioutils 4 | 5 | func callSchedulerIfNecessary() { 6 | } 7 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Tianon Gravi (@tianon) 2 | Aleksa Sarai (@cyphar) 3 | -------------------------------------------------------------------------------- /collector/stats.go: -------------------------------------------------------------------------------- 1 | package collector 2 | 3 | import "github.com/fsouza/go-dockerclient" 4 | 5 | // Stats represents singe stat from docker stats api for specific task 6 | type Stats struct { 7 | App string 8 | Task string 9 | Stats docker.Stats 10 | } 11 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/hosts_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package opts 4 | 5 | // DefaultHost constant defines the default host string used by docker on Windows 6 | var DefaultHost = DefaultTCPHost 7 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/copy_windows.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "path/filepath" 5 | ) 6 | 7 | func normalizePath(path string) string { 8 | return filepath.FromSlash(path) 9 | } 10 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils/fileutils_windows.go: -------------------------------------------------------------------------------- 1 | package fileutils 2 | 3 | // GetTotalUsedFds Returns the number of used File Descriptors. Not supported 4 | // on Windows. 5 | func GetTotalUsedFds() int { 6 | return -1 7 | } 8 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/opts_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package opts 4 | 5 | // DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. docker daemon -H tcp://:8080 6 | const DefaultHTTPHost = "localhost" 7 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/copy_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package archive 4 | 5 | import ( 6 | "path/filepath" 7 | ) 8 | 9 | func normalizePath(path string) string { 10 | return filepath.ToSlash(path) 11 | } 12 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/utimes_darwin.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "syscall" 4 | 5 | // LUtimesNano is not supported by darwin platform. 6 | func LUtimesNano(path string, ts []syscall.Timespec) error { 7 | return ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/hosts_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package opts 4 | 5 | import "fmt" 6 | 7 | // DefaultHost constant defines the default host string used by docker on other hosts than Windows 8 | var DefaultHost = fmt.Sprintf("unix://%s", DefaultUnixSocket) 9 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/meminfo_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!windows 2 | 3 | package system 4 | 5 | // ReadMemInfo is not supported on platforms other than linux and windows. 6 | func ReadMemInfo() (*MemInfo, error) { 7 | return nil, ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/errors.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var ( 8 | // ErrNotSupportedPlatform means the platform is not supported. 9 | ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") 10 | ) 11 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/path_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // DefaultPathEnv is deliberately empty on Windows as the default path will be set by 6 | // the container. Docker has no context of what the default path should be. 7 | const DefaultPathEnv = "" 8 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/DOCKER-LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | You can find the Docker license at the following link: 6 | https://raw.githubusercontent.com/docker/docker/master/LICENSE 7 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/temp_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package ioutils 4 | 5 | import "io/ioutil" 6 | 7 | // TempDir on Unix systems is equivalent to ioutil.TempDir. 8 | func TempDir(dir, prefix string) (string, error) { 9 | return ioutil.TempDir(dir, prefix) 10 | } 11 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/asm.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 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/syscall_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd 2 | 3 | package system 4 | 5 | import "syscall" 6 | 7 | // Unmount is a platform-specific helper function to call 8 | // the unmount syscall. 9 | func Unmount(dest string) error { 10 | return syscall.Unmount(dest, 0) 11 | } 12 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/umask_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // Umask is not supported on the windows platform. 6 | func Umask(newmask int) (oldmask int, err error) { 7 | // should not be called on cli code path 8 | return 0, ErrNotSupportedPlatform 9 | } 10 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/umask.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Umask sets current process's file mode creation mask to newmask 10 | // and return oldmask. 11 | func Umask(newmask int) (oldmask int, err error) { 12 | return syscall.Umask(newmask), nil 13 | } 14 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/circle.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | post: 3 | # install golint 4 | - go get github.com/golang/lint/golint 5 | 6 | test: 7 | pre: 8 | # run analysis before tests 9 | - go vet ./... 10 | - test -z "$(golint ./... | tee /dev/stderr)" 11 | - test -z "$(gofmt -s -l . | tee /dev/stderr)" 12 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/path_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | // DefaultPathEnv is unix style list of directories to search for 6 | // executables. Each directory is separated from the next by a colon 7 | // ':' character . 8 | const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 9 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/utimes_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!freebsd,!darwin 2 | 3 | package system 4 | 5 | import "syscall" 6 | 7 | // LUtimesNano is not supported on platforms other than linux, freebsd and darwin. 8 | func LUtimesNano(path string, ts []syscall.Timespec) error { 9 | return ErrNotSupportedPlatform 10 | } 11 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/scheduler_gccgo.go: -------------------------------------------------------------------------------- 1 | // +build gccgo 2 | 3 | package ioutils 4 | 5 | import ( 6 | "runtime" 7 | ) 8 | 9 | func callSchedulerIfNecessary() { 10 | //allow or force Go scheduler to switch context, without explicitly 11 | //forcing this will make it hang when using gccgo implementation 12 | runtime.Gosched() 13 | } 14 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/time_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package archive 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | ) 9 | 10 | func timeToTimespec(time time.Time) (ts syscall.Timespec) { 11 | nsec := int64(0) 12 | if !time.IsZero() { 13 | nsec = time.UnixNano() 14 | } 15 | return syscall.NsecToTimespec(nsec) 16 | } 17 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/promise/promise.go: -------------------------------------------------------------------------------- 1 | package promise 2 | 3 | // Go is a basic promise implementation: it wraps calls a function in a goroutine, 4 | // and returns a channel which will later return the function's return value. 5 | func Go(f func() error) chan error { 6 | ch := make(chan error, 1) 7 | go func() { 8 | ch <- f() 9 | }() 10 | return ch 11 | } 12 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 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 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/time_linux.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "syscall" 5 | "time" 6 | ) 7 | 8 | func timeToTimespec(time time.Time) (ts syscall.Timespec) { 9 | if time.IsZero() { 10 | // Return UTIME_OMIT special value 11 | ts.Sec = 0 12 | ts.Nsec = ((1 << 30) - 2) 13 | return 14 | } 15 | return syscall.NsecToTimespec(time.UnixNano()) 16 | } 17 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | //setCTime will set the create time on a file. On Unix, the create 10 | //time is updated as a side effect of setting the modified time, so 11 | //no action is required. 12 | func setCTime(path string, ctime time.Time) error { 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/mknod_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | // Mknod is not implemented on Windows. 6 | func Mknod(path string, mode uint32, dev int) error { 7 | return ErrNotSupportedPlatform 8 | } 9 | 10 | // Mkdev is not implemented on Windows. 11 | func Mkdev(major int64, minor int64) uint32 { 12 | panic("Mkdev not implemented on Windows.") 13 | } 14 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_openbsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: uint32(s.Mode), 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: uint64(s.Rdev), 14 | mtim: s.Mtim}, nil 15 | } 16 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 10 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 11 | return &StatT{size: s.Size, 12 | mode: uint32(s.Mode), 13 | uid: s.Uid, 14 | gid: s.Gid, 15 | rdev: uint64(s.Rdev), 16 | mtim: s.Mtim}, nil 17 | } 18 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/xattrs_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package system 4 | 5 | // Lgetxattr is not supported on platforms other than linux. 6 | func Lgetxattr(path string, attr string) ([]byte, error) { 7 | return nil, ErrNotSupportedPlatform 8 | } 9 | 10 | // Lsetxattr is not supported on platforms other than linux. 11 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 12 | return ErrNotSupportedPlatform 13 | } 14 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!windows,!freebsd,!solaris,!openbsd 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // fromStatT creates a system.StatT type from a syscall.Stat_t type 10 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 11 | return &StatT{size: s.Size, 12 | mode: uint32(s.Mode), 13 | uid: s.Uid, 14 | gid: s.Gid, 15 | rdev: uint64(s.Rdev), 16 | mtim: s.Mtimespec}, nil 17 | } 18 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/lstat.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Lstat takes a path to a file and returns 10 | // a system.StatT type pertaining to that file. 11 | // 12 | // Throws an error if the file does not exist 13 | func Lstat(path string) (*StatT, error) { 14 | s := &syscall.Stat_t{} 15 | if err := syscall.Lstat(path, s); err != nil { 16 | return nil, err 17 | } 18 | return fromStatT(s) 19 | } 20 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/meminfo.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | // MemInfo contains memory statistics of the host system. 4 | type MemInfo struct { 5 | // Total usable RAM (i.e. physical RAM minus a few reserved bits and the 6 | // kernel binary code). 7 | MemTotal int64 8 | 9 | // Amount of free memory. 10 | MemFree int64 11 | 12 | // Total amount of swap space available. 13 | SwapTotal int64 14 | 15 | // Amount of swap space that is currently unused. 16 | SwapFree int64 17 | } 18 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools/usergroupadd_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package idtools 4 | 5 | import "fmt" 6 | 7 | // AddNamespaceRangesUser takes a name and finds an unused uid, gid pair 8 | // and calls the appropriate helper function to add the group and then 9 | // the user to the group in /etc/group and /etc/passwd respectively. 10 | func AddNamespaceRangesUser(name string) (int, int, error) { 11 | return -1, -1, fmt.Errorf("No support for adding users or groups on this OS") 12 | } 13 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris 2 | 3 | package user 4 | 5 | import "io" 6 | 7 | func GetPasswdPath() (string, error) { 8 | return "", ErrUnsupported 9 | } 10 | 11 | func GetPasswd() (io.ReadCloser, error) { 12 | return nil, ErrUnsupported 13 | } 14 | 15 | func GetGroupPath() (string, error) { 16 | return "", ErrUnsupported 17 | } 18 | 19 | func GetGroup() (io.ReadCloser, error) { 20 | return nil, ErrUnsupported 21 | } 22 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/temp_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package ioutils 4 | 5 | import ( 6 | "io/ioutil" 7 | 8 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath" 9 | ) 10 | 11 | // TempDir is the equivalent of ioutil.TempDir, except that the result is in Windows longpath format. 12 | func TempDir(dir, prefix string) (string, error) { 13 | tempDir, err := ioutil.TempDir(dir, prefix) 14 | if err != nil { 15 | return "", err 16 | } 17 | return longpath.AddPrefix(tempDir), nil 18 | } 19 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/filesys.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "path/filepath" 8 | ) 9 | 10 | // MkdirAll creates a directory named path along with any necessary parents, 11 | // with permission specified by attribute perm for all dir created. 12 | func MkdirAll(path string, perm os.FileMode) error { 13 | return os.MkdirAll(path, perm) 14 | } 15 | 16 | // IsAbs is a platform-specific wrapper for filepath.IsAbs. 17 | func IsAbs(path string) bool { 18 | return filepath.IsAbs(path) 19 | } 20 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/fmt.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | // FprintfIfNotEmpty prints the string value if it's not empty 9 | func FprintfIfNotEmpty(w io.Writer, format, value string) (int, error) { 10 | if value != "" { 11 | return fmt.Fprintf(w, format, value) 12 | } 13 | return 0, nil 14 | } 15 | 16 | // FprintfIfTrue prints the boolean value if it's true 17 | func FprintfIfTrue(w io.Writer, format string, ok bool) (int, error) { 18 | if ok { 19 | return fmt.Fprintf(w, format, ok) 20 | } 21 | return 0, nil 22 | } 23 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools/idtools_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package idtools 4 | 5 | import ( 6 | "os" 7 | 8 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system" 9 | ) 10 | 11 | // Platforms such as Windows do not support the UID/GID concept. So make this 12 | // just a wrapper around system.MkdirAll. 13 | func mkdirAs(path string, mode os.FileMode, ownerUID, ownerGID int, mkAll, chownExisting bool) error { 14 | if err := system.MkdirAll(path, mode); err != nil && !os.IsExist(err) { 15 | return err 16 | } 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: required 3 | go: 4 | - 1.4.2 5 | - 1.5.3 6 | - 1.6 7 | - tip 8 | os: 9 | - linux 10 | - osx 11 | env: 12 | - GOARCH=amd64 DOCKER_VERSION=1.8.3 13 | - GOARCH=386 DOCKER_VERSION=1.8.3 14 | - GOARCH=amd64 DOCKER_VERSION=1.9.1 15 | - GOARCH=386 DOCKER_VERSION=1.9.1 16 | - GOARCH=amd64 DOCKER_VERSION=1.10.3 17 | - GOARCH=386 DOCKER_VERSION=1.10.3 18 | install: 19 | - travis_retry travis-scripts/install.bash 20 | script: 21 | - travis-scripts/run-tests.bash 22 | services: 23 | - docker 24 | matrix: 25 | fast_finish: true 26 | allow_failures: 27 | - go: tip 28 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils/fileutils_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd 2 | 3 | package fileutils 4 | 5 | import ( 6 | "fmt" 7 | "io/ioutil" 8 | "os" 9 | 10 | "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus" 11 | ) 12 | 13 | // GetTotalUsedFds Returns the number of used File Descriptors by 14 | // reading it via /proc filesystem. 15 | func GetTotalUsedFds() int { 16 | if fds, err := ioutil.ReadDir(fmt.Sprintf("/proc/%d/fd", os.Getpid())); err != nil { 17 | logrus.Errorf("Error opening /proc/%d/fd: %s", os.Getpid(), err) 18 | } else { 19 | return len(fds) 20 | } 21 | return -1 22 | } 23 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 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 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/lstat_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | // Lstat calls os.Lstat to get a fileinfo interface back. 10 | // This is then copied into our own locally defined structure. 11 | // Note the Linux version uses fromStatT to do the copy back, 12 | // but that not strictly necessary when already in an OS specific module. 13 | func Lstat(path string) (*StatT, error) { 14 | fi, err := os.Lstat(path) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | return &StatT{ 20 | name: fi.Name(), 21 | size: fi.Size(), 22 | mode: fi.Mode(), 23 | modTime: fi.ModTime(), 24 | isDir: fi.IsDir()}, nil 25 | } 26 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 2 | 3 | package user 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | // Unix-specific path to the passwd and group formatted files. 11 | const ( 12 | unixPasswdPath = "/etc/passwd" 13 | unixGroupPath = "/etc/group" 14 | ) 15 | 16 | func GetPasswdPath() (string, error) { 17 | return unixPasswdPath, nil 18 | } 19 | 20 | func GetPasswd() (io.ReadCloser, error) { 21 | return os.Open(unixPasswdPath) 22 | } 23 | 24 | func GetGroupPath() (string, error) { 25 | return unixGroupPath, nil 26 | } 27 | 28 | func GetGroup() (io.ReadCloser, error) { 29 | return os.Open(unixGroupPath) 30 | } 31 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/utimes_freebsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // LUtimesNano is used to change access and modification time of the specified path. 9 | // It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. 10 | func LUtimesNano(path string, ts []syscall.Timespec) error { 11 | var _path *byte 12 | _path, err := syscall.BytePtrFromString(path) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | if _, _, err := syscall.Syscall(syscall.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != syscall.ENOSYS { 18 | return err 19 | } 20 | 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_freebsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT converts a syscall.Stat_t type to a system.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: uint32(s.Mode), 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: uint64(s.Rdev), 14 | mtim: s.Mtimespec}, nil 15 | } 16 | 17 | // Stat takes a path to a file and returns 18 | // a system.Stat_t type pertaining to that file. 19 | // 20 | // Throws an error if the file does not exist 21 | func Stat(path string) (*StatT, error) { 22 | s := &syscall.Stat_t{} 23 | if err := syscall.Stat(path, s); err != nil { 24 | return nil, err 25 | } 26 | return fromStatT(s) 27 | } 28 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /docker/collectd.conf.tpl: -------------------------------------------------------------------------------- 1 | Hostname "{{ .Env "COLLECTD_HOST" }}" 2 | 3 | FQDNLookup false 4 | Interval {{ .Env "COLLECTD_INTERVAL" }} 5 | Timeout 2 6 | ReadThreads 5 7 | 8 | LoadPlugin write_graphite 9 | 10 | 11 | Host "{{ .Env "GRAPHITE_HOST" }}" 12 | Port "{{ .Env "GRAPHITE_PORT" }}" 13 | Protocol "tcp" 14 | Prefix "{{ .Env "GRAPHITE_PREFIX" }}" 15 | StoreRates true 16 | EscapeCharacter "." 17 | AlwaysAppendDS false 18 | SeparateInstances true 19 | 20 | 21 | 22 | LoadPlugin exec 23 | 24 | Exec "collectd-docker-collector" "/usr/bin/collectd-docker-collector" "-endpoint" "unix:///var/run/docker.sock" "-host" "{{ .Env "COLLECTD_HOST" }}" "-interval" "{{ .Env "COLLECTD_INTERVAL" }}" 25 | 26 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 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 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/changes_windows.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system" 7 | ) 8 | 9 | func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { 10 | 11 | // Don't look at size for dirs, its not a good measure of change 12 | if oldStat.ModTime() != newStat.ModTime() || 13 | oldStat.Mode() != newStat.Mode() || 14 | oldStat.Size() != newStat.Size() && !oldStat.IsDir() { 15 | return true 16 | } 17 | return false 18 | } 19 | 20 | func (info *FileInfo) isDir() bool { 21 | return info.parent == nil || info.stat.IsDir() 22 | } 23 | 24 | func getIno(fi os.FileInfo) (inode uint64) { 25 | return 26 | } 27 | 28 | func hasHardlinks(fi os.FileInfo) bool { 29 | return false 30 | } 31 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/asm_dragonfly_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-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | ) 9 | 10 | //setCTime will set the create time on a file. On Windows, this requires 11 | //calling SetFileTime and explicitly including the create time. 12 | func setCTime(path string, ctime time.Time) error { 13 | ctimespec := syscall.NsecToTimespec(ctime.UnixNano()) 14 | pathp, e := syscall.UTF16PtrFromString(path) 15 | if e != nil { 16 | return e 17 | } 18 | h, e := syscall.CreateFile(pathp, 19 | syscall.FILE_WRITE_ATTRIBUTES, syscall.FILE_SHARE_WRITE, nil, 20 | syscall.OPEN_EXISTING, syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) 21 | if e != nil { 22 | return e 23 | } 24 | defer syscall.Close(h) 25 | c := syscall.NsecToFiletime(syscall.TimespecToNsec(ctimespec)) 26 | return syscall.SetFileTime(h, &c, nil, nil) 27 | } 28 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 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 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/utimes_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // LUtimesNano is used to change access and modification time of the specified path. 9 | // It's used for symbol link file because syscall.UtimesNano doesn't support a NOFOLLOW flag atm. 10 | func LUtimesNano(path string, ts []syscall.Timespec) error { 11 | // These are not currently available in syscall 12 | atFdCwd := -100 13 | atSymLinkNoFollow := 0x100 14 | 15 | var _path *byte 16 | _path, err := syscall.BytePtrFromString(path) 17 | if err != nil { 18 | return err 19 | } 20 | 21 | if _, _, err := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(atSymLinkNoFollow), 0, 0); err != 0 && err != syscall.ENOSYS { 22 | return err 23 | } 24 | 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath/longpath.go: -------------------------------------------------------------------------------- 1 | // longpath introduces some constants and helper functions for handling long paths 2 | // in Windows, which are expected to be prepended with `\\?\` and followed by either 3 | // a drive letter, a UNC server\share, or a volume identifier. 4 | 5 | package longpath 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | // Prefix is the longpath prefix for Windows file paths. 12 | const Prefix = `\\?\` 13 | 14 | // AddPrefix will add the Windows long path prefix to the path provided if 15 | // it does not already have it. 16 | func AddPrefix(path string) string { 17 | if !strings.HasPrefix(path, Prefix) { 18 | if strings.HasPrefix(path, `\\`) { 19 | // This is a UNC path, so we need to add 'UNC' to the path as well. 20 | path = Prefix + `UNC` + path[1:] 21 | } else { 22 | path = Prefix + path 23 | } 24 | } 25 | return path 26 | } 27 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/docker/go-units?status.svg)](https://godoc.org/github.com/docker/go-units) 2 | 3 | # Introduction 4 | 5 | go-units is a library to transform human friendly measurements into machine friendly values. 6 | 7 | ## Usage 8 | 9 | See the [docs in godoc](https://godoc.org/github.com/docker/go-units) for examples and documentation. 10 | 11 | ## Copyright and license 12 | 13 | Copyright © 2015 Docker, Inc. All rights reserved, except as follows. Code 14 | is released under the Apache 2.0 license. The README.md file, and files in the 15 | "docs" folder are licensed under the Creative Commons Attribution 4.0 16 | International License under the terms and conditions set forth in the file 17 | "LICENSE.docs". You may obtain a duplicate copy of the same license, titled 18 | CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/. 19 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/mknod.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Mknod creates a filesystem node (file, device special file or named pipe) named path 10 | // with attributes specified by mode and dev. 11 | func Mknod(path string, mode uint32, dev int) error { 12 | return syscall.Mknod(path, mode, dev) 13 | } 14 | 15 | // Mkdev is used to build the value of linux devices (in /dev/) which specifies major 16 | // and minor number of the newly created device special file. 17 | // Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. 18 | // They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, 19 | // then the top 12 bits of the minor. 20 | func Mkdev(major int64, minor int64) uint32 { 21 | return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) 22 | } 23 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT converts a syscall.Stat_t type to a system.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*StatT, error) { 9 | return &StatT{size: s.Size, 10 | mode: s.Mode, 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: s.Rdev, 14 | mtim: s.Mtim}, nil 15 | } 16 | 17 | // FromStatT exists only on linux, and loads a system.StatT from a 18 | // syscal.Stat_t. 19 | func FromStatT(s *syscall.Stat_t) (*StatT, error) { 20 | return fromStatT(s) 21 | } 22 | 23 | // Stat takes a path to a file and returns 24 | // a system.StatT type pertaining to that file. 25 | // 26 | // Throws an error if the file does not exist 27 | func Stat(path string) (*StatT, error) { 28 | s := &syscall.Stat_t{} 29 | if err := syscall.Stat(path, s); err != nil { 30 | return nil, err 31 | } 32 | return fromStatT(s) 33 | } 34 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # go-connections maintainers file 2 | # 3 | # This file describes who runs the docker/go-connections project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "calavera", 15 | ] 16 | 17 | [people] 18 | 19 | # A reference list of all people associated with the project. 20 | # All other sections should refer to people by their canonical key 21 | # in the people section. 22 | 23 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 24 | [people.calavera] 25 | Name = "David Calavera" 26 | Email = "david.calavera@gmail.com" 27 | GitHub = "calavera" 28 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 < /dev/null 36 | -------------------------------------------------------------------------------- /collector/cmd/collectd-docker-collector/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | "os" 7 | 8 | "path" 9 | 10 | "github.com/bobrik/collectd-docker/collector" 11 | "github.com/fsouza/go-dockerclient" 12 | ) 13 | 14 | func main() { 15 | e := flag.String("endpoint", "unix:///var/run/docker.sock", "docker endpoint") 16 | c := flag.String("cert", "", "cert path for tls") 17 | h := flag.String("host", "", "host to report") 18 | i := flag.Int("interval", 1, "interval to report") 19 | flag.Parse() 20 | 21 | if *h == "" { 22 | flag.PrintDefaults() 23 | os.Exit(1) 24 | } 25 | 26 | var client *docker.Client 27 | var err error 28 | 29 | if *c != "" { 30 | client, err = docker.NewTLSClient(*e, path.Join(*c, "cert.pem"), path.Join(*c, "key.pem"), path.Join(*c, "ca.pem")) 31 | } else { 32 | client, err = docker.NewClient(*e) 33 | } 34 | 35 | if err != nil { 36 | log.Fatal(err) 37 | } 38 | 39 | writer := collector.NewCollectdWriter(*h, os.Stdout) 40 | 41 | collector := collector.NewCollector(client, writer, *i) 42 | 43 | err = collector.Run(5) 44 | if err != nil { 45 | log.Fatal(err) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ian Babrou 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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/change.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient 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 docker 6 | 7 | import "fmt" 8 | 9 | // ChangeType is a type for constants indicating the type of change 10 | // in a container 11 | type ChangeType int 12 | 13 | const ( 14 | // ChangeModify is the ChangeType for container modifications 15 | ChangeModify ChangeType = iota 16 | 17 | // ChangeAdd is the ChangeType for additions to a container 18 | ChangeAdd 19 | 20 | // ChangeDelete is the ChangeType for deletions from a container 21 | ChangeDelete 22 | ) 23 | 24 | // Change represents a change in a container. 25 | // 26 | // See https://goo.gl/9GsTIF for more details. 27 | type Change struct { 28 | Path string 29 | Kind ChangeType 30 | } 31 | 32 | func (change *Change) String() string { 33 | var kind string 34 | switch change.Kind { 35 | case ChangeModify: 36 | kind = "C" 37 | case ChangeAdd: 38 | kind = "A" 39 | case ChangeDelete: 40 | kind = "D" 41 | } 42 | return fmt.Sprintf("%s %s", kind, change.Path) 43 | } 44 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (cmsg *Cmsghdr) SetLen(length int) { 31 | cmsg.Len = uint32(length) 32 | } 33 | 34 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 35 | // TODO(aram): implement this, see issue 5847. 36 | panic("unimplemented") 37 | } 38 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/ip.go: -------------------------------------------------------------------------------- 1 | package opts 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | ) 7 | 8 | // IPOpt holds an IP. It is used to store values from CLI flags. 9 | type IPOpt struct { 10 | *net.IP 11 | } 12 | 13 | // NewIPOpt creates a new IPOpt from a reference net.IP and a 14 | // string representation of an IP. If the string is not a valid 15 | // IP it will fallback to the specified reference. 16 | func NewIPOpt(ref *net.IP, defaultVal string) *IPOpt { 17 | o := &IPOpt{ 18 | IP: ref, 19 | } 20 | o.Set(defaultVal) 21 | return o 22 | } 23 | 24 | // Set sets an IPv4 or IPv6 address from a given string. If the given 25 | // string is not parseable as an IP address it returns an error. 26 | func (o *IPOpt) Set(val string) error { 27 | ip := net.ParseIP(val) 28 | if ip == nil { 29 | return fmt.Errorf("%s is not an ip address", val) 30 | } 31 | *o.IP = ip 32 | return nil 33 | } 34 | 35 | // String returns the IP address stored in the IPOpt. If stored IP is a 36 | // nil pointer, it returns an empty string. 37 | func (o *IPOpt) String() string { 38 | if *o.IP == nil { 39 | return "" 40 | } 41 | return o.IP.String() 42 | } 43 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/syscall_windows.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "fmt" 5 | "syscall" 6 | ) 7 | 8 | // OSVersion is a wrapper for Windows version information 9 | // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx 10 | type OSVersion struct { 11 | Version uint32 12 | MajorVersion uint8 13 | MinorVersion uint8 14 | Build uint16 15 | } 16 | 17 | // GetOSVersion gets the operating system version on Windows. Note that 18 | // docker.exe must be manifested to get the correct version information. 19 | func GetOSVersion() (OSVersion, error) { 20 | var err error 21 | osv := OSVersion{} 22 | osv.Version, err = syscall.GetVersion() 23 | if err != nil { 24 | return osv, fmt.Errorf("Failed to call GetVersion()") 25 | } 26 | osv.MajorVersion = uint8(osv.Version & 0xFF) 27 | osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF) 28 | osv.Build = uint16(osv.Version >> 16) 29 | return osv, nil 30 | } 31 | 32 | // Unmount is a platform-specific helper function to call 33 | // the unmount syscall. Not supported on Windows 34 | func Unmount(dest string) error { 35 | return nil 36 | } 37 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/changes_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package archive 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | 9 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system" 10 | ) 11 | 12 | func statDifferent(oldStat *system.StatT, newStat *system.StatT) bool { 13 | // Don't look at size for dirs, its not a good measure of change 14 | if oldStat.Mode() != newStat.Mode() || 15 | oldStat.UID() != newStat.UID() || 16 | oldStat.GID() != newStat.GID() || 17 | oldStat.Rdev() != newStat.Rdev() || 18 | // Don't look at size for dirs, its not a good measure of change 19 | (oldStat.Mode()&syscall.S_IFDIR != syscall.S_IFDIR && 20 | (!sameFsTimeSpec(oldStat.Mtim(), newStat.Mtim()) || (oldStat.Size() != newStat.Size()))) { 21 | return true 22 | } 23 | return false 24 | } 25 | 26 | func (info *FileInfo) isDir() bool { 27 | return info.parent == nil || info.stat.Mode()&syscall.S_IFDIR != 0 28 | } 29 | 30 | func getIno(fi os.FileInfo) uint64 { 31 | return uint64(fi.Sys().(*syscall.Stat_t).Ino) 32 | } 33 | 34 | func hasHardlinks(fi os.FileInfo) bool { 35 | return fi.Sys().(*syscall.Stat_t).Nlink > 1 36 | } 37 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/duration.go: -------------------------------------------------------------------------------- 1 | // Package units provides helper function to parse and print size and time units 2 | // in human-readable format. 3 | package units 4 | 5 | import ( 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | // HumanDuration returns a human-readable approximation of a duration 11 | // (eg. "About a minute", "4 hours ago", etc.). 12 | func HumanDuration(d time.Duration) string { 13 | if seconds := int(d.Seconds()); seconds < 1 { 14 | return "Less than a second" 15 | } else if seconds < 60 { 16 | return fmt.Sprintf("%d seconds", seconds) 17 | } else if minutes := int(d.Minutes()); minutes == 1 { 18 | return "About a minute" 19 | } else if minutes < 60 { 20 | return fmt.Sprintf("%d minutes", minutes) 21 | } else if hours := int(d.Hours()); hours == 1 { 22 | return "About an hour" 23 | } else if hours < 48 { 24 | return fmt.Sprintf("%d hours", hours) 25 | } else if hours < 24*7*2 { 26 | return fmt.Sprintf("%d days", hours/24) 27 | } else if hours < 24*30*3 { 28 | return fmt.Sprintf("%d weeks", hours/24/7) 29 | } else if hours < 24*365*2 { 30 | return fmt.Sprintf("%d months", hours/24/30) 31 | } 32 | return fmt.Sprintf("%d years", int(d.Hours())/24/365) 33 | } 34 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/homedir/homedir.go: -------------------------------------------------------------------------------- 1 | package homedir 2 | 3 | import ( 4 | "os" 5 | "runtime" 6 | 7 | "github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user" 8 | ) 9 | 10 | // Key returns the env var name for the user's home dir based on 11 | // the platform being run on 12 | func Key() string { 13 | if runtime.GOOS == "windows" { 14 | return "USERPROFILE" 15 | } 16 | return "HOME" 17 | } 18 | 19 | // Get returns the home directory of the current user with the help of 20 | // environment variables depending on the target operating system. 21 | // Returned path should be used with "path/filepath" to form new paths. 22 | func Get() string { 23 | home := os.Getenv(Key()) 24 | if home == "" && runtime.GOOS != "windows" { 25 | if u, err := user.CurrentUser(); err == nil { 26 | return u.Home 27 | } 28 | } 29 | return home 30 | } 31 | 32 | // GetShortcutString returns the string that is shortcut to user's home directory 33 | // in the native shell of the platform running on. 34 | func GetShortcutString() string { 35 | if runtime.GOOS == "windows" { 36 | return "%USERPROFILE%" // be careful while using in format functions 37 | } 38 | return "~" 39 | } 40 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp/cleanhttp.go: -------------------------------------------------------------------------------- 1 | package cleanhttp 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "runtime" 7 | "time" 8 | ) 9 | 10 | // DefaultTransport returns a new http.Transport with the same default values 11 | // as http.DefaultTransport 12 | func DefaultTransport() *http.Transport { 13 | transport := &http.Transport{ 14 | Proxy: http.ProxyFromEnvironment, 15 | Dial: (&net.Dialer{ 16 | Timeout: 30 * time.Second, 17 | KeepAlive: 30 * time.Second, 18 | }).Dial, 19 | TLSHandshakeTimeout: 10 * time.Second, 20 | } 21 | SetTransportFinalizer(transport) 22 | return transport 23 | } 24 | 25 | // DefaultClient returns a new http.Client with the same default values as 26 | // http.Client, but with a non-shared Transport 27 | func DefaultClient() *http.Client { 28 | return &http.Client{ 29 | Transport: DefaultTransport(), 30 | } 31 | } 32 | 33 | // SetTransportFinalizer sets a finalizer on the transport to ensure that 34 | // idle connections are closed prior to garbage collection; otherwise 35 | // these may leak 36 | func SetTransportFinalizer(transport *http.Transport) { 37 | runtime.SetFinalizer(&transport, func(t **http.Transport) { 38 | (*t).CloseIdleConnections() 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/whiteouts.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | // Whiteouts are files with a special meaning for the layered filesystem. 4 | // Docker uses AUFS whiteout files inside exported archives. In other 5 | // filesystems these files are generated/handled on tar creation/extraction. 6 | 7 | // WhiteoutPrefix prefix means file is a whiteout. If this is followed by a 8 | // filename this means that file has been removed from the base layer. 9 | const WhiteoutPrefix = ".wh." 10 | 11 | // WhiteoutMetaPrefix prefix means whiteout has a special meaning and is not 12 | // for removing an actual file. Normally these files are excluded from exported 13 | // archives. 14 | const WhiteoutMetaPrefix = WhiteoutPrefix + WhiteoutPrefix 15 | 16 | // WhiteoutLinkDir is a directory AUFS uses for storing hardlink links to other 17 | // layers. Normally these should not go into exported archives and all changed 18 | // hardlinks should be copied to the top layer. 19 | const WhiteoutLinkDir = WhiteoutMetaPrefix + "plnk" 20 | 21 | // WhiteoutOpaqueDir file means directory has been made opaque - meaning 22 | // readdir calls to this directory do not follow to lower layers. 23 | const WhiteoutOpaqueDir = WhiteoutMetaPrefix + ".opq" 24 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "time" 7 | "unsafe" 8 | ) 9 | 10 | var ( 11 | maxTime time.Time 12 | ) 13 | 14 | func init() { 15 | if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 { 16 | // This is a 64 bit timespec 17 | // os.Chtimes limits time to the following 18 | maxTime = time.Unix(0, 1<<63-1) 19 | } else { 20 | // This is a 32 bit timespec 21 | maxTime = time.Unix(1<<31-1, 0) 22 | } 23 | } 24 | 25 | // Chtimes changes the access time and modified time of a file at the given path 26 | func Chtimes(name string, atime time.Time, mtime time.Time) error { 27 | unixMinTime := time.Unix(0, 0) 28 | unixMaxTime := maxTime 29 | 30 | // If the modified time is prior to the Unix Epoch, or after the 31 | // end of Unix Time, os.Chtimes has undefined behavior 32 | // default to Unix Epoch in this case, just in case 33 | 34 | if atime.Before(unixMinTime) || atime.After(unixMaxTime) { 35 | atime = unixMinTime 36 | } 37 | 38 | if mtime.Before(unixMinTime) || mtime.After(unixMaxTime) { 39 | mtime = unixMinTime 40 | } 41 | 42 | if err := os.Chtimes(name, atime, mtime); err != nil { 43 | return err 44 | } 45 | 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = nsec % 1e9 / 1e3 24 | tv.Sec = nsec / 1e9 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/stat.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // StatT type contains status of a file. It contains metadata 10 | // like permission, owner, group, size, etc about a file. 11 | type StatT struct { 12 | mode uint32 13 | uid uint32 14 | gid uint32 15 | rdev uint64 16 | size int64 17 | mtim syscall.Timespec 18 | } 19 | 20 | // Mode returns file's permission mode. 21 | func (s StatT) Mode() uint32 { 22 | return s.mode 23 | } 24 | 25 | // UID returns file's user id of owner. 26 | func (s StatT) UID() uint32 { 27 | return s.uid 28 | } 29 | 30 | // GID returns file's group id of owner. 31 | func (s StatT) GID() uint32 { 32 | return s.gid 33 | } 34 | 35 | // Rdev returns file's device ID (if it's special file). 36 | func (s StatT) Rdev() uint64 { 37 | return s.rdev 38 | } 39 | 40 | // Size returns file's size. 41 | func (s StatT) Size() int64 { 42 | return s.size 43 | } 44 | 45 | // Mtim returns file's last modification time. 46 | func (s StatT) Mtim() syscall.Timespec { 47 | return s.mtim 48 | } 49 | 50 | // GetLastModification returns file's last modification time. 51 | func (s StatT) GetLastModification() syscall.Timespec { 52 | return s.Mtim() 53 | } 54 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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+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 <){ 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 '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print < The Client's Transport typically has internal state (cached TCP connections), 13 | so Clients should be reused instead of created as needed. Clients are safe for 14 | concurrent use by multiple goroutines. 15 | 16 | Unfortunately, this is a shared value, and it is not uncommon for libraries to 17 | assume that they are free to modify it at will. With enough dependencies, it 18 | can be very easy to encounter strange problems and race conditions due to 19 | manipulation of this shared value across libraries and goroutines (clients are 20 | safe for concurrent use, but writing values to the client struct itself is not 21 | protected). 22 | 23 | Making things worse is the fact that a bare `http.Client` will use a default 24 | `http.Transport` called `http.DefaultTransport`, which is another global value 25 | that behaves the same way. So it is not simply enough to replace 26 | `http.DefaultClient` with `&http.Client{}`. 27 | 28 | This repository provides some simple functions to get a "clean" `http.Client` 29 | -- one that uses the same default values as the Go standard library, but 30 | returns a client that does not share any state with other clients. 31 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/wrap.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "archive/tar" 5 | "bytes" 6 | "io/ioutil" 7 | ) 8 | 9 | // Generate generates a new archive from the content provided 10 | // as input. 11 | // 12 | // `files` is a sequence of path/content pairs. A new file is 13 | // added to the archive for each pair. 14 | // If the last pair is incomplete, the file is created with an 15 | // empty content. For example: 16 | // 17 | // Generate("foo.txt", "hello world", "emptyfile") 18 | // 19 | // The above call will return an archive with 2 files: 20 | // * ./foo.txt with content "hello world" 21 | // * ./empty with empty content 22 | // 23 | // FIXME: stream content instead of buffering 24 | // FIXME: specify permissions and other archive metadata 25 | func Generate(input ...string) (Archive, error) { 26 | files := parseStringPairs(input...) 27 | buf := new(bytes.Buffer) 28 | tw := tar.NewWriter(buf) 29 | for _, file := range files { 30 | name, content := file[0], file[1] 31 | hdr := &tar.Header{ 32 | Name: name, 33 | Size: int64(len(content)), 34 | } 35 | if err := tw.WriteHeader(hdr); err != nil { 36 | return nil, err 37 | } 38 | if _, err := tw.Write([]byte(content)); err != nil { 39 | return nil, err 40 | } 41 | } 42 | if err := tw.Close(); err != nil { 43 | return nil, err 44 | } 45 | return ioutil.NopCloser(buf), nil 46 | } 47 | 48 | func parseStringPairs(input ...string) (output [][2]string) { 49 | output = make([][2]string, 0, len(input)/2+1) 50 | for i := 0; i < len(input); i += 2 { 51 | var pair [2]string 52 | pair[0] = input[i] 53 | if i+1 < len(input) { 54 | pair[1] = input[i+1] 55 | } 56 | output = append(output, pair) 57 | } 58 | return 59 | } 60 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/meminfo_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "os" 7 | "strconv" 8 | "strings" 9 | 10 | "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units" 11 | ) 12 | 13 | // ReadMemInfo retrieves memory statistics of the host system and returns a 14 | // MemInfo type. 15 | func ReadMemInfo() (*MemInfo, error) { 16 | file, err := os.Open("/proc/meminfo") 17 | if err != nil { 18 | return nil, err 19 | } 20 | defer file.Close() 21 | return parseMemInfo(file) 22 | } 23 | 24 | // parseMemInfo parses the /proc/meminfo file into 25 | // a MemInfo object given a io.Reader to the file. 26 | // 27 | // Throws error if there are problems reading from the file 28 | func parseMemInfo(reader io.Reader) (*MemInfo, error) { 29 | meminfo := &MemInfo{} 30 | scanner := bufio.NewScanner(reader) 31 | for scanner.Scan() { 32 | // Expected format: ["MemTotal:", "1234", "kB"] 33 | parts := strings.Fields(scanner.Text()) 34 | 35 | // Sanity checks: Skip malformed entries. 36 | if len(parts) < 3 || parts[2] != "kB" { 37 | continue 38 | } 39 | 40 | // Convert to bytes. 41 | size, err := strconv.Atoi(parts[1]) 42 | if err != nil { 43 | continue 44 | } 45 | bytes := int64(size) * units.KiB 46 | 47 | switch parts[0] { 48 | case "MemTotal:": 49 | meminfo.MemTotal = bytes 50 | case "MemFree:": 51 | meminfo.MemFree = bytes 52 | case "SwapTotal:": 53 | meminfo.SwapTotal = bytes 54 | case "SwapFree:": 55 | meminfo.SwapFree = bytes 56 | } 57 | 58 | } 59 | 60 | // Handle errors that may have occurred during the reading of the file. 61 | if err := scanner.Err(); err != nil { 62 | return nil, err 63 | } 64 | 65 | return meminfo, nil 66 | } 67 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/gccgo.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 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writers.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import "io" 4 | 5 | // NopWriter represents a type which write operation is nop. 6 | type NopWriter struct{} 7 | 8 | func (*NopWriter) Write(buf []byte) (int, error) { 9 | return len(buf), nil 10 | } 11 | 12 | type nopWriteCloser struct { 13 | io.Writer 14 | } 15 | 16 | func (w *nopWriteCloser) Close() error { return nil } 17 | 18 | // NopWriteCloser returns a nopWriteCloser. 19 | func NopWriteCloser(w io.Writer) io.WriteCloser { 20 | return &nopWriteCloser{w} 21 | } 22 | 23 | // NopFlusher represents a type which flush operation is nop. 24 | type NopFlusher struct{} 25 | 26 | // Flush is a nop operation. 27 | func (f *NopFlusher) Flush() {} 28 | 29 | type writeCloserWrapper struct { 30 | io.Writer 31 | closer func() error 32 | } 33 | 34 | func (r *writeCloserWrapper) Close() error { 35 | return r.closer() 36 | } 37 | 38 | // NewWriteCloserWrapper returns a new io.WriteCloser. 39 | func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser { 40 | return &writeCloserWrapper{ 41 | Writer: r, 42 | closer: closer, 43 | } 44 | } 45 | 46 | // WriteCounter wraps a concrete io.Writer and hold a count of the number 47 | // of bytes written to the writer during a "session". 48 | // This can be convenient when write return is masked 49 | // (e.g., json.Encoder.Encode()) 50 | type WriteCounter struct { 51 | Count int64 52 | Writer io.Writer 53 | } 54 | 55 | // NewWriteCounter returns a new WriteCounter. 56 | func NewWriteCounter(w io.Writer) *WriteCounter { 57 | return &WriteCounter{ 58 | Writer: w, 59 | } 60 | } 61 | 62 | func (wc *WriteCounter) Write(p []byte) (count int, err error) { 63 | count, err = wc.Writer.Write(p) 64 | wc.Count += int64(count) 65 | return 66 | } 67 | -------------------------------------------------------------------------------- /docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | echo "APT::Install-Recommends false;" >> /etc/apt/apt.conf.d/recommends.conf 4 | echo "APT::Install-Suggests false;" >> /etc/apt/apt.conf.d/recommends.conf 5 | echo "APT::AutoRemove::RecommendsImportant false;" >> /etc/apt/apt.conf.d/recommends.conf 6 | echo "APT::AutoRemove::SuggestsImportant false;" >> /etc/apt/apt.conf.d/recommends.conf 7 | 8 | apt-get update 9 | apt-get install -y collectd git curl ca-certificates && \ 10 | 11 | export GOLANG_VERSION="1.6" 12 | export GOLANG_DOWNLOAD_URL="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" 13 | export GOLANG_DOWNLOAD_SHA256="5470eac05d273c74ff8bac7bef5bad0b5abbd1c4052efbdbc8db45332e836b0b" 14 | export GOLANG_DOWNLOAD_DESTINATION="/tmp/go${GOLANG_VERSION}.linux-amd64.tar.gz" 15 | 16 | curl -sL "${GOLANG_DOWNLOAD_URL}" > "${GOLANG_DOWNLOAD_DESTINATION}" 17 | echo "${GOLANG_DOWNLOAD_SHA256} ${GOLANG_DOWNLOAD_DESTINATION}" | sha256sum -c 18 | tar -C /usr/local -xzf "${GOLANG_DOWNLOAD_DESTINATION}" 19 | rm "${GOLANG_DOWNLOAD_DESTINATION}" 20 | 21 | export GOPATH="/go" 22 | export PATH="${GOPATH}/bin:/usr/local/go/bin:${PATH}" 23 | 24 | go get github.com/docker-infra/reefer 25 | go get github.com/tools/godep 26 | 27 | cd /go/src/github.com/bobrik/collectd-docker/collector 28 | godep restore 29 | go get github.com/bobrik/collectd-docker/collector/... 30 | 31 | cd / 32 | 33 | cp /go/bin/collectd-docker-collector /usr/bin/collectd-docker-collector 34 | cp /go/bin/reefer /usr/bin/reefer 35 | 36 | cp /go/src/github.com/bobrik/collectd-docker/docker/collectd.conf.tpl /etc/collectd/collectd.conf.tpl 37 | cp /go/src/github.com/bobrik/collectd-docker/docker/run.sh /run.sh 38 | 39 | apt-get remove -y git curl ca-certificates 40 | apt-get autoremove -y 41 | 42 | rm -rf /go /usr/local/go 43 | rm -rf /var/lib/apt/lists/* 44 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/syscall_freebsd_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,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = nsec / 1e9 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/syscall_dragonfly_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,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 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 writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/mksysnum_freebsd.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 FreeBSD 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_freebsd.pl " . join(' ', @ARGV); 17 | 18 | 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 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print <>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/xattrs_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // Lgetxattr retrieves the value of the extended attribute identified by attr 9 | // and associated with the given path in the file system. 10 | // It will returns a nil slice and nil error if the xattr is not set. 11 | func Lgetxattr(path string, attr string) ([]byte, error) { 12 | pathBytes, err := syscall.BytePtrFromString(path) 13 | if err != nil { 14 | return nil, err 15 | } 16 | attrBytes, err := syscall.BytePtrFromString(attr) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | dest := make([]byte, 128) 22 | destBytes := unsafe.Pointer(&dest[0]) 23 | sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 24 | if errno == syscall.ENODATA { 25 | return nil, nil 26 | } 27 | if errno == syscall.ERANGE { 28 | dest = make([]byte, sz) 29 | destBytes := unsafe.Pointer(&dest[0]) 30 | sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 31 | } 32 | if errno != 0 { 33 | return nil, errno 34 | } 35 | 36 | return dest[:sz], nil 37 | } 38 | 39 | var _zero uintptr 40 | 41 | // Lsetxattr sets the value of the extended attribute identified by attr 42 | // and associated with the given path in the file system. 43 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 44 | pathBytes, err := syscall.BytePtrFromString(path) 45 | if err != nil { 46 | return err 47 | } 48 | attrBytes, err := syscall.BytePtrFromString(attr) 49 | if err != nil { 50 | return err 51 | } 52 | var dataBytes unsafe.Pointer 53 | if len(data) > 0 { 54 | dataBytes = unsafe.Pointer(&data[0]) 55 | } else { 56 | dataBytes = unsafe.Pointer(&_zero) 57 | } 58 | _, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) 59 | if errno != 0 { 60 | return errno 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = int32(sec) 40 | tv.Usec = int32(usec) 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint32(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint32(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/filesys_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "path/filepath" 8 | "regexp" 9 | "strings" 10 | "syscall" 11 | ) 12 | 13 | // MkdirAll implementation that is volume path aware for Windows. 14 | func MkdirAll(path string, perm os.FileMode) error { 15 | if re := regexp.MustCompile(`^\\\\\?\\Volume{[a-z0-9-]+}$`); re.MatchString(path) { 16 | return nil 17 | } 18 | 19 | // The rest of this method is copied from os.MkdirAll and should be kept 20 | // as-is to ensure compatibility. 21 | 22 | // Fast path: if we can tell whether path is a directory or file, stop with success or error. 23 | dir, err := os.Stat(path) 24 | if err == nil { 25 | if dir.IsDir() { 26 | return nil 27 | } 28 | return &os.PathError{ 29 | Op: "mkdir", 30 | Path: path, 31 | Err: syscall.ENOTDIR, 32 | } 33 | } 34 | 35 | // Slow path: make sure parent exists and then call Mkdir for path. 36 | i := len(path) 37 | for i > 0 && os.IsPathSeparator(path[i-1]) { // Skip trailing path separator. 38 | i-- 39 | } 40 | 41 | j := i 42 | for j > 0 && !os.IsPathSeparator(path[j-1]) { // Scan backward over element. 43 | j-- 44 | } 45 | 46 | if j > 1 { 47 | // Create parent 48 | err = MkdirAll(path[0:j-1], perm) 49 | if err != nil { 50 | return err 51 | } 52 | } 53 | 54 | // Parent now exists; invoke Mkdir and use its result. 55 | err = os.Mkdir(path, perm) 56 | if err != nil { 57 | // Handle arguments like "foo/." by 58 | // double-checking that directory doesn't exist. 59 | dir, err1 := os.Lstat(path) 60 | if err1 == nil && dir.IsDir() { 61 | return nil 62 | } 63 | return err 64 | } 65 | return nil 66 | } 67 | 68 | // IsAbs is a platform-specific wrapper for filepath.IsAbs. On Windows, 69 | // golang filepath.IsAbs does not consider a path \windows\system32 as absolute 70 | // as it doesn't start with a drive-letter/colon combination. However, in 71 | // docker we need to verify things such as WORKDIR /windows/system32 in 72 | // a Dockerfile (which gets translated to \windows\system32 when being processed 73 | // by the daemon. This SHOULD be treated as absolute from a docker processing 74 | // perspective. 75 | func IsAbs(path string) bool { 76 | if !filepath.IsAbs(path) { 77 | if !strings.HasPrefix(path, string(os.PathSeparator)) { 78 | return false 79 | } 80 | } 81 | return true 82 | } 83 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/envfile.go: -------------------------------------------------------------------------------- 1 | package opts 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // ParseEnvFile reads a file with environment variables enumerated by lines 11 | // 12 | // ``Environment variable names used by the utilities in the Shell and 13 | // Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase 14 | // letters, digits, and the '_' (underscore) from the characters defined in 15 | // Portable Character Set and do not begin with a digit. *But*, other 16 | // characters may be permitted by an implementation; applications shall 17 | // tolerate the presence of such names.'' 18 | // -- http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html 19 | // 20 | // As of #16585, it's up to application inside docker to validate or not 21 | // environment variables, that's why we just strip leading whitespace and 22 | // nothing more. 23 | func ParseEnvFile(filename string) ([]string, error) { 24 | fh, err := os.Open(filename) 25 | if err != nil { 26 | return []string{}, err 27 | } 28 | defer fh.Close() 29 | 30 | lines := []string{} 31 | scanner := bufio.NewScanner(fh) 32 | for scanner.Scan() { 33 | // trim the line from all leading whitespace first 34 | line := strings.TrimLeft(scanner.Text(), whiteSpaces) 35 | // line is not empty, and not starting with '#' 36 | if len(line) > 0 && !strings.HasPrefix(line, "#") { 37 | data := strings.SplitN(line, "=", 2) 38 | 39 | // trim the front of a variable, but nothing else 40 | variable := strings.TrimLeft(data[0], whiteSpaces) 41 | if strings.ContainsAny(variable, whiteSpaces) { 42 | return []string{}, ErrBadEnvVariable{fmt.Sprintf("variable '%s' has white spaces", variable)} 43 | } 44 | 45 | if len(data) > 1 { 46 | 47 | // pass the value through, no trimming 48 | lines = append(lines, fmt.Sprintf("%s=%s", variable, data[1])) 49 | } else { 50 | // if only a pass-through variable is given, clean it up. 51 | lines = append(lines, fmt.Sprintf("%s=%s", strings.TrimSpace(line), os.Getenv(line))) 52 | } 53 | } 54 | } 55 | return lines, scanner.Err() 56 | } 57 | 58 | var whiteSpaces = " \t" 59 | 60 | // ErrBadEnvVariable typed error for bad environment variable 61 | type ErrBadEnvVariable struct { 62 | msg string 63 | } 64 | 65 | func (e ErrBadEnvVariable) Error() string { 66 | return fmt.Sprintf("poorly formatted environment: %s", e.msg) 67 | } 68 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 27 | 28 | func NsecToTimeval(nsec int64) (tv Timeval) { 29 | nsec += 999 // round up to microsecond 30 | tv.Usec = int32(nsec % 1e9 / 1e3) 31 | tv.Sec = int64(nsec / 1e9) 32 | return 33 | } 34 | 35 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 36 | func Gettimeofday(tv *Timeval) (err error) { 37 | // The tv passed to gettimeofday must be non-nil 38 | // but is otherwise unused. The answers come back 39 | // in the two registers. 40 | sec, usec, err := gettimeofday(tv) 41 | tv.Sec = sec 42 | tv.Usec = usec 43 | return err 44 | } 45 | 46 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 47 | k.Ident = uint64(fd) 48 | k.Filter = int16(mode) 49 | k.Flags = uint16(flags) 50 | } 51 | 52 | func (iov *Iovec) SetLen(length int) { 53 | iov.Len = uint64(length) 54 | } 55 | 56 | func (msghdr *Msghdr) SetControllen(length int) { 57 | msghdr.Controllen = uint32(length) 58 | } 59 | 60 | func (cmsg *Cmsghdr) SetLen(length int) { 61 | cmsg.Len = uint32(length) 62 | } 63 | 64 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 65 | var length = uint64(count) 66 | 67 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 68 | 69 | written = int(length) 70 | 71 | if e1 != 0 { 72 | err = e1 73 | } 74 | return 75 | } 76 | 77 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 78 | 79 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 80 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 81 | const SYS___SYSCTL = SYS_SYSCTL 82 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/archive_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package archive 4 | 5 | import ( 6 | "archive/tar" 7 | "fmt" 8 | "os" 9 | "path/filepath" 10 | "strings" 11 | 12 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath" 13 | ) 14 | 15 | // fixVolumePathPrefix does platform specific processing to ensure that if 16 | // the path being passed in is not in a volume path format, convert it to one. 17 | func fixVolumePathPrefix(srcPath string) string { 18 | return longpath.AddPrefix(srcPath) 19 | } 20 | 21 | // getWalkRoot calculates the root path when performing a TarWithOptions. 22 | // We use a separate function as this is platform specific. 23 | func getWalkRoot(srcPath string, include string) string { 24 | return filepath.Join(srcPath, include) 25 | } 26 | 27 | // CanonicalTarNameForPath returns platform-specific filepath 28 | // to canonical posix-style path for tar archival. p is relative 29 | // path. 30 | func CanonicalTarNameForPath(p string) (string, error) { 31 | // windows: convert windows style relative path with backslashes 32 | // into forward slashes. Since windows does not allow '/' or '\' 33 | // in file names, it is mostly safe to replace however we must 34 | // check just in case 35 | if strings.Contains(p, "/") { 36 | return "", fmt.Errorf("Windows path contains forward slash: %s", p) 37 | } 38 | return strings.Replace(p, string(os.PathSeparator), "/", -1), nil 39 | 40 | } 41 | 42 | // chmodTarEntry is used to adjust the file permissions used in tar header based 43 | // on the platform the archival is done. 44 | func chmodTarEntry(perm os.FileMode) os.FileMode { 45 | perm &= 0755 46 | // Add the x bit: make everything +x from windows 47 | perm |= 0111 48 | 49 | return perm 50 | } 51 | 52 | func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (inode uint64, err error) { 53 | // do nothing. no notion of Rdev, Inode, Nlink in stat on Windows 54 | return 55 | } 56 | 57 | // handleTarTypeBlockCharFifo is an OS-specific helper function used by 58 | // createTarFile to handle the following types of header: Block; Char; Fifo 59 | func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { 60 | return nil 61 | } 62 | 63 | func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error { 64 | return nil 65 | } 66 | 67 | func getFileUIDGID(stat interface{}) (int, int, error) { 68 | // no notion of file ownership mapping yet on Windows 69 | return 0, 0, nil 70 | } 71 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/changes_other.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package archive 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "path/filepath" 9 | "runtime" 10 | "strings" 11 | 12 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system" 13 | ) 14 | 15 | func collectFileInfoForChanges(oldDir, newDir string) (*FileInfo, *FileInfo, error) { 16 | var ( 17 | oldRoot, newRoot *FileInfo 18 | err1, err2 error 19 | errs = make(chan error, 2) 20 | ) 21 | go func() { 22 | oldRoot, err1 = collectFileInfo(oldDir) 23 | errs <- err1 24 | }() 25 | go func() { 26 | newRoot, err2 = collectFileInfo(newDir) 27 | errs <- err2 28 | }() 29 | 30 | // block until both routines have returned 31 | for i := 0; i < 2; i++ { 32 | if err := <-errs; err != nil { 33 | return nil, nil, err 34 | } 35 | } 36 | 37 | return oldRoot, newRoot, nil 38 | } 39 | 40 | func collectFileInfo(sourceDir string) (*FileInfo, error) { 41 | root := newRootFileInfo() 42 | 43 | err := filepath.Walk(sourceDir, func(path string, f os.FileInfo, err error) error { 44 | if err != nil { 45 | return err 46 | } 47 | 48 | // Rebase path 49 | relPath, err := filepath.Rel(sourceDir, path) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | // As this runs on the daemon side, file paths are OS specific. 55 | relPath = filepath.Join(string(os.PathSeparator), relPath) 56 | 57 | // See https://github.com/golang/go/issues/9168 - bug in filepath.Join. 58 | // Temporary workaround. If the returned path starts with two backslashes, 59 | // trim it down to a single backslash. Only relevant on Windows. 60 | if runtime.GOOS == "windows" { 61 | if strings.HasPrefix(relPath, `\\`) { 62 | relPath = relPath[1:] 63 | } 64 | } 65 | 66 | if relPath == string(os.PathSeparator) { 67 | return nil 68 | } 69 | 70 | parent := root.LookUp(filepath.Dir(relPath)) 71 | if parent == nil { 72 | return fmt.Errorf("collectFileInfo: Unexpectedly no parent for %s", relPath) 73 | } 74 | 75 | info := &FileInfo{ 76 | name: filepath.Base(relPath), 77 | children: make(map[string]*FileInfo), 78 | parent: parent, 79 | } 80 | 81 | s, err := system.Lstat(path) 82 | if err != nil { 83 | return err 84 | } 85 | info.stat = s 86 | 87 | info.capability, _ = system.Lgetxattr(path, "security.capability") 88 | 89 | parent.children[info.name] = info 90 | 91 | return nil 92 | }) 93 | if err != nil { 94 | return nil, err 95 | } 96 | return root, nil 97 | } 98 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils/writeflusher.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "net/http" 7 | "sync" 8 | ) 9 | 10 | // WriteFlusher wraps the Write and Flush operation ensuring that every write 11 | // is a flush. In addition, the Close method can be called to intercept 12 | // Read/Write calls if the targets lifecycle has already ended. 13 | type WriteFlusher struct { 14 | mu sync.Mutex 15 | w io.Writer 16 | flusher http.Flusher 17 | flushed bool 18 | closed error 19 | 20 | // TODO(stevvooe): Use channel for closed instead, remove mutex. Using a 21 | // channel will allow one to properly order the operations. 22 | } 23 | 24 | var errWriteFlusherClosed = errors.New("writeflusher: closed") 25 | 26 | func (wf *WriteFlusher) Write(b []byte) (n int, err error) { 27 | wf.mu.Lock() 28 | defer wf.mu.Unlock() 29 | if wf.closed != nil { 30 | return 0, wf.closed 31 | } 32 | 33 | n, err = wf.w.Write(b) 34 | wf.flush() // every write is a flush. 35 | return n, err 36 | } 37 | 38 | // Flush the stream immediately. 39 | func (wf *WriteFlusher) Flush() { 40 | wf.mu.Lock() 41 | defer wf.mu.Unlock() 42 | 43 | wf.flush() 44 | } 45 | 46 | // flush the stream immediately without taking a lock. Used internally. 47 | func (wf *WriteFlusher) flush() { 48 | if wf.closed != nil { 49 | return 50 | } 51 | 52 | wf.flushed = true 53 | wf.flusher.Flush() 54 | } 55 | 56 | // Flushed returns the state of flushed. 57 | // If it's flushed, return true, or else it return false. 58 | func (wf *WriteFlusher) Flushed() bool { 59 | // BUG(stevvooe): Remove this method. Its use is inherently racy. Seems to 60 | // be used to detect whether or a response code has been issued or not. 61 | // Another hook should be used instead. 62 | wf.mu.Lock() 63 | defer wf.mu.Unlock() 64 | 65 | return wf.flushed 66 | } 67 | 68 | // Close closes the write flusher, disallowing any further writes to the 69 | // target. After the flusher is closed, all calls to write or flush will 70 | // result in an error. 71 | func (wf *WriteFlusher) Close() error { 72 | wf.mu.Lock() 73 | defer wf.mu.Unlock() 74 | 75 | if wf.closed != nil { 76 | return wf.closed 77 | } 78 | 79 | wf.closed = errWriteFlusherClosed 80 | return nil 81 | } 82 | 83 | // NewWriteFlusher returns a new WriteFlusher. 84 | func NewWriteFlusher(w io.Writer) *WriteFlusher { 85 | var flusher http.Flusher 86 | if f, ok := w.(http.Flusher); ok { 87 | flusher = f 88 | } else { 89 | flusher = &NopFlusher{} 90 | } 91 | return &WriteFlusher{w: w, flusher: flusher} 92 | } 93 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/tls.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient 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 | // The content is borrowed from Docker's own source code to provide a simple 6 | // tls based dialer 7 | 8 | package docker 9 | 10 | import ( 11 | "crypto/tls" 12 | "errors" 13 | "net" 14 | "strings" 15 | "time" 16 | ) 17 | 18 | type tlsClientCon struct { 19 | *tls.Conn 20 | rawConn net.Conn 21 | } 22 | 23 | func (c *tlsClientCon) CloseWrite() error { 24 | // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it 25 | // on its underlying connection. 26 | if cwc, ok := c.rawConn.(interface { 27 | CloseWrite() error 28 | }); ok { 29 | return cwc.CloseWrite() 30 | } 31 | return nil 32 | } 33 | 34 | func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { 35 | // We want the Timeout and Deadline values from dialer to cover the 36 | // whole process: TCP connection and TLS handshake. This means that we 37 | // also need to start our own timers now. 38 | timeout := dialer.Timeout 39 | 40 | if !dialer.Deadline.IsZero() { 41 | deadlineTimeout := dialer.Deadline.Sub(time.Now()) 42 | if timeout == 0 || deadlineTimeout < timeout { 43 | timeout = deadlineTimeout 44 | } 45 | } 46 | 47 | var errChannel chan error 48 | 49 | if timeout != 0 { 50 | errChannel = make(chan error, 2) 51 | time.AfterFunc(timeout, func() { 52 | errChannel <- errors.New("") 53 | }) 54 | } 55 | 56 | rawConn, err := dialer.Dial(network, addr) 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | colonPos := strings.LastIndex(addr, ":") 62 | if colonPos == -1 { 63 | colonPos = len(addr) 64 | } 65 | hostname := addr[:colonPos] 66 | 67 | // If no ServerName is set, infer the ServerName 68 | // from the hostname we're connecting to. 69 | if config.ServerName == "" { 70 | // Make a copy to avoid polluting argument or default. 71 | c := *config 72 | c.ServerName = hostname 73 | config = &c 74 | } 75 | 76 | conn := tls.Client(rawConn, config) 77 | 78 | if timeout == 0 { 79 | err = conn.Handshake() 80 | } else { 81 | go func() { 82 | errChannel <- conn.Handshake() 83 | }() 84 | 85 | err = <-errChannel 86 | } 87 | 88 | if err != nil { 89 | rawConn.Close() 90 | return nil, err 91 | } 92 | 93 | // This is Docker difference with standard's crypto/tls package: returned a 94 | // wrapper which holds both the TLS and raw connections. 95 | return &tlsClientCon{conn, rawConn}, nil 96 | } 97 | -------------------------------------------------------------------------------- /collector/collector.go: -------------------------------------------------------------------------------- 1 | package collector 2 | 3 | import ( 4 | "log" 5 | "sync" 6 | 7 | "github.com/fsouza/go-dockerclient" 8 | ) 9 | 10 | // Collector is responsible for discovering containers 11 | // for monitoring and writing stats 12 | type Collector struct { 13 | client *docker.Client 14 | ch chan Stats 15 | mutex sync.Mutex 16 | registered map[string]struct{} 17 | interval int 18 | } 19 | 20 | // NewCollector creates new Collector with specified docker client, 21 | // collectd stats writer and stat updating interval 22 | func NewCollector(client *docker.Client, w CollectdWriter, interval int) *Collector { 23 | ch := make(chan Stats) 24 | 25 | // TODO: this can be better, need to figure out how 26 | go func() { 27 | for s := range ch { 28 | w.Write(s) 29 | } 30 | }() 31 | 32 | return &Collector{ 33 | client: client, 34 | ch: ch, 35 | mutex: sync.Mutex{}, 36 | registered: map[string]struct{}{}, 37 | interval: interval, 38 | } 39 | } 40 | 41 | // Run stats loop that discovers containers and runs 42 | // monitoring tasks for them 43 | func (c *Collector) Run(interval int) error { 44 | ch := make(chan *docker.APIEvents) 45 | err := c.client.AddEventListener(ch) 46 | if err != nil { 47 | return err 48 | } 49 | 50 | defer c.client.RemoveEventListener(ch) 51 | 52 | containers, err := c.client.ListContainers(docker.ListContainersOptions{}) 53 | if err != nil { 54 | return err 55 | } 56 | 57 | for _, container := range containers { 58 | go c.handle(container.ID) 59 | } 60 | 61 | for e := range ch { 62 | switch e.Status { 63 | case "start", "restart": 64 | go c.handle(e.ID) 65 | } 66 | } 67 | 68 | return nil 69 | } 70 | 71 | func (c *Collector) handle(id string) { 72 | m, err := NewMonitor(c.client, id, c.interval) 73 | if err != nil { 74 | if err == ErrNoNeedToMonitor { 75 | return 76 | } 77 | 78 | log.Printf("error handling %s: %s\n", id, err) 79 | 80 | return 81 | } 82 | 83 | go func() { 84 | if !c.register(id) { 85 | return 86 | } 87 | 88 | err := m.handle(c.ch) 89 | if err != nil { 90 | log.Printf("error handling container for app %s: %s\n", m.app, err) 91 | } 92 | 93 | c.unregister(id) 94 | }() 95 | } 96 | 97 | func (c *Collector) register(id string) bool { 98 | c.mutex.Lock() 99 | defer c.mutex.Unlock() 100 | 101 | if _, ok := c.registered[id]; ok { 102 | return false 103 | } 104 | 105 | c.registered[id] = struct{}{} 106 | return true 107 | } 108 | 109 | func (c *Collector) unregister(id string) { 110 | c.mutex.Lock() 111 | delete(c.registered, id) 112 | c.mutex.Unlock() 113 | } 114 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/events_windows.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | // This file implements syscalls for Win32 events which are not implemented 4 | // in golang. 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | var ( 12 | procCreateEvent = modkernel32.NewProc("CreateEventW") 13 | procOpenEvent = modkernel32.NewProc("OpenEventW") 14 | procSetEvent = modkernel32.NewProc("SetEvent") 15 | procResetEvent = modkernel32.NewProc("ResetEvent") 16 | procPulseEvent = modkernel32.NewProc("PulseEvent") 17 | ) 18 | 19 | // CreateEvent implements win32 CreateEventW func in golang. It will create an event object. 20 | func CreateEvent(eventAttributes *syscall.SecurityAttributes, manualReset bool, initialState bool, name string) (handle syscall.Handle, err error) { 21 | namep, _ := syscall.UTF16PtrFromString(name) 22 | var _p1 uint32 23 | if manualReset { 24 | _p1 = 1 25 | } 26 | var _p2 uint32 27 | if initialState { 28 | _p2 = 1 29 | } 30 | r0, _, e1 := procCreateEvent.Call(uintptr(unsafe.Pointer(eventAttributes)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(namep))) 31 | use(unsafe.Pointer(namep)) 32 | handle = syscall.Handle(r0) 33 | if handle == syscall.InvalidHandle { 34 | err = e1 35 | } 36 | return 37 | } 38 | 39 | // OpenEvent implements win32 OpenEventW func in golang. It opens an event object. 40 | func OpenEvent(desiredAccess uint32, inheritHandle bool, name string) (handle syscall.Handle, err error) { 41 | namep, _ := syscall.UTF16PtrFromString(name) 42 | var _p1 uint32 43 | if inheritHandle { 44 | _p1 = 1 45 | } 46 | r0, _, e1 := procOpenEvent.Call(uintptr(desiredAccess), uintptr(_p1), uintptr(unsafe.Pointer(namep))) 47 | use(unsafe.Pointer(namep)) 48 | handle = syscall.Handle(r0) 49 | if handle == syscall.InvalidHandle { 50 | err = e1 51 | } 52 | return 53 | } 54 | 55 | // SetEvent implements win32 SetEvent func in golang. 56 | func SetEvent(handle syscall.Handle) (err error) { 57 | return setResetPulse(handle, procSetEvent) 58 | } 59 | 60 | // ResetEvent implements win32 ResetEvent func in golang. 61 | func ResetEvent(handle syscall.Handle) (err error) { 62 | return setResetPulse(handle, procResetEvent) 63 | } 64 | 65 | // PulseEvent implements win32 PulseEvent func in golang. 66 | func PulseEvent(handle syscall.Handle) (err error) { 67 | return setResetPulse(handle, procPulseEvent) 68 | } 69 | 70 | func setResetPulse(handle syscall.Handle, proc *syscall.LazyProc) (err error) { 71 | r0, _, _ := proc.Call(uintptr(handle)) 72 | if r0 != 0 { 73 | err = syscall.Errno(r0) 74 | } 75 | return 76 | } 77 | 78 | var temp unsafe.Pointer 79 | 80 | // use ensures a variable is kept alive without the GC freeing while still needed 81 | func use(p unsafe.Pointer) { 82 | temp = p 83 | } 84 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/example_changes.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Simple tool to create an archive stream from an old and new directory 4 | // 5 | // By default it will stream the comparison of two temporary directories with junk files 6 | package main 7 | 8 | import ( 9 | "flag" 10 | "fmt" 11 | "io" 12 | "io/ioutil" 13 | "os" 14 | "path" 15 | 16 | "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus" 17 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive" 18 | ) 19 | 20 | var ( 21 | flDebug = flag.Bool("D", false, "debugging output") 22 | flNewDir = flag.String("newdir", "", "") 23 | flOldDir = flag.String("olddir", "", "") 24 | log = logrus.New() 25 | ) 26 | 27 | func main() { 28 | flag.Usage = func() { 29 | fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)") 30 | fmt.Printf("%s [OPTIONS]\n", os.Args[0]) 31 | flag.PrintDefaults() 32 | } 33 | flag.Parse() 34 | log.Out = os.Stderr 35 | if (len(os.Getenv("DEBUG")) > 0) || *flDebug { 36 | logrus.SetLevel(logrus.DebugLevel) 37 | } 38 | var newDir, oldDir string 39 | 40 | if len(*flNewDir) == 0 { 41 | var err error 42 | newDir, err = ioutil.TempDir("", "docker-test-newDir") 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | defer os.RemoveAll(newDir) 47 | if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil { 48 | log.Fatal(err) 49 | } 50 | } else { 51 | newDir = *flNewDir 52 | } 53 | 54 | if len(*flOldDir) == 0 { 55 | oldDir, err := ioutil.TempDir("", "docker-test-oldDir") 56 | if err != nil { 57 | log.Fatal(err) 58 | } 59 | defer os.RemoveAll(oldDir) 60 | } else { 61 | oldDir = *flOldDir 62 | } 63 | 64 | changes, err := archive.ChangesDirs(newDir, oldDir) 65 | if err != nil { 66 | log.Fatal(err) 67 | } 68 | 69 | a, err := archive.ExportChanges(newDir, changes) 70 | if err != nil { 71 | log.Fatal(err) 72 | } 73 | defer a.Close() 74 | 75 | i, err := io.Copy(os.Stdout, a) 76 | if err != nil && err != io.EOF { 77 | log.Fatal(err) 78 | } 79 | fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i) 80 | } 81 | 82 | func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) { 83 | fileData := []byte("fooo") 84 | for n := 0; n < numberOfFiles; n++ { 85 | fileName := fmt.Sprintf("file-%d", n) 86 | if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil { 87 | return 0, err 88 | } 89 | if makeLinks { 90 | if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil { 91 | return 0, err 92 | } 93 | } 94 | } 95 | totalSize := numberOfFiles * len(fileData) 96 | return totalSize, nil 97 | } 98 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/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 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | // use is a no-op, but the compiler cannot see that it is. 72 | // Calling use(p) ensures that p is kept live until that point. 73 | //go:noescape 74 | func use(p unsafe.Pointer) 75 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Fields type, used to pass to `WithFields`. 9 | type Fields map[string]interface{} 10 | 11 | // Level type 12 | type Level uint8 13 | 14 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 15 | func (level Level) String() string { 16 | switch level { 17 | case DebugLevel: 18 | return "debug" 19 | case InfoLevel: 20 | return "info" 21 | case WarnLevel: 22 | return "warning" 23 | case ErrorLevel: 24 | return "error" 25 | case FatalLevel: 26 | return "fatal" 27 | case PanicLevel: 28 | return "panic" 29 | } 30 | 31 | return "unknown" 32 | } 33 | 34 | // ParseLevel takes a string level and returns the Logrus log level constant. 35 | func ParseLevel(lvl string) (Level, error) { 36 | switch lvl { 37 | case "panic": 38 | return PanicLevel, nil 39 | case "fatal": 40 | return FatalLevel, nil 41 | case "error": 42 | return ErrorLevel, nil 43 | case "warn", "warning": 44 | return WarnLevel, nil 45 | case "info": 46 | return InfoLevel, nil 47 | case "debug": 48 | return DebugLevel, nil 49 | } 50 | 51 | var l Level 52 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 53 | } 54 | 55 | // These are the different logging levels. You can set the logging level to log 56 | // on your instance of logger, obtained with `logrus.New()`. 57 | const ( 58 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 59 | // message passed to Debug, Info, ... 60 | PanicLevel Level = iota 61 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 62 | // logging level is set to Panic. 63 | FatalLevel 64 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 65 | // Commonly used for hooks to send errors to an error tracking service. 66 | ErrorLevel 67 | // WarnLevel level. Non-critical entries that deserve eyes. 68 | WarnLevel 69 | // InfoLevel level. General operational entries about what's going on inside the 70 | // application. 71 | InfoLevel 72 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 73 | DebugLevel 74 | ) 75 | 76 | // Won't compile if StdLogger can't be realized by a log.Logger 77 | var ( 78 | _ StdLogger = &log.Logger{} 79 | _ StdLogger = &Entry{} 80 | _ StdLogger = &Logger{} 81 | ) 82 | 83 | // StdLogger is what your logrus-enabled library should take, that way 84 | // it'll accept a stdlib logger and a logrus logger. There's no standard 85 | // interface, this is the closest we get, unfortunately. 86 | type StdLogger interface { 87 | Print(...interface{}) 88 | Printf(string, ...interface{}) 89 | Println(...interface{}) 90 | 91 | Fatal(...interface{}) 92 | Fatalf(string, ...interface{}) 93 | Fatalln(...interface{}) 94 | 95 | Panic(...interface{}) 96 | Panicf(string, ...interface{}) 97 | Panicln(...interface{}) 98 | } 99 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/size.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | // See: http://en.wikipedia.org/wiki/Binary_prefix 11 | const ( 12 | // Decimal 13 | 14 | KB = 1000 15 | MB = 1000 * KB 16 | GB = 1000 * MB 17 | TB = 1000 * GB 18 | PB = 1000 * TB 19 | 20 | // Binary 21 | 22 | KiB = 1024 23 | MiB = 1024 * KiB 24 | GiB = 1024 * MiB 25 | TiB = 1024 * GiB 26 | PiB = 1024 * TiB 27 | ) 28 | 29 | type unitMap map[string]int64 30 | 31 | var ( 32 | decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB} 33 | binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB} 34 | sizeRegex = regexp.MustCompile(`^(\d+)([kKmMgGtTpP])?[bB]?$`) 35 | ) 36 | 37 | var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} 38 | var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} 39 | 40 | // CustomSize returns a human-readable approximation of a size 41 | // using custom format. 42 | func CustomSize(format string, size float64, base float64, _map []string) string { 43 | i := 0 44 | for size >= base { 45 | size = size / base 46 | i++ 47 | } 48 | return fmt.Sprintf(format, size, _map[i]) 49 | } 50 | 51 | // HumanSize returns a human-readable approximation of a size 52 | // capped at 4 valid numbers (eg. "2.746 MB", "796 KB"). 53 | func HumanSize(size float64) string { 54 | return CustomSize("%.4g %s", size, 1000.0, decimapAbbrs) 55 | } 56 | 57 | // BytesSize returns a human-readable size in bytes, kibibytes, 58 | // mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB"). 59 | func BytesSize(size float64) string { 60 | return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs) 61 | } 62 | 63 | // FromHumanSize returns an integer from a human-readable specification of a 64 | // size using SI standard (eg. "44kB", "17MB"). 65 | func FromHumanSize(size string) (int64, error) { 66 | return parseSize(size, decimalMap) 67 | } 68 | 69 | // RAMInBytes parses a human-readable string representing an amount of RAM 70 | // in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and 71 | // returns the number of bytes, or -1 if the string is unparseable. 72 | // Units are case-insensitive, and the 'b' suffix is optional. 73 | func RAMInBytes(size string) (int64, error) { 74 | return parseSize(size, binaryMap) 75 | } 76 | 77 | // Parses the human-readable size string into the amount it represents. 78 | func parseSize(sizeStr string, uMap unitMap) (int64, error) { 79 | matches := sizeRegex.FindStringSubmatch(sizeStr) 80 | if len(matches) != 3 { 81 | return -1, fmt.Errorf("invalid size: '%s'", sizeStr) 82 | } 83 | 84 | size, err := strconv.ParseInt(matches[1], 10, 0) 85 | if err != nil { 86 | return -1, err 87 | } 88 | 89 | unitPrefix := strings.ToLower(matches[2]) 90 | if mul, ok := uMap[unitPrefix]; ok { 91 | size *= mul 92 | } 93 | 94 | return size, nil 95 | } 96 | -------------------------------------------------------------------------------- /collector/writer.go: -------------------------------------------------------------------------------- 1 | package collector 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | const collectdIntGaugeTemplate = "PUTVAL %s/docker_stats-%s.%s/gauge-%s %d:%d\n" 9 | 10 | // CollectdWriter is responsible for writing data 11 | // to wrapped writer in collectd exec plugin format 12 | type CollectdWriter struct { 13 | host string 14 | writer io.Writer 15 | interval int 16 | } 17 | 18 | // NewCollectdWriter creates new CollectdWriter 19 | // with specified hostname and writer 20 | func NewCollectdWriter(host string, writer io.Writer) CollectdWriter { 21 | return CollectdWriter{ 22 | host: host, 23 | writer: writer, 24 | } 25 | } 26 | 27 | func (w CollectdWriter) Write(s Stats) error { 28 | return w.writeInts(s) 29 | } 30 | 31 | func (w CollectdWriter) writeInts(s Stats) error { 32 | metrics := map[string]uint64{ 33 | "cpu.user": s.Stats.CPUStats.CPUUsage.UsageInUsermode, 34 | "cpu.system": s.Stats.CPUStats.CPUUsage.UsageInKernelmode, 35 | "cpu.total": s.Stats.CPUStats.CPUUsage.TotalUsage, 36 | 37 | "memory.limit": s.Stats.MemoryStats.Limit, 38 | "memory.max": s.Stats.MemoryStats.MaxUsage, 39 | "memory.usage": s.Stats.MemoryStats.Usage, 40 | 41 | "memory.active_anon": s.Stats.MemoryStats.Stats.TotalActiveAnon, 42 | "memory.active_file": s.Stats.MemoryStats.Stats.TotalActiveFile, 43 | "memory.cache": s.Stats.MemoryStats.Stats.TotalCache, 44 | "memory.inactive_anon": s.Stats.MemoryStats.Stats.TotalInactiveAnon, 45 | "memory.inactive_file": s.Stats.MemoryStats.Stats.TotalInactiveFile, 46 | "memory.mapped_file": s.Stats.MemoryStats.Stats.TotalMappedFile, 47 | "memory.pg_fault": s.Stats.MemoryStats.Stats.TotalPgfault, 48 | "memory.pg_in": s.Stats.MemoryStats.Stats.TotalPgpgin, 49 | "memory.pg_out": s.Stats.MemoryStats.Stats.TotalPgpgout, 50 | "memory.rss": s.Stats.MemoryStats.Stats.TotalRss, 51 | "memory.rss_huge": s.Stats.MemoryStats.Stats.TotalRssHuge, 52 | "memory.unevictable": s.Stats.MemoryStats.Stats.TotalUnevictable, 53 | "memory.writeback": s.Stats.MemoryStats.Stats.TotalWriteback, 54 | } 55 | 56 | for _, network := range s.Stats.Networks { 57 | metrics["net.rx_bytes"] += network.RxBytes 58 | metrics["net.rx_dropped"] += network.RxDropped 59 | metrics["net.rx_errors"] += network.RxErrors 60 | metrics["net.rx_packets"] += network.RxPackets 61 | 62 | metrics["net.tx_bytes"] += network.TxBytes 63 | metrics["net.tx_dropped"] += network.TxDropped 64 | metrics["net.tx_errors"] += network.TxErrors 65 | metrics["net.tx_packets"] += network.TxPackets 66 | } 67 | 68 | t := s.Stats.Read.Unix() 69 | 70 | for k, v := range metrics { 71 | err := w.writeInt(s, k, t, v) 72 | if err != nil { 73 | return err 74 | } 75 | } 76 | 77 | return nil 78 | } 79 | 80 | func (w CollectdWriter) writeInt(s Stats, k string, t int64, v uint64) error { 81 | msg := fmt.Sprintf(collectdIntGaugeTemplate, w.host, s.App, s.Task, k, t, v) 82 | _, err := w.writer.Write([]byte(msg)) 83 | return err 84 | } 85 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to go-units 2 | 3 | Want to hack on go-units? Awesome! Here are instructions to get you started. 4 | 5 | go-units is a part of the [Docker](https://www.docker.com) project, and follows 6 | the same rules and principles. If you're already familiar with the way 7 | Docker does things, you'll feel right at home. 8 | 9 | Otherwise, go read Docker's 10 | [contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md), 11 | [issue triaging](https://github.com/docker/docker/blob/master/project/ISSUE-TRIAGE.md), 12 | [review process](https://github.com/docker/docker/blob/master/project/REVIEWING.md) and 13 | [branches and tags](https://github.com/docker/docker/blob/master/project/BRANCHES-AND-TAGS.md). 14 | 15 | ### Sign your work 16 | 17 | The sign-off is a simple line at the end of the explanation for the patch. Your 18 | signature certifies that you wrote the patch or otherwise have the right to pass 19 | it on as an open-source patch. The rules are pretty simple: if you can certify 20 | the below (from [developercertificate.org](http://developercertificate.org/)): 21 | 22 | ``` 23 | Developer Certificate of Origin 24 | Version 1.1 25 | 26 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 27 | 660 York Street, Suite 102, 28 | San Francisco, CA 94110 USA 29 | 30 | Everyone is permitted to copy and distribute verbatim copies of this 31 | license document, but changing it is not allowed. 32 | 33 | Developer's Certificate of Origin 1.1 34 | 35 | By making a contribution to this project, I certify that: 36 | 37 | (a) The contribution was created in whole or in part by me and I 38 | have the right to submit it under the open source license 39 | indicated in the file; or 40 | 41 | (b) The contribution is based upon previous work that, to the best 42 | of my knowledge, is covered under an appropriate open source 43 | license and I have the right under that license to submit that 44 | work with modifications, whether created in whole or in part 45 | by me, under the same open source license (unless I am 46 | permitted to submit under a different license), as indicated 47 | in the file; or 48 | 49 | (c) The contribution was provided directly to me by some other 50 | person who certified (a), (b) or (c) and I have not modified 51 | it. 52 | 53 | (d) I understand and agree that this project and the contribution 54 | are public and that a record of the contribution (including all 55 | personal information I submit with it, including my sign-off) is 56 | maintained indefinitely and may be redistributed consistent with 57 | this project or the open source license(s) involved. 58 | ``` 59 | 60 | Then you just add a line to every git commit message: 61 | 62 | Signed-off-by: Joe Smith 63 | 64 | Use your real name (sorry, no pseudonyms or anonymous contributions.) 65 | 66 | If you set your `user.name` and `user.email` git configs, you can sign your 67 | commit automatically with `git commit -s`. 68 | -------------------------------------------------------------------------------- /collector/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/bobrik/collectd-docker/collector", 3 | "GoVersion": "go1.6", 4 | "GodepVersion": "v60", 5 | "Deps": [ 6 | { 7 | "ImportPath": "github.com/fsouza/go-dockerclient", 8 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 9 | }, 10 | { 11 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus", 12 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 13 | }, 14 | { 15 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts", 16 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 17 | }, 18 | { 19 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive", 20 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 21 | }, 22 | { 23 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils", 24 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 25 | }, 26 | { 27 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/homedir", 28 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 29 | }, 30 | { 31 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools", 32 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 33 | }, 34 | { 35 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils", 36 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 37 | }, 38 | { 39 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath", 40 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 41 | }, 42 | { 43 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/pools", 44 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 45 | }, 46 | { 47 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/promise", 48 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 49 | }, 50 | { 51 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/stdcopy", 52 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 53 | }, 54 | { 55 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system", 56 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 57 | }, 58 | { 59 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units", 60 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 61 | }, 62 | { 63 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp", 64 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 65 | }, 66 | { 67 | "ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user", 68 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 69 | }, 70 | { 71 | "ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/net/context", 72 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 73 | }, 74 | { 75 | "ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix", 76 | "Rev": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" 77 | } 78 | ] 79 | } 80 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix/sockcmsg_unix.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin and DragonFly BSD kernels 17 | // still require 32-bit aligned access to network subsystem. 18 | if darwin64Bit || dragonfly64Bit { 19 | salign = 4 20 | } 21 | return (salen + salign - 1) & ^(salign - 1) 22 | } 23 | 24 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 25 | // structure, taking into account any necessary alignment. 26 | func CmsgLen(datalen int) int { 27 | return cmsgAlignOf(SizeofCmsghdr) + datalen 28 | } 29 | 30 | // CmsgSpace returns the number of bytes an ancillary element with 31 | // payload of the passed data length occupies. 32 | func CmsgSpace(datalen int) int { 33 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 34 | } 35 | 36 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 37 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 38 | } 39 | 40 | // SocketControlMessage represents a socket control message. 41 | type SocketControlMessage struct { 42 | Header Cmsghdr 43 | Data []byte 44 | } 45 | 46 | // ParseSocketControlMessage parses b as an array of socket control 47 | // messages. 48 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 49 | var msgs []SocketControlMessage 50 | i := 0 51 | for i+CmsgLen(0) <= len(b) { 52 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 53 | if err != nil { 54 | return nil, err 55 | } 56 | m := SocketControlMessage{Header: *h, Data: dbuf} 57 | msgs = append(msgs, m) 58 | i += cmsgAlignOf(int(h.Len)) 59 | } 60 | return msgs, nil 61 | } 62 | 63 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 64 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 65 | if h.Len < SizeofCmsghdr || int(h.Len) > len(b) { 66 | return nil, nil, EINVAL 67 | } 68 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 69 | } 70 | 71 | // UnixRights encodes a set of open file descriptors into a socket 72 | // control message for sending to another process. 73 | func UnixRights(fds ...int) []byte { 74 | datalen := len(fds) * 4 75 | b := make([]byte, CmsgSpace(datalen)) 76 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 77 | h.Level = SOL_SOCKET 78 | h.Type = SCM_RIGHTS 79 | h.SetLen(CmsgLen(datalen)) 80 | data := cmsgData(h) 81 | for _, fd := range fds { 82 | *(*int32)(data) = int32(fd) 83 | data = unsafe.Pointer(uintptr(data) + 4) 84 | } 85 | return b 86 | } 87 | 88 | // ParseUnixRights decodes a socket control message that contains an 89 | // integer array of open file descriptors from another process. 90 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 91 | if m.Header.Level != SOL_SOCKET { 92 | return nil, EINVAL 93 | } 94 | if m.Header.Type != SCM_RIGHTS { 95 | return nil, EINVAL 96 | } 97 | fds := make([]int, len(m.Data)>>2) 98 | for i, j := 0, 0; i < len(m.Data); i += 4 { 99 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 100 | j++ 101 | } 102 | return fds, nil 103 | } 104 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts/opts_windows.go: -------------------------------------------------------------------------------- 1 | package opts 2 | 3 | // TODO Windows. Identify bug in GOLang 1.5.1 and/or Windows Server 2016 TP4. 4 | // @jhowardmsft, @swernli. 5 | // 6 | // On Windows, this mitigates a problem with the default options of running 7 | // a docker client against a local docker daemon on TP4. 8 | // 9 | // What was found that if the default host is "localhost", even if the client 10 | // (and daemon as this is local) is not physically on a network, and the DNS 11 | // cache is flushed (ipconfig /flushdns), then the client will pause for 12 | // exactly one second when connecting to the daemon for calls. For example 13 | // using docker run windowsservercore cmd, the CLI will send a create followed 14 | // by an attach. You see the delay between the attach finishing and the attach 15 | // being seen by the daemon. 16 | // 17 | // Here's some daemon debug logs with additional debug spew put in. The 18 | // AfterWriteJSON log is the very last thing the daemon does as part of the 19 | // create call. The POST /attach is the second CLI call. Notice the second 20 | // time gap. 21 | // 22 | // time="2015-11-06T13:38:37.259627400-08:00" level=debug msg="After createRootfs" 23 | // time="2015-11-06T13:38:37.263626300-08:00" level=debug msg="After setHostConfig" 24 | // time="2015-11-06T13:38:37.267631200-08:00" level=debug msg="before createContainerPl...." 25 | // time="2015-11-06T13:38:37.271629500-08:00" level=debug msg=ToDiskLocking.... 26 | // time="2015-11-06T13:38:37.275643200-08:00" level=debug msg="loggin event...." 27 | // time="2015-11-06T13:38:37.277627600-08:00" level=debug msg="logged event...." 28 | // time="2015-11-06T13:38:37.279631800-08:00" level=debug msg="In defer func" 29 | // time="2015-11-06T13:38:37.282628100-08:00" level=debug msg="After daemon.create" 30 | // time="2015-11-06T13:38:37.286651700-08:00" level=debug msg="return 2" 31 | // time="2015-11-06T13:38:37.289629500-08:00" level=debug msg="Returned from daemon.ContainerCreate" 32 | // time="2015-11-06T13:38:37.311629100-08:00" level=debug msg="After WriteJSON" 33 | // ... 1 second gap here.... 34 | // time="2015-11-06T13:38:38.317866200-08:00" level=debug msg="Calling POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach" 35 | // time="2015-11-06T13:38:38.326882500-08:00" level=info msg="POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach?stderr=1&stdin=1&stdout=1&stream=1" 36 | // 37 | // We suspect this is either a bug introduced in GOLang 1.5.1, or that a change 38 | // in GOLang 1.5.1 (from 1.4.3) is exposing a bug in Windows TP4. In theory, 39 | // the Windows networking stack is supposed to resolve "localhost" internally, 40 | // without hitting DNS, or even reading the hosts file (which is why localhost 41 | // is commented out in the hosts file on Windows). 42 | // 43 | // We have validated that working around this using the actual IPv4 localhost 44 | // address does not cause the delay. 45 | // 46 | // This does not occur with the docker client built with 1.4.3 on the same 47 | // Windows TP4 build, regardless of whether the daemon is built using 1.5.1 48 | // or 1.4.3. It does not occur on Linux. We also verified we see the same thing 49 | // on a cross-compiled Windows binary (from Linux). 50 | // 51 | // Final note: This is a mitigation, not a 'real' fix. It is still susceptible 52 | // to the delay in TP4 if a user were to do 'docker run -H=tcp://localhost:2375...' 53 | // explicitly. 54 | 55 | // DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. docker daemon -H tcp://:8080 56 | const DefaultHTTPHost = "127.0.0.1" 57 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user/lookup.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "syscall" 7 | ) 8 | 9 | var ( 10 | // The current operating system does not provide the required data for user lookups. 11 | ErrUnsupported = errors.New("user lookup: operating system does not provide passwd-formatted data") 12 | ) 13 | 14 | func lookupUser(filter func(u User) bool) (User, error) { 15 | // Get operating system-specific passwd reader-closer. 16 | passwd, err := GetPasswd() 17 | if err != nil { 18 | return User{}, err 19 | } 20 | defer passwd.Close() 21 | 22 | // Get the users. 23 | users, err := ParsePasswdFilter(passwd, filter) 24 | if err != nil { 25 | return User{}, err 26 | } 27 | 28 | // No user entries found. 29 | if len(users) == 0 { 30 | return User{}, fmt.Errorf("no matching entries in passwd file") 31 | } 32 | 33 | // Assume the first entry is the "correct" one. 34 | return users[0], nil 35 | } 36 | 37 | // CurrentUser looks up the current user by their user id in /etc/passwd. If the 38 | // user cannot be found (or there is no /etc/passwd file on the filesystem), 39 | // then CurrentUser returns an error. 40 | func CurrentUser() (User, error) { 41 | return LookupUid(syscall.Getuid()) 42 | } 43 | 44 | // LookupUser looks up a user by their username in /etc/passwd. If the user 45 | // cannot be found (or there is no /etc/passwd file on the filesystem), then 46 | // LookupUser returns an error. 47 | func LookupUser(username string) (User, error) { 48 | return lookupUser(func(u User) bool { 49 | return u.Name == username 50 | }) 51 | } 52 | 53 | // LookupUid looks up a user by their user id in /etc/passwd. If the user cannot 54 | // be found (or there is no /etc/passwd file on the filesystem), then LookupId 55 | // returns an error. 56 | func LookupUid(uid int) (User, error) { 57 | return lookupUser(func(u User) bool { 58 | return u.Uid == uid 59 | }) 60 | } 61 | 62 | func lookupGroup(filter func(g Group) bool) (Group, error) { 63 | // Get operating system-specific group reader-closer. 64 | group, err := GetGroup() 65 | if err != nil { 66 | return Group{}, err 67 | } 68 | defer group.Close() 69 | 70 | // Get the users. 71 | groups, err := ParseGroupFilter(group, filter) 72 | if err != nil { 73 | return Group{}, err 74 | } 75 | 76 | // No user entries found. 77 | if len(groups) == 0 { 78 | return Group{}, fmt.Errorf("no matching entries in group file") 79 | } 80 | 81 | // Assume the first entry is the "correct" one. 82 | return groups[0], nil 83 | } 84 | 85 | // CurrentGroup looks up the current user's group by their primary group id's 86 | // entry in /etc/passwd. If the group cannot be found (or there is no 87 | // /etc/group file on the filesystem), then CurrentGroup returns an error. 88 | func CurrentGroup() (Group, error) { 89 | return LookupGid(syscall.Getgid()) 90 | } 91 | 92 | // LookupGroup looks up a group by its name in /etc/group. If the group cannot 93 | // be found (or there is no /etc/group file on the filesystem), then LookupGroup 94 | // returns an error. 95 | func LookupGroup(groupname string) (Group, error) { 96 | return lookupGroup(func(g Group) bool { 97 | return g.Name == groupname 98 | }) 99 | } 100 | 101 | // LookupGid looks up a group by its group id in /etc/group. If the group cannot 102 | // be found (or there is no /etc/group file on the filesystem), then LookupGid 103 | // returns an error. 104 | func LookupGid(gid int) (Group, error) { 105 | return lookupGroup(func(g Group) bool { 106 | return g.Gid == gid 107 | }) 108 | } 109 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/go-units/ulimit.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // Ulimit is a human friendly version of Rlimit. 10 | type Ulimit struct { 11 | Name string 12 | Hard int64 13 | Soft int64 14 | } 15 | 16 | // Rlimit specifies the resource limits, such as max open files. 17 | type Rlimit struct { 18 | Type int `json:"type,omitempty"` 19 | Hard uint64 `json:"hard,omitempty"` 20 | Soft uint64 `json:"soft,omitempty"` 21 | } 22 | 23 | const ( 24 | // magic numbers for making the syscall 25 | // some of these are defined in the syscall package, but not all. 26 | // Also since Windows client doesn't get access to the syscall package, need to 27 | // define these here 28 | rlimitAs = 9 29 | rlimitCore = 4 30 | rlimitCPU = 0 31 | rlimitData = 2 32 | rlimitFsize = 1 33 | rlimitLocks = 10 34 | rlimitMemlock = 8 35 | rlimitMsgqueue = 12 36 | rlimitNice = 13 37 | rlimitNofile = 7 38 | rlimitNproc = 6 39 | rlimitRss = 5 40 | rlimitRtprio = 14 41 | rlimitRttime = 15 42 | rlimitSigpending = 11 43 | rlimitStack = 3 44 | ) 45 | 46 | var ulimitNameMapping = map[string]int{ 47 | //"as": rlimitAs, // Disabled since this doesn't seem usable with the way Docker inits a container. 48 | "core": rlimitCore, 49 | "cpu": rlimitCPU, 50 | "data": rlimitData, 51 | "fsize": rlimitFsize, 52 | "locks": rlimitLocks, 53 | "memlock": rlimitMemlock, 54 | "msgqueue": rlimitMsgqueue, 55 | "nice": rlimitNice, 56 | "nofile": rlimitNofile, 57 | "nproc": rlimitNproc, 58 | "rss": rlimitRss, 59 | "rtprio": rlimitRtprio, 60 | "rttime": rlimitRttime, 61 | "sigpending": rlimitSigpending, 62 | "stack": rlimitStack, 63 | } 64 | 65 | // ParseUlimit parses and returns a Ulimit from the specified string. 66 | func ParseUlimit(val string) (*Ulimit, error) { 67 | parts := strings.SplitN(val, "=", 2) 68 | if len(parts) != 2 { 69 | return nil, fmt.Errorf("invalid ulimit argument: %s", val) 70 | } 71 | 72 | if _, exists := ulimitNameMapping[parts[0]]; !exists { 73 | return nil, fmt.Errorf("invalid ulimit type: %s", parts[0]) 74 | } 75 | 76 | var ( 77 | soft int64 78 | hard = &soft // default to soft in case no hard was set 79 | temp int64 80 | err error 81 | ) 82 | switch limitVals := strings.Split(parts[1], ":"); len(limitVals) { 83 | case 2: 84 | temp, err = strconv.ParseInt(limitVals[1], 10, 64) 85 | if err != nil { 86 | return nil, err 87 | } 88 | hard = &temp 89 | fallthrough 90 | case 1: 91 | soft, err = strconv.ParseInt(limitVals[0], 10, 64) 92 | if err != nil { 93 | return nil, err 94 | } 95 | default: 96 | return nil, fmt.Errorf("too many limit value arguments - %s, can only have up to two, `soft[:hard]`", parts[1]) 97 | } 98 | 99 | if soft > *hard { 100 | return nil, fmt.Errorf("ulimit soft limit must be less than or equal to hard limit: %d > %d", soft, *hard) 101 | } 102 | 103 | return &Ulimit{Name: parts[0], Soft: soft, Hard: *hard}, nil 104 | } 105 | 106 | // GetRlimit returns the RLimit corresponding to Ulimit. 107 | func (u *Ulimit) GetRlimit() (*Rlimit, error) { 108 | t, exists := ulimitNameMapping[u.Name] 109 | if !exists { 110 | return nil, fmt.Errorf("invalid ulimit name %s", u.Name) 111 | } 112 | 113 | return &Rlimit{Type: t, Soft: uint64(u.Soft), Hard: uint64(u.Hard)}, nil 114 | } 115 | 116 | func (u *Ulimit) String() string { 117 | return fmt.Sprintf("%s=%d:%d", u.Name, u.Soft, u.Hard) 118 | } 119 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive/archive_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package archive 4 | 5 | import ( 6 | "archive/tar" 7 | "errors" 8 | "os" 9 | "path/filepath" 10 | "syscall" 11 | 12 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system" 13 | ) 14 | 15 | // fixVolumePathPrefix does platform specific processing to ensure that if 16 | // the path being passed in is not in a volume path format, convert it to one. 17 | func fixVolumePathPrefix(srcPath string) string { 18 | return srcPath 19 | } 20 | 21 | // getWalkRoot calculates the root path when performing a TarWithOptions. 22 | // We use a separate function as this is platform specific. On Linux, we 23 | // can't use filepath.Join(srcPath,include) because this will clean away 24 | // a trailing "." or "/" which may be important. 25 | func getWalkRoot(srcPath string, include string) string { 26 | return srcPath + string(filepath.Separator) + include 27 | } 28 | 29 | // CanonicalTarNameForPath returns platform-specific filepath 30 | // to canonical posix-style path for tar archival. p is relative 31 | // path. 32 | func CanonicalTarNameForPath(p string) (string, error) { 33 | return p, nil // already unix-style 34 | } 35 | 36 | // chmodTarEntry is used to adjust the file permissions used in tar header based 37 | // on the platform the archival is done. 38 | 39 | func chmodTarEntry(perm os.FileMode) os.FileMode { 40 | return perm // noop for unix as golang APIs provide perm bits correctly 41 | } 42 | 43 | func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (inode uint64, err error) { 44 | s, ok := stat.(*syscall.Stat_t) 45 | 46 | if !ok { 47 | err = errors.New("cannot convert stat value to syscall.Stat_t") 48 | return 49 | } 50 | 51 | inode = uint64(s.Ino) 52 | 53 | // Currently go does not fill in the major/minors 54 | if s.Mode&syscall.S_IFBLK != 0 || 55 | s.Mode&syscall.S_IFCHR != 0 { 56 | hdr.Devmajor = int64(major(uint64(s.Rdev))) 57 | hdr.Devminor = int64(minor(uint64(s.Rdev))) 58 | } 59 | 60 | return 61 | } 62 | 63 | func getFileUIDGID(stat interface{}) (int, int, error) { 64 | s, ok := stat.(*syscall.Stat_t) 65 | 66 | if !ok { 67 | return -1, -1, errors.New("cannot convert stat value to syscall.Stat_t") 68 | } 69 | return int(s.Uid), int(s.Gid), nil 70 | } 71 | 72 | func major(device uint64) uint64 { 73 | return (device >> 8) & 0xfff 74 | } 75 | 76 | func minor(device uint64) uint64 { 77 | return (device & 0xff) | ((device >> 12) & 0xfff00) 78 | } 79 | 80 | // handleTarTypeBlockCharFifo is an OS-specific helper function used by 81 | // createTarFile to handle the following types of header: Block; Char; Fifo 82 | func handleTarTypeBlockCharFifo(hdr *tar.Header, path string) error { 83 | mode := uint32(hdr.Mode & 07777) 84 | switch hdr.Typeflag { 85 | case tar.TypeBlock: 86 | mode |= syscall.S_IFBLK 87 | case tar.TypeChar: 88 | mode |= syscall.S_IFCHR 89 | case tar.TypeFifo: 90 | mode |= syscall.S_IFIFO 91 | } 92 | 93 | if err := system.Mknod(path, mode, int(system.Mkdev(hdr.Devmajor, hdr.Devminor))); err != nil { 94 | return err 95 | } 96 | return nil 97 | } 98 | 99 | func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error { 100 | if hdr.Typeflag == tar.TypeLink { 101 | if fi, err := os.Lstat(hdr.Linkname); err == nil && (fi.Mode()&os.ModeSymlink == 0) { 102 | if err := os.Chmod(path, hdrInfo.Mode()); err != nil { 103 | return err 104 | } 105 | } 106 | } else if hdr.Typeflag != tar.TypeSymlink { 107 | if err := os.Chmod(path, hdrInfo.Mode()); err != nil { 108 | return err 109 | } 110 | } 111 | return nil 112 | } 113 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/README.markdown: -------------------------------------------------------------------------------- 1 | # go-dockerclient 2 | 3 | [![Travis](https://img.shields.io/travis/fsouza/go-dockerclient.svg?style=flat-square)](https://travis-ci.org/fsouza/go-dockerclient) 4 | [![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient) 5 | 6 | This package presents a client for the Docker remote API. It also provides 7 | support for the extensions in the [Swarm API](https://docs.docker.com/swarm/swarm-api/). 8 | 9 | This package also provides support for docker's network API, which is a simple 10 | passthrough to the libnetwork remote API. Note that docker's network API is 11 | only available in docker 1.8 and above, and only enabled in docker if 12 | DOCKER_EXPERIMENTAL is defined during the docker build process. 13 | 14 | For more details, check the [remote API documentation](http://docs.docker.com/engine/reference/api/docker_remote_api/). 15 | 16 | ## Vendoring 17 | 18 | If you are having issues with Go 1.5 and have `GO15VENDOREXPERIMENT` set with an application that has go-dockerclient vendored, 19 | please update your vendoring of go-dockerclient :) We recently moved the `vendor` directory to `external` so that go-dockerclient 20 | is compatible with this configuration. See [338](https://github.com/fsouza/go-dockerclient/issues/338) and [339](https://github.com/fsouza/go-dockerclient/pull/339) 21 | for details. 22 | 23 | ## Example 24 | 25 | ```go 26 | package main 27 | 28 | import ( 29 | "fmt" 30 | 31 | "github.com/fsouza/go-dockerclient" 32 | ) 33 | 34 | func main() { 35 | endpoint := "unix:///var/run/docker.sock" 36 | client, _ := docker.NewClient(endpoint) 37 | imgs, _ := client.ListImages(docker.ListImagesOptions{All: false}) 38 | for _, img := range imgs { 39 | fmt.Println("ID: ", img.ID) 40 | fmt.Println("RepoTags: ", img.RepoTags) 41 | fmt.Println("Created: ", img.Created) 42 | fmt.Println("Size: ", img.Size) 43 | fmt.Println("VirtualSize: ", img.VirtualSize) 44 | fmt.Println("ParentId: ", img.ParentID) 45 | } 46 | } 47 | ``` 48 | 49 | ## Using with TLS 50 | 51 | In order to instantiate the client for a TLS-enabled daemon, you should use NewTLSClient, passing the endpoint and path for key and certificates as parameters. 52 | 53 | ```go 54 | package main 55 | 56 | import ( 57 | "fmt" 58 | 59 | "github.com/fsouza/go-dockerclient" 60 | ) 61 | 62 | func main() { 63 | endpoint := "tcp://[ip]:[port]" 64 | path := os.Getenv("DOCKER_CERT_PATH") 65 | ca := fmt.Sprintf("%s/ca.pem", path) 66 | cert := fmt.Sprintf("%s/cert.pem", path) 67 | key := fmt.Sprintf("%s/key.pem", path) 68 | client, _ := docker.NewTLSClient(endpoint, cert, key, ca) 69 | // use client 70 | } 71 | ``` 72 | 73 | If using [docker-machine](https://docs.docker.com/machine/), or another application that exports environment variables 74 | `DOCKER_HOST, DOCKER_TLS_VERIFY, DOCKER_CERT_PATH`, you can use NewClientFromEnv. 75 | 76 | 77 | ```go 78 | package main 79 | 80 | import ( 81 | "fmt" 82 | 83 | "github.com/fsouza/go-dockerclient" 84 | ) 85 | 86 | func main() { 87 | client, _ := docker.NewClientFromEnv() 88 | // use client 89 | } 90 | ``` 91 | 92 | See the documentation for more details. 93 | 94 | ## Developing 95 | 96 | All development commands can be seen in the [Makefile](Makefile). 97 | 98 | Commited code must pass: 99 | 100 | * [golint](https://github.com/golang/lint) 101 | * [go vet](https://godoc.org/golang.org/x/tools/cmd/vet) 102 | * [gofmt](https://golang.org/cmd/gofmt) 103 | * [go test](https://golang.org/cmd/go/#hdr-Test_packages) 104 | 105 | Running `make test` will check all of these. If your editor does not automatically call gofmt, `make fmt` will format all go files in this repository. 106 | -------------------------------------------------------------------------------- /collector/vendor/github.com/fsouza/go-dockerclient/tar.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 go-dockerclient 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 docker 6 | 7 | import ( 8 | "fmt" 9 | "io" 10 | "io/ioutil" 11 | "os" 12 | "path" 13 | "path/filepath" 14 | "strings" 15 | 16 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive" 17 | "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils" 18 | ) 19 | 20 | func createTarStream(srcPath, dockerfilePath string) (io.ReadCloser, error) { 21 | excludes, err := parseDockerignore(srcPath) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | includes := []string{"."} 27 | 28 | // If .dockerignore mentions .dockerignore or the Dockerfile 29 | // then make sure we send both files over to the daemon 30 | // because Dockerfile is, obviously, needed no matter what, and 31 | // .dockerignore is needed to know if either one needs to be 32 | // removed. The deamon will remove them for us, if needed, after it 33 | // parses the Dockerfile. 34 | // 35 | // https://github.com/docker/docker/issues/8330 36 | // 37 | forceIncludeFiles := []string{".dockerignore", dockerfilePath} 38 | 39 | for _, includeFile := range forceIncludeFiles { 40 | if includeFile == "" { 41 | continue 42 | } 43 | keepThem, err := fileutils.Matches(includeFile, excludes) 44 | if err != nil { 45 | return nil, fmt.Errorf("cannot match .dockerfile: '%s', error: %s", includeFile, err) 46 | } 47 | if keepThem { 48 | includes = append(includes, includeFile) 49 | } 50 | } 51 | 52 | if err := validateContextDirectory(srcPath, excludes); err != nil { 53 | return nil, err 54 | } 55 | tarOpts := &archive.TarOptions{ 56 | ExcludePatterns: excludes, 57 | IncludeFiles: includes, 58 | Compression: archive.Uncompressed, 59 | NoLchown: true, 60 | } 61 | return archive.TarWithOptions(srcPath, tarOpts) 62 | } 63 | 64 | // validateContextDirectory checks if all the contents of the directory 65 | // can be read and returns an error if some files can't be read. 66 | // Symlinks which point to non-existing files don't trigger an error 67 | func validateContextDirectory(srcPath string, excludes []string) error { 68 | return filepath.Walk(filepath.Join(srcPath, "."), func(filePath string, f os.FileInfo, err error) error { 69 | // skip this directory/file if it's not in the path, it won't get added to the context 70 | if relFilePath, err := filepath.Rel(srcPath, filePath); err != nil { 71 | return err 72 | } else if skip, err := fileutils.Matches(relFilePath, excludes); err != nil { 73 | return err 74 | } else if skip { 75 | if f.IsDir() { 76 | return filepath.SkipDir 77 | } 78 | return nil 79 | } 80 | 81 | if err != nil { 82 | if os.IsPermission(err) { 83 | return fmt.Errorf("can't stat '%s'", filePath) 84 | } 85 | if os.IsNotExist(err) { 86 | return nil 87 | } 88 | return err 89 | } 90 | 91 | // skip checking if symlinks point to non-existing files, such symlinks can be useful 92 | // also skip named pipes, because they hanging on open 93 | if f.Mode()&(os.ModeSymlink|os.ModeNamedPipe) != 0 { 94 | return nil 95 | } 96 | 97 | if !f.IsDir() { 98 | currentFile, err := os.Open(filePath) 99 | if err != nil && os.IsPermission(err) { 100 | return fmt.Errorf("no permission to read from '%s'", filePath) 101 | } 102 | currentFile.Close() 103 | } 104 | return nil 105 | }) 106 | } 107 | 108 | func parseDockerignore(root string) ([]string, error) { 109 | var excludes []string 110 | ignore, err := ioutil.ReadFile(path.Join(root, ".dockerignore")) 111 | if err != nil && !os.IsNotExist(err) { 112 | return excludes, fmt.Errorf("error reading .dockerignore: '%s'", err) 113 | } 114 | excludes = strings.Split(string(ignore), "\n") 115 | 116 | return excludes, nil 117 | } 118 | --------------------------------------------------------------------------------