sysinfo

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sysinfo gathers the read-only environment summary surfaced by the Settings → General page and the GET /api/v1/system/info endpoint. Centralising it here keeps the two callers from drifting and avoids a cross-package import of unexported helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HumanBytes

func HumanBytes(n int64) string

HumanBytes formats a byte count with binary units (KiB / MiB / GiB). Sub-kibibyte values render with the literal byte count.

Types

type DiskUsage

type DiskUsage struct {
	Used  string
	Total string
	Free  string
	Pct   uint8
	Kind  string // "ok" (<70%), "warn" (70–90%), "err" (>=90%)
}

DiskUsage is the volume-level usage for a directory. Used / Total / Free are pre-formatted byte strings; Pct is 0–100 (rounded down). Kind is a coarse threshold marker for badge / progress-bar styling.

func DiskUsageFor

func DiskUsageFor(path string) *DiskUsage

DiskUsageFor reports volume-level usage for the directory at path via statfs. Returns nil when statfs fails (missing dir, permission errors). Bsize is converted to int64 explicitly: it is typed int64 on linux but uint32 on darwin/openbsd, and Bavail is signed on freebsd — the conversions normalize all of them so this compiles across every unix goreleaser target.

type Snapshot

type Snapshot struct {
	AppName   string
	PublicURL string
	HTTPSWarn bool
	AuthMode  string
	DataDir   string
	DataUsage *DiskUsage
	DBPath    string
	DBSize    string
	DBUsage   *DiskUsage
	Version   string
	Commit    string
	BuiltAt   string
	GoVersion string
	GoOSArch  string
}

Snapshot is the read-only environment view. Pointer fields are nil when the underlying probe fails (statfs error, missing DB file, etc.).

func Collect

func Collect() Snapshot

Collect returns the current environment snapshot.

Jump to

Keyboard shortcuts

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