utils

package
v0.0.0-...-c4caace Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerIDLen = sha256.Size * 2

ContainerIDLen is the length of a container ID is the length of the hex representation of a sha256 hash

Variables

This section is empty.

Functions

func CapEffCapEprm

func CapEffCapEprm(pid int32) (uint64, uint64, error)

CapEffCapEprm returns the effective and permitted kernel capabilities of a process

func CgroupTaskPath

func CgroupTaskPath(tgid, pid uint32) string

CgroupTaskPath returns the path to the cgroup file of a pid in /proc

func EnvVars

func EnvVars(pid int32) (map[string]string, error)

EnvVars returns a map with the environment variables of the given pid

func GetFilledProcess

func GetFilledProcess(p *process.Process) *process.FilledProcess

GetFilledProcess returns a FilledProcess from a Process input TODO: make a PR to export a similar function in Datadog/gopsutil. We only populate the fields we need for now.

func GetProcesses

func GetProcesses() ([]*process.Process, error)

GetProcesses returns list of active processes

func GetTagValue

func GetTagValue(tagName string, tags []string) string

GetTagValue returns the value of the given tag in the given list

func Getpid

func Getpid() int32

Getpid returns the current process ID in the host namespace

func NumCPU

func NumCPU() (int, error)

NumCPU returns the count of CPUs in the CPU affinity mask of the pid 1 process

func PidTTY

func PidTTY(pid int32) string

PidTTY returns the TTY of the given pid

func ProcExePath

func ProcExePath(pid int32) string

ProcExePath returns the path to the exe file of a pid in /proc

func StatusPath

func StatusPath(pid int32) string

StatusPath returns the path to the status file of a pid in /proc

Types

type ContainerID

type ContainerID string

ContainerID is the type holding the container ID

func GetProcContainerID

func GetProcContainerID(tgid, pid uint32) (ContainerID, error)

GetProcContainerID returns the container ID which the process belongs to. Returns "" if the process does not belong to a container.

func (ContainerID) Bytes

func (c ContainerID) Bytes() []byte

Bytes returns the container ID as a byte array

type ControlGroup

type ControlGroup struct {
	// ID unique hierarchy ID
	ID int

	// Controllers are the list of cgroup controllers bound to the hierarchy
	Controllers []string

	// Path is the pathname of the control group to which the process
	// belongs. It is relative to the mountpoint of the hierarchy.
	Path string
}

ControlGroup describes the cgroup membership of a process

func GetProcControlGroups

func GetProcControlGroups(tgid, pid uint32) ([]ControlGroup, error)

GetProcControlGroups returns the cgroup membership of the specified task.

func (ControlGroup) GetContainerID

func (cg ControlGroup) GetContainerID() ContainerID

GetContainerID returns the container id extracted from the path of the control group

Jump to

Keyboard shortcuts

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