Documentation
¶
Overview ¶
Package procfs implements reading structured text-based information about a system through the procfs filesystem.
Index ¶
- type Board
- type CPUInfo
- type CPUStat
- type CPUStats
- type Cgroup
- type Cgroups
- type DiskStat
- type DiskStats
- type Error
- type Filesystem
- type Filesystems
- type LinkStat
- type LinkStats
- type LoadAvg
- type Meminfo
- type Module
- type Modules
- type Mount
- type Mounts
- type Partition
- type Partitions
- type Processor
- type Procfs
- type RaspberryPi
- type RxStats
- type Stat
- type State
- type Swap
- type Swaps
- type TxStats
- type Uptime
- type VMStat
- type WirelessStat
- type WirelessStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
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 ¶
GetCPUInfo reads information about the systems processors or processor cores (depending on platform), read from /proc/cpuinfo using the given Procfs.
func (*CPUInfo) UnmarshalText ¶
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 ¶
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 ¶
GetCPUStats reads statistics about processor time and running processed, read from /proc/stat in the given Procfs.
func (*CPUStats) UnmarshalText ¶
UnmarshalText unmarshals the lines from /proc/stat.
type Cgroup ¶
Cgroup contains details of a single cgroup subsystem, read from /proc/cgroups.
References:
- proc_groups
func (*Cgroup) UnmarshalText ¶
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 ¶
GetCgroups reads the systems cgroup subsystems, read from /proc/cgroups in the given Procfs.
func (*Cgroups) UnmarshalText ¶
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 ¶
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 ¶
GetDiskStats reads I/O statistics for the systems block storage devices, read from /proc/diskstats in the given Procfs.
func (*DiskStats) UnmarshalText ¶
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.
type Filesystem ¶
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 ¶
LinkStat contains the receive and transmit statistics for a single network interface, read from /proc/net/dev.
References:
- proc_net(5)
func (*LinkStat) UnmarshalText ¶
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 ¶
GetLinkStats reads receive and transmit statistics for the systems network interfaces, read from /proc/net/dev for the given Procfs.
func (*LinkStats) UnmarshalText ¶
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 ¶
GetLoadAvg reads system load and scheduling information, from /proc/loadavg in the given Procfs.
func (*LoadAvg) UnmarshalText ¶
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 ¶
GetMeminfo get memory, swap and cache usage information, read from /proc/meminfo in the given Procfs.
func (*Meminfo) UnmarshalText ¶
UnmarshalText unmarshals the lines from /proc/meminfo.
type Module ¶
Module is a currently loaded Linux Kernel module, read from /proc/modules.
References:
- proc_modules(5)
func (*Module) UnmarshalText ¶
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 ¶
GetModules reads the currently loaded Linux Kernel modules, from /proc/modules in the given Procfs.
func (*Modules) UnmarshalText ¶
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 ¶
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 ¶
GetMounts reads the mounted filesystems visible in the current process' namespace, read from /proc/self/mountinfo in the given Procfs.
func (*Mounts) UnmarshalText ¶
UnmarshalText unmarshals the lines from /proc/<pid>/mountinfo.
type Partition ¶
Partition is one of the partitions read from /proc/partitions.
References:
- proc_partitions(5)
func (*Partition) UnmarshalText ¶
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 ¶
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.
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 ¶
GetStat reads the specified process id status information, from /proc/<pid>/stat in the given Procfs.
func (*Stat) UnmarshalText ¶
UnmarshalText unmarshals the fields from /proc/<pid>/stat.
type State ¶
type State byte
State is the current state of a process in Stat.
type Swap ¶
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 ¶
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 ¶
GetSwaps reads the swap devices configured for the system, read from proc/swaps in the given Procfs.
func (*Swaps) UnmarshalText ¶
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 ¶
Uptime contains system uptime information, read from /proc/uptime.
References:
- proc_uptime(5)
func GetUptime ¶
GetUptime reads system uptime information, read from /proc/uptime in the given Procfs.
func (*Uptime) UnmarshalText ¶
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
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 ¶
GetVMStat gets virtual memory statistics about the system, read from /proc/vmstat in the given Procfs.
func (*VMStat) UnmarshalText ¶
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. |