usage

package
v0.0.0-...-0b698e0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0, MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package usage observes a captured process group. It never grants process control authority and never reads command lines or process environments.

Index

Constants

View Source
const CPUCutBudget = 100 * time.Millisecond
View Source
const CPUOwnerLimit = 32
View Source
const CPUProcessLimit = 256
View Source
const CPUUnitDarwinMach = "darwin-recount-mach"
View Source
const MaxMembers = 256

Variables

This section is empty.

Functions

func CPUClockQuantum

func CPUClockQuantum() (uint64, string, error)

func Capture

func Capture(pid int) (model.ProcessIdentity, error)

func CaptureCPUAnchor

func CaptureCPUAnchor(root model.ProcessIdentity) (string, error)

func ListPIDs

func ListPIDs(limit int) ([]int, error)

ListPIDs enumerates visible processes, bounded by limit.

func View

func View(current Snapshot, previous *Snapshot) model.WorkloadUsage

Types

type CPUCut

type CPUCut struct {
	Started, Finished time.Time
	Method, Detail    string
	Members           []CPUProcessCounter
	// contains filtered or unexported fields
}

func CollectCPU

func CollectCPU(ctx context.Context, owners []CPUOwner) CPUCut

CollectCPU performs CPU-only native reads. Inventory can be partial: only members with a complete verified ancestry chain are retained, and later matching credits only members present in both contained cuts.

func (*CPUCut) Close

func (c *CPUCut) Close() error

Close retires this cut's lifetime evidence. Darwin uses unique process IDs, not retained descriptors; future platforms may need native handle cleanup.

type CPUOwner

type CPUOwner struct {
	Token  string
	Root   model.ProcessIdentity
	Cookie string
}

CPUOwner is supplied only from an original live supervised job. Cookie is captured while its launch gate is closed, before the original Wait can reap that process. Neither a saved PID nor a process group establishes ownership.

type CPUOwnerDelta

type CPUOwnerDelta struct {
	Owner            CPUOwner
	User, System     uint64
	MatchedProcesses int
	Members          []CPUProcessDelta
}

func ContainedCPUDeltas

func ContainedCPUDeltas(previous, current CPUCut) []CPUOwnerDelta

ContainedCPUDeltas returns raw, identity-verified matched-member deltas. The caller must separately establish that these cuts lie inside its host-counter interval and that the native units have a proved accounting relationship.

type CPUProcessCounter

type CPUProcessCounter struct {
	Owner                CPUOwner
	Identity             model.ProcessIdentity
	ParentPID            int
	Cookie, ParentCookie string
	User, System         uint64
	Unit                 string
}

type CPUProcessDelta

type CPUProcessDelta struct {
	BeforeUser, BeforeSystem, AfterUser, AfterSystem uint64
	Identity                                         model.ProcessIdentity
	Cookie, ParentCookie                             string
	ParentPID                                        int
	User, System                                     uint64
}

type Sample

type Sample struct {
	Identity   model.ProcessIdentity
	PPID       int
	Name       string
	Stopped    bool // stopped by a signal or tracer
	CPUSeconds *float64
	Resident   *uint64
	Footprint  *uint64 // Darwin physical footprint; nil elsewhere
	DiskRead   *uint64 // cumulative storage bytes, when the platform permits
	DiskWrite  *uint64
}

Sample is one process observation for host-wide inventory. It carries no control authority; callers must revalidate Identity before any action.

func Inspect

func Inspect(pid int) (Sample, error)

Inspect observes any visible process. Counters the caller may not read, such as another user's usage, are nil rather than zero.

type Snapshot

type Snapshot struct {
	Started      time.Time
	Finished     time.Time
	Root         model.ProcessIdentity
	Verified     bool
	Complete     bool
	Method       string
	MemoryMetric string
	Detail       string
	Members      []model.ProcessUsage
}

func Collect

func Collect(ctx context.Context, root model.ProcessIdentity) Snapshot

Jump to

Keyboard shortcuts

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