collectd

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 11 Imported by: 1

README

collectd

Mainly used to collect cpu, memory metrics correctly for container, k8s and non container environment.

Usage

go get -u github.com/v8fg/collectd

Feature

metrics container linux
cpu Y Y
memory Y Y

ENV

The go version shall >= 1.16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCgroupFile

func ParseCgroupFile(path string) (map[string]string, error)

ParseCgroupFile parse cgroup file

func RunningInDockerContainer

func RunningInDockerContainer() bool

RunningInDockerContainer determine if it is running in the Container environment. Simply determine by the ways: 1: .dockerenv; 2: cgroups(normal pid=1 in docker)

func RunningInDockerContainerPid

func RunningInDockerContainerPid(pid int32) bool

RunningInDockerContainerPid determine if the process with pid is running in the Container environment. Simply determine by the ways: 1: .dockerenv; 2: cgroups(normal pid=1 in docker)

Types

type CpuInfoData

type CpuInfoData struct {
	Count     float64
	Used      float64
	Percent   float64
	Container int
}

CpuInfoData cpu info data

func CpuInfo

func CpuInfo(container bool, pid int32) CpuInfoData

CpuInfo read the cpu info for Container or not, with the special pid

type MemInfoData

type MemInfoData struct {
	Total     float64
	Used      float64
	Percent   float64
	Container int
}

MemInfoData memory info data

func MemInfo

func MemInfo(container bool, pid int32) MemInfoData

MemInfo read the memory info for Container or not, with the special pid

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL