procstats

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package procstats reports a process's own resource usage — CPU time and resident memory — for nodes to include in their heartbeats. Neither figure is available from the Go standard library: runtime.MemStats describes the Go heap, not the process's actual memory footprint, and there is no standard-library equivalent of CPU accounting at all. Both need an OS-specific query, which is what this package delegates to gopsutil for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Self

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

Self measures the current process's own resource usage.

func NewSelf

func NewSelf() *Self

NewSelf prepares a reader for the current process.

Never fails: if the underlying OS handle cannot be opened, Usage simply reports zero from then on. A heartbeat missing this detail is far less costly than plumbing a constructor error through for something this minor.

func (*Self) Usage

func (s *Self) Usage() (cpuPercent float64, memBytes uint64)

Usage reports this process's CPU use — a percentage averaged over its whole life so far, where 100 means one full core sustained — and its resident memory in bytes. Either figure comes back zero if the underlying OS query fails, which is treated as "unknown right now" rather than an error worth surfacing.

Jump to

Keyboard shortcuts

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