Documentation ¶
Index ¶
- Variables
- func ExtractContainerRateMetric(containers []*containers.Container) map[string]ContainerRateMetrics
- func GetContainers() ([]*containers.Container, error)
- func GetDockerSocketPath() (string, error)
- func GetEnv(key string, dfault string, combineWith ...string) string
- func GetPlatform() (string, error)
- func GetProcRoot() string
- func HandleSignals(exit chan struct{})
- func HostProc(combineWith ...string) string
- func HostSys(combineWith ...string) string
- func IsDebugfsMounted() (bool, string)
- func NetIPFromAddress(addr Address) net.IP
- func PathExists(filename string) bool
- func ReadLines(filename string) ([]string, error)
- func SetContainerSources(names []string)
- func StringInSlice(slice []string, searchString string) bool
- func WithRootNS(procRoot string, fn func()) error
- type Address
- type ContainerRateMetrics
- type LogLimit
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented yet")
ErrNotImplemented is the "not implemented" error given by `gopsutil` when an OS doesn't support and API. Unfortunately it's in an internal package so we can't import it so we'll copy it here.
var NullContainerRates = ContainerRateMetrics{ CPU: &metrics.ContainerCPUStats{}, IO: &metrics.ContainerIOStats{}, NetworkSum: &metrics.InterfaceNetStats{}, Network: metrics.ContainerNetStats{}, }
NullContainerRates can be safely used for containers that have no previours rate values stored (new containers)
Functions ¶
func ExtractContainerRateMetric ¶
func ExtractContainerRateMetric(containers []*containers.Container) map[string]ContainerRateMetrics
ExtractContainerRateMetric extracts relevant rate values from a container list for later reuse, while reducing memory usage to only the needed fields
func GetContainers ¶
func GetContainers() ([]*containers.Container, error)
GetContainers returns containers found on the machine GetContainers autodetects the best backend from available sources if the users don't specify the preferred container sources
func GetDockerSocketPath ¶
GetDockerSocketPath is only for exposing the sockpath out of the module
func GetEnv ¶
GetEnv retrieves the environment variable key. If it does not exist it returns the default.
func GetPlatform ¶
GetPlatform returns the current platform we are running on by calling 1. python -m platform 2. "uname -a" 3. "lsb_release -a" 4. reading redhat-release
func GetProcRoot ¶
func GetProcRoot() string
GetProcRoot retrieves the current procfs dir we should use
func HandleSignals ¶
func HandleSignals(exit chan struct{})
HandleSignals tells us whether we should exit.
func HostProc ¶
HostProc returns the location of a host's procfs. This can and will be overridden when running inside a container.
func HostSys ¶
HostSys returns the location of a host's /sys. This can and will be overridden when running inside a container.
func IsDebugfsMounted ¶
IsDebugfsMounted would test the existence of file /sys/kernel/debug/tracing/kprobe_events to determine if debugfs is mounted or not returns a boolean and a possible error message
func NetIPFromAddress ¶
NetIPFromAddress returns a net.IP from an Address
func PathExists ¶
PathExists returns a boolean indicating if the given path exists on the file system.
func SetContainerSources ¶
func SetContainerSources(names []string)
SetContainerSources allows config to force one or multiple container sources
func StringInSlice ¶
StringInSlice returns true if the given searchString is in the given slice, false otherwise.
func WithRootNS ¶
WithRootNS executes a function within root network namespace and then switch back to the previous namespace. If the thread is already in the root network namespace, the function is executed without calling SYS_SETNS.
Types ¶
type Address ¶
Address is an IP abstraction that is family (v4/v6) agnostic
func AddressFromNetIP ¶
AddressFromNetIP returns an Address from a provided net.IP
func AddressFromString ¶
AddressFromString creates an Address using the string representation of an v4 IP
func V4AddressFromBytes ¶
V4AddressFromBytes creates an Address using the byte representation of an v4 IP
func V6AddressFromBytes ¶
V6AddressFromBytes creates an Address using the byte representation of an v6 IP
type ContainerRateMetrics ¶
type ContainerRateMetrics struct { CPU *metrics.ContainerCPUStats IO *metrics.ContainerIOStats NetworkSum *metrics.InterfaceNetStats Network metrics.ContainerNetStats }
ContainerRateMetrics holds previous values for a container, in order to compute rates
type LogLimit ¶
type LogLimit struct {
// contains filtered or unexported fields
}
LogLimit is a utility that can be used to avoid logging noisily
func NewLogLimit ¶
NewLogLimit creates a LogLimit where shouldLog will return true the first N times it is called, and will return true once every interval thereafter.