sysinfo

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sysinfo provides cross-platform access to system uptime and load average data. It reads kernel-provided values from fixed, non-user-controlled sources (/proc/uptime and /proc/loadavg on Linux; sysctl on Darwin; GetTickCount64 on Windows). These paths are hardcoded and never derived from shell-script input, so this package uses os.Open directly rather than routing through the AllowedPaths sandbox — the same intentional bypass used by diskstats, procnetroute, and procsyskernel.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("not supported on this platform")

ErrNotSupported is returned on platforms with no backend implementation.

Functions

This section is empty.

Types

type Info

type Info struct {
	// UptimeSeconds is the number of seconds elapsed since the last boot.
	UptimeSeconds float64

	// Load1, Load5, Load15 are the 1-, 5-, and 15-minute load averages.
	// These fields are only meaningful when LoadAvailable is true.
	Load1, Load5, Load15 float64

	// LoadAvailable reports whether load average data is available on this
	// platform. It is false on Windows, which has no native load-average API.
	LoadAvailable bool

	// BootTime is the Unix epoch second of the last system boot.
	// It is computed as time.Now().Unix() - int64(UptimeSeconds), so it may
	// be off by up to one second from the true boot time.
	BootTime int64
}

Info holds the data points read from the kernel.

func Get

func Get() (Info, error)

Get reads uptime and load-average data from the kernel. The implementation is platform-specific; see the build-tagged files.

Jump to

Keyboard shortcuts

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