taskstats

package module
v0.0.0-...-387b3d5 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 9 Imported by: 7

README

taskstats Test Status Go Reference Go Report Card

Package taskstats provides access to Linux's taskstats interface, for sending per-task, per-process, and cgroup statistics from the kernel to userspace. MIT Licensed.

For more information on taskstats, please see:

Notes

  • When instrumenting Go programs, use either the taskstats.Self() or taskstats.TGID() method. Using the PID() method on multithreaded programs, including Go programs, will produce inaccurate results.

  • Access to taskstats requires that the application have at least CAP_NET_RAW capability (see capabilities(7)). Otherwise, the application must be run as root.

  • If running the application in a container (e.g. via Docker), it cannot be run in a network namespace -- usually this means that host networking must be used.

Documentation

Overview

Package taskstats provides access to Linux's taskstats interface, for sending per-task, per-process, and cgroup statistics from the kernel to userspace.

For more information on taskstats, please see:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CGroupStats

type CGroupStats struct {
	Sleeping        uint64
	Running         uint64
	Stopped         uint64
	Uninterruptible uint64
	IOWait          uint64
}

CGroupStats contains statistics for tasks of an individual cgroup.

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client provides access to Linux taskstats information.

Some Client operations require elevated privileges.

func New

func New() (*Client, error)

New creates a new Client.

func (*Client) CGroupStats

func (c *Client) CGroupStats(path string) (*CGroupStats, error)

CGroupStats retrieves cgroup statistics for the cgroup specified by path. Path should be a CPU cgroup path found in sysfs, such as:

  • /sys/fs/cgroup/cpu
  • /sys/fs/cgroup/cpu/docker
  • /sys/fs/cgroup/cpu/docker/(hexadecimal identifier)

func (*Client) Close

func (c *Client) Close() error

Close releases resources used by a Client.

func (*Client) PID

func (c *Client) PID(pid int) (*Stats, error)

PID retrieves statistics about a process, identified by its PID.

func (*Client) Self

func (c *Client) Self() (*Stats, error)

Self is a convenience method for retrieving statistics about the current process.

func (*Client) TGID

func (c *Client) TGID(tgid int) (*Stats, error)

TGID retrieves statistics about a thread group, identified by its TGID.

type Stats

type Stats struct {
	BeginTime           time.Time
	ElapsedTime         time.Duration
	UserCPUTime         time.Duration
	SystemCPUTime       time.Duration
	MinorPageFaults     uint64
	MajorPageFaults     uint64
	CPUDelayCount       uint64
	CPUDelay            time.Duration
	BlockIODelayCount   uint64
	BlockIODelay        time.Duration
	SwapInDelayCount    uint64
	SwapInDelay         time.Duration
	FreePagesDelayCount uint64
	FreePagesDelay      time.Duration
	ThrashingDelayCount uint64
	ThrashingDelay      time.Duration
}

Stats contains statistics for an individual task.

Jump to

Keyboard shortcuts

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