Documentation
¶
Overview ¶
Package sysinfo asks the operating system what a support report needs to know: the processor, memory, graphics cards, and how much room a disk has. It needs no administrator rights, changes nothing and never fails loudly: what can't be found out is left empty.
Index ¶
- func BlockDevice(source string) string
- func FreeBytes(dir string) int64
- func MemoryMB() int64
- func ReadCPU() (all CPUTicks, cores []CPUTicks, ok bool)
- type CPUTicks
- type Disk
- type DiskCounters
- type FS
- type Info
- type MemoryUse
- type MountLine
- type NetCounters
- type ProcessUse
- type Temperature
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockDevice ¶
BlockDevice names the whole disk under /sys/block behind a mount's source (/dev/sda1 is sda; /dev/mapper/x is what the mapping sits on). "" when the source is not a local disk.
Types ¶
type CPUTicks ¶
type CPUTicks struct {
Busy, Total uint64
}
CPUTicks is how much a processor has done since the machine started, in whatever unit its system counts. Only the difference between two readings means anything.
type Disk ¶
type Disk struct {
Free int64 `json:"free"` // what this program may use
Total int64 `json:"total"`
}
Disk is how much room a disk has.
type DiskCounters ¶
type DiskCounters struct {
Name string
ReadBytes, WriteBytes uint64
BusyMs uint64 // time it had something to do; 0 where a system doesn't say
}
DiskCounters is what one disk has read and written. Name is the system's: sda, nvme0n1, C:.
type FS ¶
type FS struct {
Type string `json:"type,omitempty"` // lower case: ntfs, exfat, fat32, refs, ext4, xfs, nfs, cifs, apfs...
Kind string `json:"kind"` // fixed, removable, sdcard, network, optical, ram or unknown
ReadOnly bool `json:"readOnly,omitempty"`
Mount string `json:"mount,omitempty"` // the drive's root or the mount point
Source string `json:"source,omitempty"` // Linux and macOS: the device or share it comes from
// Mapped: a drive letter for a network share. Services don't see those.
Mapped bool `json:"mapped,omitempty"`
// UNC: named as \\server\share.
UNC bool `json:"unc,omitempty"`
}
FS describes the file system a folder is on, as far as the operating system says without administrator rights. Whatever it won't say stays empty.
type Info ¶
type Info struct {
OS string `json:"os"` // "linux", "windows", "darwin"
Arch string `json:"arch"` // "amd64", "arm64"
Release string `json:"release"` // the system's own name for its version
CPU string `json:"cpu,omitempty"`
Cores int `json:"cores"`
MemoryMB int64 `json:"memoryMB,omitempty"`
FreeMB int64 `json:"freeMemoryMB,omitempty"`
GPUs []string `json:"gpus,omitempty"`
Container bool `json:"container,omitempty"`
}
Info describes the machine.
type MemoryUse ¶
type MemoryUse struct {
Total, Available, SwapTotal, SwapFree uint64
}
MemoryUse is the machine's memory, in bytes.
type MountLine ¶
MountLine is one line of /proc/self/mountinfo.
func FindMount ¶
FindMount picks the mount that holds a path from the text of /proc/self/mountinfo: the longest mount point that is the path or a folder above it. The last line wins among equals: a later mount hides an earlier one.
func ParseMountLine ¶
ParseMountLine reads one line of /proc/self/mountinfo.
type NetCounters ¶
type NetCounters struct {
Name string
RxBytes, TxBytes uint64
RxErrs, TxErrs uint64
Up bool
SpeedMbps int64 // 0: not known
}
NetCounters is what one network interface has carried.
func ReadNetwork ¶
func ReadNetwork() []NetCounters
ReadNetwork gives each interface, leaving out the loopback.
type ProcessUse ¶
type ProcessUse struct {
CPUSec float64 // processor time used since it started
RSS uint64 // memory the system says it holds
Threads int // 0: not known
Handles int // open files and such; 0: not known
}
ProcessUse is this program's own share of the machine.
type Temperature ¶
Temperature is one sensor's reading.
func ReadTemperatures ¶
func ReadTemperatures() []Temperature
ReadTemperatures gives what the kernel's sensors say.
type Volume ¶
type Volume struct {
Mount string
Device string // the system's name for what it's on, to match with DiskCounters
Type string // ntfs, ext4...
Kind string // fixed, removable, network...
Total uint64
Free uint64
}
Volume is somewhere files can go.
func ReadVolumes ¶
func ReadVolumes() []Volume
ReadVolumes gives each mounted file system that holds files of its own.