sysprobe

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package sysprobe provides host and executable dependency snapshots for operational dashboards and health inspection.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("sysprobe: service is unavailable")

Functions

This section is empty.

Types

type CPU

type CPU struct {
	LogicalCores int     `json:"logical_cores"`
	UsedPercent  float64 `json:"used_percent"`
}

type Config

type Config struct {
	Host            HostConfig            `mapstructure:"host" yaml:"host"`
	NetworkCapacity NetworkCapacityConfig `mapstructure:"network_capacity" yaml:"network_capacity"`
	DependencyTTL   time.Duration         `mapstructure:"dependency_ttl" yaml:"dependency_ttl"`
	CheckTimeout    time.Duration         `mapstructure:"check_timeout" yaml:"check_timeout"`
	Dependencies    []DependencySpec      `mapstructure:"dependencies" yaml:"dependencies"`
}

type DependencyCode

type DependencyCode string
const (
	DependencyReady          DependencyCode = "ready"
	DependencyMissing        DependencyCode = "missing"
	DependencyDirectoryError DependencyCode = "directory_error"
	DependencyCheckFailed    DependencyCode = "check_failed"
	DependencyVersionUnknown DependencyCode = "version_unknown"
	DependencyVersionOutside DependencyCode = "version_outside_range"
)

type DependencySpec

type DependencySpec struct {
	Key         string   `mapstructure:"key" yaml:"key"`
	Name        string   `mapstructure:"name" yaml:"name"`
	BinaryPath  string   `mapstructure:"binary_path" yaml:"binary_path"`
	Args        []string `mapstructure:"args" yaml:"args"`
	Env         []string `mapstructure:"env" yaml:"env"`
	PrepareDir  string   `mapstructure:"prepare_dir" yaml:"prepare_dir"`
	MinVersion  string   `mapstructure:"min_version" yaml:"min_version"`
	MaxVersion  string   `mapstructure:"max_version" yaml:"max_version"`
	Required    bool     `mapstructure:"required" yaml:"required"`
	Description string   `mapstructure:"description" yaml:"description"`
}

type DependencyStatus

type DependencyStatus struct {
	Key         string         `json:"key"`
	Name        string         `json:"name"`
	Required    bool           `json:"required"`
	Installed   bool           `json:"installed"`
	Compatible  bool           `json:"compatible"`
	Version     string         `json:"version,omitempty"`
	Path        string         `json:"path,omitempty"`
	MinVersion  string         `json:"min_version,omitempty"`
	MaxVersion  string         `json:"max_version,omitempty"`
	Description string         `json:"description"`
	Code        DependencyCode `json:"code"`
	Message     string         `json:"message"`
}

type Disk

type Disk struct {
	Name        string  `json:"name"`
	Path        string  `json:"path"`
	Filesystem  string  `json:"filesystem"`
	Total       uint64  `json:"total"`
	Used        uint64  `json:"used"`
	Free        uint64  `json:"free"`
	UsedPercent float64 `json:"used_percent"`
}

type DiskSpec

type DiskSpec struct {
	Name string `json:"name" mapstructure:"name" yaml:"name"`
	Path string `json:"path" mapstructure:"path" yaml:"path"`
}

type Host

type Host struct {
	Hostname        string `json:"hostname"`
	OS              string `json:"os"`
	Platform        string `json:"platform"`
	PlatformVersion string `json:"platform_version"`
	KernelVersion   string `json:"kernel_version"`
	Architecture    string `json:"architecture"`
	UptimeSeconds   uint64 `json:"uptime_seconds"`
	BootTime        uint64 `json:"boot_time"`
}

type HostConfig

type HostConfig struct {
	CacheTTL    time.Duration `json:"-" mapstructure:"cache_ttl" yaml:"cache_ttl"`
	CPUInterval time.Duration `json:"-" mapstructure:"cpu_interval" yaml:"cpu_interval"`
	Disks       []DiskSpec    `json:"-" mapstructure:"disks" yaml:"disks"`
	Network     NetworkSpec   `json:"-" mapstructure:"network" yaml:"network"`
}

type HostProbe

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

func NewHost

func NewHost(config HostConfig) *HostProbe

func (*HostProbe) Snapshot

func (p *HostProbe) Snapshot(ctx context.Context) (HostSnapshot, error)

type HostSampler

type HostSampler interface {
	Snapshot(context.Context) (HostSnapshot, error)
}

HostSampler permits an explicitly supplied host collector.

type HostSnapshot

type HostSnapshot struct {
	CollectedAt time.Time `json:"collected_at"`
	Host        Host      `json:"host"`
	CPU         CPU       `json:"cpu"`
	Memory      Memory    `json:"memory"`
	Disks       []Disk    `json:"disks"`
	Network     Network   `json:"network"`
	Issues      []Issue   `json:"issues"`
}

type Issue

type Issue struct {
	Component string `json:"component"`
	Path      string `json:"path,omitempty"`
	Message   string `json:"message"`
}

type Memory

type Memory struct {
	Total       uint64  `json:"total"`
	Used        uint64  `json:"used"`
	Available   uint64  `json:"available"`
	UsedPercent float64 `json:"used_percent"`
}

type Network

type Network struct {
	BytesSent          uint64  `json:"bytes_sent"`
	BytesReceived      uint64  `json:"bytes_received"`
	PacketsSent        uint64  `json:"packets_sent"`
	PacketsReceived    uint64  `json:"packets_received"`
	SendBytesPerSecond float64 `json:"send_bytes_per_second"`
	RecvBytesPerSecond float64 `json:"recv_bytes_per_second"`
	SampleWindow       float64 `json:"sample_window_seconds"`
	RateReady          bool    `json:"rate_ready"`
}

type NetworkCapacityConfig

type NetworkCapacityConfig struct {
	ReceiveLimitMbps float64 `json:"receive_limit_mbps" mapstructure:"receive_limit_mbps" yaml:"receive_limit_mbps"`
	SendLimitMbps    float64 `json:"send_limit_mbps" mapstructure:"send_limit_mbps" yaml:"send_limit_mbps"`
}

type NetworkSpec

type NetworkSpec struct {
	ProcRoot   string   `json:"-" mapstructure:"proc_root" yaml:"proc_root"`
	Interfaces []string `json:"-" mapstructure:"interfaces" yaml:"interfaces"`
}

type Option

type Option func(*Service)

func WithHostSampler

func WithHostSampler(host HostSampler) Option

func WithRunner

func WithRunner(runner Runner) Option

type Runner

type Runner interface {
	Run(context.Context, DependencySpec) ([]byte, error)
}

Runner must stop when its context is canceled.

type Service

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

func New

func New(config Config, options ...Option) *Service

func (*Service) Close

func (s *Service) Close() error

Close makes subsequent snapshots unavailable. The service owns no permanent goroutines.

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context) (Snapshot, error)

type Snapshot

type Snapshot struct {
	At                time.Time             `json:"at"`
	Ready             bool                  `json:"ready"`
	Host              HostSnapshot          `json:"host"`
	NetworkCapacity   NetworkCapacityConfig `json:"network_capacity"`
	Dependencies      []DependencyStatus    `json:"dependencies"`
	DependencyChecked time.Time             `json:"dependency_checked_at"`
}

Directories

Path Synopsis
Package facade binds system probes to a service runtime.
Package facade binds system probes to a service runtime.

Jump to

Keyboard shortcuts

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