procfs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

README

procfs

Go Reference

$ go get go.jamescun.com/procfs

This package implements reading structured text-based information about a Linux (or other compatible) system through the procfs filesystem.

The source for this project is hosted on both GitHub and Codeberg.

usage

This package is built with containers in mind, specifically the case where the procfs filesystem mounted at /proc is not the one you want to read, instead you want to read from the procfs of the host system bind mounted elsewhere inside a container.

Initializing to read from the normal /proc directory:

proc := procfs.New()

Initializing to read from a different directory:

proc := procfs.From(os.DirFS("/mnt/host/proc"))

It can also be used with anything implementing the fs.FS interface.

The procfs filesystem can be read directly as bytes or strings, additionally all the structures contained within this package implement the encoding.TextUnmarshaler interface, which can be used with anything using that interface.

examples

Below are some examples of how to use the procfs package.

[!NOTE] Error handling is omitted in these examples for brevity.

getting mount information
package main

import (
	"fmt"

	"go.jamescun.com/procfs"
)

func main() {
	// initialize a procfs reader for the root /proc directory.
	proc := procfs.New()

	// read the mounted filesystems from /proc/self/mountinfo.
	mounts, _ := procfs.GetMounts(proc)

	for _, mount := range mounts {
		fmt.Printf("Root: %s, Path: %s, Type: %s\n", mount.Root, mount.Path, mount.Type)
	}
}
getting network interface statistics
package main

import (
	"fmt"

	"go.jamescun.com/procfs"
)

func main() {
	// initialize a procfs reader for the root /proc directory.
	proc := procfs.New()

	// get statistics from all the network links/interfaces on the system.
	stats, _ := procfs.GetLinkStats(proc)

	for _, link := range stats {
		fmt.Printf("Interface: %s\n", link.Name)
		fmt.Printf("  Receive: %d bytes, %d packets\n", link.Rx.Bytes, link.Rx.Packets)
		fmt.Printf("  Transmit: %d bytes, %d packets\n", link.Tx.Bytes, link.Tx.Packets)
	}
}

sysctl

Go Reference

$ go get go.jamescun.com/procfs/sysctl

This package also contains a wrapper for procfs for reading sysctl Linux Kernel parameters, which are exposed through the procfs filesystem, under the sys/ subdirectory.

Documentation

Overview

Package procfs implements reading structured text-based information about a system through the procfs filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board interface {
	BoardVendor() string
	BoardVersion() string
}

Board is available on some single-board computers (SBC) through /proc/cpuinfo detailing their configuration, such as the Raspberry Pi.

type CPUInfo

type CPUInfo struct {
	Processors []*Processor
	Revision   string
	Serial     string
	Model      string
	Board      Board
}

CPUInfo contains information about the systems processors or processor cores (depending on platform), read from /proc/cpuinfo.

Due to the platform-specific nature of the contents of /proc/cpuinfo, this is not an extensive implementation of all possible fields, merely a best effort to capture the primary information.

func GetCPUInfo

func GetCPUInfo(proc Procfs) (*CPUInfo, error)

GetCPUInfo reads information about the systems processors or processor cores (depending on platform), read from /proc/cpuinfo using the given Procfs.

func (*CPUInfo) UnmarshalText

func (c *CPUInfo) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/cpuinfo.

type CPUStat

type CPUStat struct {
	CPU       int
	User      uint64
	Nice      uint64
	System    uint64
	Idle      uint64
	IOWait    uint64
	IRQ       uint64
	SoftIRQ   uint64
	Steal     uint64
	Guest     uint64
	GuestNice uint64
}

CPUStat is either the sum processor time spent or time spent for a single processor in CPUStats, read from /proc/stat.

References:

  • proc_stat(5)

func (*CPUStat) UnmarshalText

func (c *CPUStat) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single processor line from /proc/stat.

type CPUStats

type CPUStats struct {
	Total        CPUStat
	CPU          []*CPUStat
	Ctxt         uint64
	Btime        uint64
	Processes    uint64
	ProcsRunning uint64
	ProcsBlocked uint64
}

CPUStats contains statistics about processor time and running processes, read from /proc/stat.

References:

  • proc_stat(5)

func GetCPUStats

func GetCPUStats(proc Procfs) (*CPUStats, error)

GetCPUStats reads statistics about processor time and running processed, read from /proc/stat in the given Procfs.

func (*CPUStats) UnmarshalText

func (cs *CPUStats) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/stat.

type Cgroup

type Cgroup struct {
	Name       string
	Hierarchy  int
	NumCgroups int
	Enabled    bool
}

Cgroup contains details of a single cgroup subsystem, read from /proc/cgroups.

References:

  • proc_groups

func (*Cgroup) UnmarshalText

func (c *Cgroup) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/cgroups.

type Cgroups

type Cgroups []*Cgroup

Cgroups contains the details of the systems cgroup subsystems, read from /proc/cgroups.

References:

  • proc_groups

func GetCgroups

func GetCgroups(proc Procfs) (Cgroups, error)

GetCgroups reads the systems cgroup subsystems, read from /proc/cgroups in the given Procfs.

func (*Cgroups) UnmarshalText

func (cs *Cgroups) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/cgroups.

type DiskStat

type DiskStat struct {
	Major          int
	Minor          int
	Name           string
	Reads          uint64
	ReadMerged     uint64
	ReadSectors    uint64
	ReadTicks      uint64
	Writes         uint64
	WriteMerged    uint64
	WriteSectors   uint64
	WriteTicks     uint64
	InFlight       uint64
	IOTicks        uint64
	TimeInQueue    uint64
	Discards       uint64
	DiscardMerged  uint64
	DiscardSectors uint64
	DiscardTicks   uint64
	Flushes        uint64
	FlushTicks     uint64
}

DiskStat contains the I/O statistics for a single block storage device, read from /proc/diskstats.

References:

  • linux/Documentation/admin-guide/iostats.rst

func (*DiskStat) UnmarshalText

func (d *DiskStat) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/diskstats.

type DiskStats

type DiskStats []*DiskStat

DiskStats contains I/O statistics for the systems block storage devices, read from /proc/diskstats.

References:

  • linux/Documentation/admin-guide/iostats.rst

func GetDiskStats

func GetDiskStats(proc Procfs) (DiskStats, error)

GetDiskStats reads I/O statistics for the systems block storage devices, read from /proc/diskstats in the given Procfs.

func (*DiskStats) UnmarshalText

func (ds *DiskStats) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/diskstats.

type Error

type Error struct {
	// Name is the basename of the file requested.
	Name string

	// Path is the relative path within the procfs filesystem attempted.
	Path string

	// Inner is the actual error, returned by [Error.Unwrap].
	Inner error
}

Error wraps errors returned by Procfs to contextualize the path within the procfs filesystem that was being read.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Filesystem

type Filesystem struct {
	NoDev bool
	Name  string
}

Filesystem is one of the filesystems supported by the kernel, read from /proc/filesystems.

References:

  • proc_filesystems(5)

func (*Filesystem) UnmarshalText

func (f *Filesystem) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/filesystems.

type Filesystems

type Filesystems []*Filesystem

Filesystems are the filesystems supported by the kernel, read from /proc/filesystems.

References:

  • proc_filesystems(5)

func GetFilesystems

func GetFilesystems(proc Procfs) (Filesystems, error)

GetFilesystems reads the filesystems supported by the kernel, read from /proc/filesystems in the given Procfs.

func (*Filesystems) UnmarshalText

func (fs *Filesystems) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/filesystems.

type LinkStat

type LinkStat struct {
	Name string
	Rx   RxStats
	Tx   TxStats
}

LinkStat contains the receive and transmit statistics for a single network interface, read from /proc/net/dev.

References:

  • proc_net(5)

func (*LinkStat) UnmarshalText

func (l *LinkStat) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/net/dev.

type LinkStats

type LinkStats []*LinkStat

LinkStats contains the receive and transmit statistics for the systems network interfaces, read from /proc/net/dev.

References:

  • proc_net(5)

func GetLinkStats

func GetLinkStats(proc Procfs) (LinkStats, error)

GetLinkStats reads receive and transmit statistics for the systems network interfaces, read from /proc/net/dev for the given Procfs.

func (*LinkStats) UnmarshalText

func (ls *LinkStats) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/net/dev.

type LoadAvg

type LoadAvg struct {
	// Load is the 1, 5 and 15 minute load average.
	Load [3]float64

	Runnable  int
	Scheduled int
	LastPID   int
}

LoadAvg contains information about the systems load and scheduling, read from /proc/loadavg.

References:

  • proc_loadavg(5)

func GetLoadAvg

func GetLoadAvg(proc Procfs) (*LoadAvg, error)

GetLoadAvg reads system load and scheduling information, from /proc/loadavg in the given Procfs.

func (*LoadAvg) UnmarshalText

func (l *LoadAvg) UnmarshalText(b []byte) error

UnmarshalText unmarshals the contents of /proc/loadavg.

type Meminfo

type Meminfo struct {
	MemTotal          uint64
	MemFree           uint64
	MemAvailable      uint64
	Buffers           uint64
	Cached            uint64
	SwapCached        uint64
	Active            uint64
	Inactive          uint64
	ActiveAnon        uint64
	InactiveAnon      uint64
	ActiveFile        uint64
	InactiveFile      uint64
	Unevictable       uint64
	Mlocked           uint64
	SwapTotal         uint64
	SwapFree          uint64
	Zswap             uint64
	Zswapped          uint64
	Dirty             uint64
	Writeback         uint64
	AnonPages         uint64
	Mapped            uint64
	Shmem             uint64
	KReclaimable      uint64
	Slab              uint64
	SReclaimable      uint64
	SUnreclaim        uint64
	KernelStack       uint64
	PageTables        uint64
	SecPageTables     uint64
	NFSUnstable       uint64
	Bounce            uint64
	WritebackTmp      uint64
	CommitLimit       uint64
	CommittedAS       uint64
	VmallocTotal      uint64
	VmallocUsed       uint64
	VmallocChunk      uint64
	Percpu            uint64
	HardwareCorrupted uint64
	AnonHugePages     uint64
	ShmemHugePages    uint64
	ShmemPmdMapped    uint64
	FileHugePages     uint64
	FilePmdMapped     uint64
	CmaTotal          uint64
	CmaFree           uint64
	Unaccepted        uint64
	Balloon           uint64
	HugePagesTotal    uint64
	HugePagesFree     uint64
	HugePagesRsvd     uint64
	HugePagesSurp     uint64
	Hugepagesize      uint64
	Hugetlb           uint64
	DirectMap4k       uint64
	DirectMap2M       uint64
	DirectMap1G       uint64
}

Meminfo contains memory, swap and cache usage information, read from /proc/meminfo. All values are in kilobytes.

References:

  • proc_meminfo(5)

func GetMeminfo

func GetMeminfo(proc Procfs) (*Meminfo, error)

GetMeminfo get memory, swap and cache usage information, read from /proc/meminfo in the given Procfs.

func (*Meminfo) UnmarshalText

func (m *Meminfo) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/meminfo.

type Module

type Module struct {
	Name      string
	Size      uint64
	Instances int
	Depends   []string
	State     string
}

Module is a currently loaded Linux Kernel module, read from /proc/modules.

References:

  • proc_modules(5)

func (*Module) UnmarshalText

func (m *Module) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/modules.

type Modules

type Modules []*Module

Modules are the currently loaded Linux Kernel modules, read from /proc/modules.

References:

  • proc_modules(5)

func GetModules

func GetModules(proc Procfs) (Modules, error)

GetModules reads the currently loaded Linux Kernel modules, from /proc/modules in the given Procfs.

func (*Modules) UnmarshalText

func (ms *Modules) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/modules.

type Mount

type Mount struct {
	ID           int
	ParentID     int
	Device       string
	Root         string
	Path         string
	Options      []string
	Tags         []string
	Type         string
	Source       string
	SuperOptions []string
}

Mount is a single mounted filesystem visible in a process' namespace, read from /proc/<pid>/mountinfo.

References:

  • proc_pid_mountinfo(5)

func (*Mount) UnmarshalText

func (m *Mount) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/<pid>/mountinfo.

type Mounts

type Mounts []*Mount

Mounts are the mounted filesystems visible in a process' namespace, read from /proc/<pid>/mountinfo.

References:

  • proc_pid_mountinfo(5)

func GetMounts

func GetMounts(proc Procfs) (Mounts, error)

GetMounts reads the mounted filesystems visible in the current process' namespace, read from /proc/self/mountinfo in the given Procfs.

func (*Mounts) UnmarshalText

func (ms *Mounts) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/<pid>/mountinfo.

type Partition

type Partition struct {
	Major  int
	Minor  int
	Blocks uint64
	Name   string
}

Partition is one of the partitions read from /proc/partitions.

References:

  • proc_partitions(5)

func (*Partition) UnmarshalText

func (p *Partition) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/partitions.

type Partitions

type Partitions []*Partition

Partitions are the partitions read from /proc/partitions.

References:

  • proc_partitions(5)

func GetPartitions

func GetPartitions(proc Procfs) (Partitions, error)

GetPartitions reads the systems partitions from /proc/partitions in the given Procfs.

func (*Partitions) UnmarshalText

func (ps *Partitions) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/partitions.

type Processor

type Processor struct {
	ID       int
	Vendor   string
	Model    string
	Core     int
	BogoMIPS float64
}

Processor contains information about one of the systems processors or processor cores (depending on platform), read from /proc/cpuinfo.

Due to the platform-specific nature of the contents of /proc/cpuinfo, this is not an extensive implementation of all possible fields, merely a best effort to capture the primary information.

type Procfs

type Procfs interface {
	// List all the files and directories at a given path within the procfs
	// filesystem.
	List(path string) ([]fs.DirEntry, error)

	// Read a path from the procfs filesystem, and unmarshal it's contents to
	// a pointer to an object implementing the [encoding.TextUnmarshaler]
	// interface.
	Read(path string, dst encoding.TextUnmarshaler) error

	// ReadBytes reads a path from the procfs filesystem as bytes.
	//
	// Any leading or trailing whitespace will automatically be trimmed.
	ReadBytes(path string) ([]byte, error)

	// ReadString reads a path from the procfs filesystem as a string.
	//
	// Any leading or trailing whitespace will automatically be trimmed.
	ReadString(path string) (string, error)
}

Procfs implements reading structured text-based information about a system through the procfs filesystem.

func From

func From(proc fs.FS) Procfs

From initializes a new Procfs with a given fs.FS pointing to the procfs filesystem.

This is useful for situations where the target procfs to read from is not mounted at /proc, such as a bind mount within a container pointing to the host procfs.

func New

func New() Procfs

New initializes a new Procfs where the procfs filesystem is mounted at /proc.

To read from a procfs filesystem mounted elsewhere, such as inside a container and wanting to read the host procfs, see From.

type RaspberryPi

type RaspberryPi struct {
	Overvolt     bool
	OTPWrite     bool
	OTPRead      bool
	Warranty     bool
	New          bool
	Memory       int
	Manufacturer string
	Processor    string
	Type         string
	Revision     int
}

RaspberryPi is a Board that contains structured information decoded from a "new-style" Raspberry Pi "Revision" within /proc/cpuinfo.

References:

func (RaspberryPi) BoardVendor

func (RaspberryPi) BoardVendor() string

BoardVendor returns "Raspberry Pi".

func (RaspberryPi) BoardVersion

func (r RaspberryPi) BoardVersion() string

BoardVersion returns the type of Raspberry Pi.

type RxStats

type RxStats struct {
	Bytes      uint64
	Packets    uint64
	Errors     uint64
	Dropped    uint64
	FIFO       uint64
	Frame      uint64
	Compressed uint64
	Multicast  uint64
}

RxStats contains the receive statistics for a LinkStat.

type Stat

type Stat struct {
	Pid                 int
	Command             string
	State               State
	Ppid                int
	Pgrp                int
	Session             int
	TTY                 int
	Tpgid               int
	Flags               uint
	Minflt              uint
	Cminflt             uint
	Majflt              uint
	Cmajflt             uint
	Utime               uint
	Stime               uint
	Cutime              int
	Cstime              int
	Priority            int
	Nice                int
	NumThreads          int
	Itrealvalue         int
	StartTime           uint
	Vsize               uint
	Rss                 int
	Rsslim              uint
	StartCode           uint
	EndCode             uint
	StartStack          uint
	Kstkesp             uint
	Kstkeip             uint
	Signal              uint
	Blocked             uint
	SigIgnore           uint
	SigCatch            uint
	Wchan               uint
	Nswap               uint
	Cnswap              uint
	ExitSignal          int
	Processor           int
	RtPriority          uint
	Policy              uint
	DelayAcctBlkioTicks uint
	GuestTime           uint
	CguestTime          int
	StartData           uint
	EndData             uint
	StartBrk            uint
	ArgStart            uint
	ArgEnd              uint
	EnvStart            uint
	EnvEnd              uint
	ExitCode            int
}

Stat contains status information about a process, read from /proc/<pid>/stat.

References:

  • proc_pid_stat(5)
  • linux/fs/proc/array.c do_task_stat

func GetStat

func GetStat(proc Procfs, pid int) (*Stat, error)

GetStat reads the specified process id status information, from /proc/<pid>/stat in the given Procfs.

func (*Stat) UnmarshalText

func (s *Stat) UnmarshalText(b []byte) error

UnmarshalText unmarshals the fields from /proc/<pid>/stat.

type State

type State byte

State is the current state of a process in Stat.

const (
	Running     State = 'R'
	Sleeping    State = 'S'
	Waiting     State = 'D'
	Zombie      State = 'Z'
	Stopped     State = 'T'
	TracingStop State = 't'
	Dead        State = 'X'
	Idle        State = 'I'
)

Constants for State.

func (State) String

func (s State) String() string

type Swap

type Swap struct {
	Name     string
	Type     string
	Size     uint64
	Used     uint64
	Priority int
}

Swap is one of the swap devices configured, read from /proc/swaps.

References:

  • proc_swaps(5)
  • linux/mm/swapfile.c swap_show

func (*Swap) UnmarshalText

func (s *Swap) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/swaps.

type Swaps

type Swaps []*Swap

Swaps are the swap devices configured for the system, read from /proc/swaps.

References:

  • proc_swaps(5)
  • linux/mm/swapfile.c swap_show

func GetSwaps

func GetSwaps(proc Procfs) (Swaps, error)

GetSwaps reads the swap devices configured for the system, read from proc/swaps in the given Procfs.

func (*Swaps) UnmarshalText

func (ss *Swaps) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/swaps.

type TxStats

type TxStats struct {
	Bytes      uint64
	Packets    uint64
	Errors     uint64
	Dropped    uint64
	FIFO       uint64
	Collisions uint64
	Carrier    uint64
	Compressed uint64
}

TxStats contains the transmit statistics for a LinkStat.

type Uptime

type Uptime struct {
	Up   time.Duration
	Idle time.Duration
}

Uptime contains system uptime information, read from /proc/uptime.

References:

  • proc_uptime(5)

func GetUptime

func GetUptime(proc Procfs) (*Uptime, error)

GetUptime reads system uptime information, read from /proc/uptime in the given Procfs.

func (*Uptime) UnmarshalText

func (u *Uptime) UnmarshalText(b []byte) error

UnmarshalText unmarshals the line from /proc/uptime.

type VMStat

type VMStat struct {
	NrFreePages                 uint64
	NrFreePagesBlocks           uint64
	NrZoneInactiveAnon          uint64
	NrZoneActiveAnon            uint64
	NrZoneInactiveFile          uint64
	NrZoneActiveFile            uint64
	NrZoneUnevictable           uint64
	NrZoneWritePending          uint64
	NrMlock                     uint64
	NrZsPages                   uint64
	NrFreeCma                   uint64
	NrInactiveAnon              uint64
	NrActiveAnon                uint64
	NrInactiveFile              uint64
	NrActiveFile                uint64
	NrUnevictable               uint64
	NrSlabReclaimable           uint64
	NrSlabUnreclaimable         uint64
	NrIsolatedAnon              uint64
	NrIsolatedFile              uint64
	WorkingSetNodes             uint64
	WorkingSetRefaultAnon       uint64
	WorkingSetRefaultFile       uint64
	WorkingSetActivateAnon      uint64
	WorkingSetActivateFile      uint64
	WorkingSetRestoreAnon       uint64
	WorkingSetRestoreFile       uint64
	WorkingSetNodeReclaim       uint64
	NrAnonPages                 uint64
	NrMapped                    uint64
	NrFilePages                 uint64
	NrDirty                     uint64
	NrWriteback                 uint64
	NrShmem                     uint64
	NrShmemHugePages            uint64
	NrShmemPmdMapped            uint64
	NrFileHugePages             uint64
	NrFilePmdMapped             uint64
	NrAnonTransparentHugePages  uint64
	NrVmscanWrite               uint64
	NrVmscanImmediateReclaim    uint64
	NrDirtied                   uint64
	NrWritten                   uint64
	NrThrottledWritten          uint64
	NrKernelMiscReclaimable     uint64
	NrFollPinAcquired           uint64
	NrFollPinReleased           uint64
	NrKernelStack               uint64
	NrPageTablePages            uint64
	NrSecPageTablePages         uint64
	NrSwapCached                uint64
	PgDemoteKswapd              uint64
	PgDemoteDirect              uint64
	PgDemoteKHugePaged          uint64
	PgDemoteProactive           uint64
	NrBalloonPages              uint64
	NrKernelFilePages           uint64
	NrDirtyThreshold            uint64
	NrDirtyBackgroundThreshold  uint64
	NrMemmapPages               uint64
	NrMemmapBootPages           uint64
	Pgpgin                      uint64
	Pgpgout                     uint64
	Pswpin                      uint64
	Pswpout                     uint64
	PgAllocDMA                  uint64
	PgAllocDMA32                uint64
	PgAllocNormal               uint64
	PgAllocMovable              uint64
	AllocStallDMA               uint64
	AllocStallDMA32             uint64
	AllocStallNormal            uint64
	AllocStallMovable           uint64
	PgSkipDMA                   uint64
	PgSkipDMA32                 uint64
	PgSkipNormal                uint64
	PgSkipMovable               uint64
	PgFree                      uint64
	PgActivate                  uint64
	PgDeactivate                uint64
	PgLazyFree                  uint64
	PgFault                     uint64
	PgMajFault                  uint64
	PgLazyFreed                 uint64
	PgRefill                    uint64
	PgReuse                     uint64
	PgStealKswapd               uint64
	PgStealDirect               uint64
	PgStealKHugePaged           uint64
	PgStealProactive            uint64
	PgScanKswapd                uint64
	PgScanDirect                uint64
	PgScanKHugePaged            uint64
	PgScanProactive             uint64
	PgScanDirectThrottle        uint64
	PgScanAnon                  uint64
	PgScanFile                  uint64
	PgStealAnon                 uint64
	PgStealFile                 uint64
	PgInodeSteal                uint64
	SlabsScanned                uint64
	KswapdInodeSteal            uint64
	KswapdLowWmarkHitQuickly    uint64
	KswapdHighWmarkHitQuickly   uint64
	PageOutRun                  uint64
	PgRotated                   uint64
	DropPageCache               uint64
	DropSlab                    uint64
	OomKill                     uint64
	PgMigrateSuccess            uint64
	PgMigrateFail               uint64
	ThpMigrationSuccess         uint64
	ThpMigrationFail            uint64
	ThpMigrationSplit           uint64
	CompactMigrateScanned       uint64
	CompactFreeScanned          uint64
	CompactIsolated             uint64
	CompactStall                uint64
	CompactFail                 uint64
	CompactSuccess              uint64
	CompactDaemonWake           uint64
	CompactDaemonMigrateScanned uint64
	CompactDaemonFreeScanned    uint64
	UnevictablePgsCulled        uint64
	UnevictablePgsScanned       uint64
	UnevictablePgsRescued       uint64
	UnevictablePgsMlocked       uint64
	UnevictablePgsMunlocked     uint64
	UnevictablePgsCleared       uint64
	UnevictablePgsStranded      uint64
	ThpFaultAlloc               uint64
	ThpFaultFallback            uint64
	ThpFaultFallbackCharge      uint64
	ThpCollapseAlloc            uint64
	ThpCollapseAllocFailed      uint64
	ThpFileAlloc                uint64
	ThpFileFallback             uint64
	ThpFileFallbackCharge       uint64
	ThpFileMapped               uint64
	ThpSplitPage                uint64
	ThpSplitPageFailed          uint64
	ThpDeferredSplitPage        uint64
	ThpUnderusedSplitPage       uint64
	ThpSplitPmd                 uint64
	ThpScanExceedNonePte        uint64
	ThpScanExceedSwapPte        uint64
	ThpScanExceedSharePte       uint64
	ThpZeroPageAlloc            uint64
	ThpZeroPageAllocFailed      uint64
	ThpSwpout                   uint64
	ThpSwpoutFallback           uint64
	BalloonInflate              uint64
	BalloonDeflate              uint64
	BalloonMigrate              uint64
	SwapRa                      uint64
	SwapRaHit                   uint64
	SwpinZero                   uint64
	SwpoutZero                  uint64
	NrUnstable                  uint64
}

VMStat contains virtual memory statistics, read from /proc/vmstat.

Some values are absolute measures, and some are incrementing counters.

References:

  • proc_vmstat(5)

func GetVMStat

func GetVMStat(proc Procfs) (*VMStat, error)

GetVMStat gets virtual memory statistics about the system, read from /proc/vmstat in the given Procfs.

func (*VMStat) UnmarshalText

func (v *VMStat) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/vmstat.

type WirelessStat

type WirelessStat struct {
	Name    string
	Status  uint16
	Quality int
	Level   int
	Noise   int
	Nwid    uint64
	Crypt   uint64
	Frag    uint64
	Retry   uint64
	Misc    uint64
	Beacon  uint64
}

WirelessStat contains statistics about a single wireless network interface, read from /proc/net/wireless.

References:

  • linux/net/wireless/wext-proc.c

func (*WirelessStat) UnmarshalText

func (w *WirelessStat) UnmarshalText(b []byte) error

UnmarshalText unmarshals a single line from /proc/net/wireless.

type WirelessStats

type WirelessStats []*WirelessStat

WirelessStats contains statistics about the systems wireless network interfaces, read from /proc/net/wireless.

References:

  • linux/net/wireless/wext-proc.c

func GetWirelessStats

func GetWirelessStats(proc Procfs) (WirelessStats, error)

GetWirelessStats reads statistics about the systems wireless network interfaces, read from /proc/net/wireless in the given Procfs.

func (*WirelessStats) UnmarshalText

func (ws *WirelessStats) UnmarshalText(b []byte) error

UnmarshalText unmarshals the lines from /proc/net/wireless.

Directories

Path Synopsis
internal
utils
Package utils contains a set of utilities that make it easier to deal with files within the procfs filesystem, but don't make sense to expose as the general purpose API.
Package utils contains a set of utilities that make it easier to deal with files within the procfs filesystem, but don't make sense to expose as the general purpose API.
Package sysctl implements reading the sysctl Linux Kernel parameters exposed through the procfs filesystem.
Package sysctl implements reading the sysctl Linux Kernel parameters exposed through the procfs filesystem.

Jump to

Keyboard shortcuts

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