resources

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: 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 resources measures what agents cost the machine: every process attributed to a session, to a session that has ended, or to whatever else runs on the box.

Index

Constants

View Source
const (
	KindSession = "session"
	KindLeft    = "left"
	KindOutside = "outside"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Disk

type Disk struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
	Used int64  `json:"used"`
}

type DiskUse

type DiskUse struct {
	Path     string   `json:"path"`
	Kind     string   `json:"kind"`
	Size     int64    `json:"size"`
	Sessions []string `json:"sessions,omitempty"`
}

type Group

type Group struct {
	Key       string    `json:"key"`
	SessionID string    `json:"sessionId,omitempty"`
	Kind      string    `json:"kind"`
	Title     string    `json:"title"`
	Detail    string    `json:"detail,omitempty"`
	CPU       float64   `json:"cpu"`
	Mem       int64     `json:"mem"`
	Read      float64   `json:"read"`
	Write     float64   `json:"write"`
	Count     int       `json:"count"`
	RSSOnly   bool      `json:"rssOnly,omitempty"`
	Procs     []Process `json:"procs,omitempty"`
}

type Load

type Load struct {
	CPU int   `json:"cpu,omitempty"`
	Mem int64 `json:"mem,omitempty"`
}

Load is what a session row carries, only while it is heavy and rounded, so an ordinary fluctuation does not re-send the whole session list.

type Machine

type Machine struct {
	Cores     int     `json:"cores"`
	CPU       float64 `json:"cpu"`
	MemTotal  int64   `json:"memTotal"`
	MemUsed   int64   `json:"memUsed"`
	SwapTotal int64   `json:"swapTotal"`
	SwapUsed  int64   `json:"swapUsed"`
	Load      float64 `json:"load"`
	Pressure  float64 `json:"pressure"`
	Shared    int64   `json:"shared,omitempty"`
	RAMDisk   int64   `json:"ramDisk,omitempty"`
	Read      float64 `json:"read"`
	Write     float64 `json:"write"`
	Disks     []Disk  `json:"disks,omitempty"`
}

type Process

type Process struct {
	PID   int     `json:"pid"`
	PPID  int     `json:"ppid"`
	Name  string  `json:"name"`
	Cmd   string  `json:"cmd"`
	CPU   float64 `json:"cpu"`
	Mem   int64   `json:"mem"`
	Read  float64 `json:"read,omitempty"`
	Write float64 `json:"write,omitempty"`
	Age   int64   `json:"age,omitempty"`
}

type Report

type Report struct {
	At       time.Time `json:"at"`
	Machine  Machine   `json:"machine"`
	Sessions []Group   `json:"sessions"`
	Left     []Group   `json:"left"`
	Outside  []Group   `json:"outside"`
	Rest     Group     `json:"rest"`
	Disk     []DiskUse `json:"disk,omitempty"`
	DiskAt   time.Time `json:"diskAt,omitzero"`
	RAMDirs  []DiskUse `json:"ramDirs,omitempty"`
	Exact    bool      `json:"exact"`
	Cost     float64   `json:"cost"`
}

type Row

type Row struct {
	T      int64      `json:"t"`
	CPU    float64    `json:"cpu"`
	Mem    int64      `json:"mem"`
	Total  int64      `json:"total"`
	RAM    int64      `json:"ram,omitempty"`
	Cores  int        `json:"cores"`
	Groups []RowGroup `json:"g"`
}

type RowGroup

type RowGroup struct {
	Key   string  `json:"k"`
	Kind  string  `json:"o"`
	Title string  `json:"l,omitempty"`
	CPU   float64 `json:"c"`
	Mem   int64   `json:"m"`
	Read  float64 `json:"r,omitempty"`
	Write float64 `json:"w,omitempty"`
	Top   []Top   `json:"p,omitempty"`
}

type Sampler

type Sampler struct {
	Dir       string
	ClaudeDir string
	Resolve   func(key string) (title, sessionID string)
	// contains filtered or unexported fields
}

func New

func New(dir, claudeDir string) *Sampler

func (*Sampler) History

func (s *Sampler) History(d time.Duration, key string) []Row

History is the machine's rows, or with a key only that session's, which is far less to send.

func (*Sampler) Load

func (s *Sampler) Load(key string) *Load

func (*Sampler) Report

func (s *Sampler) Report() Report

func (*Sampler) Run

func (s *Sampler) Run(ctx context.Context)

func (*Sampler) Track

func (s *Sampler) Track(targets []Target)

type Target

type Target struct {
	Key, SessionID, Title, Cwd string
	PID                        int
}

type Top

type Top struct {
	Name string  `json:"n"`
	Mem  int64   `json:"m"`
	CPU  float64 `json:"c,omitempty"`
}

Jump to

Keyboard shortcuts

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