package procfs
Import Path
github.com/prometheus/procfs (on go.dev)
Dependency Relation
imports 17 packages, and imported by one package
Involved Source Files
arp.go
buddyinfo.go
cpuinfo.go
crypto.go
Package procfs provides functions to retrieve system, kernel and process
metrics from the pseudo-filesystem proc.
Example:
package main
import (
"fmt"
"log"
"github.com/prometheus/procfs"
)
func main() {
p, err := procfs.Self()
if err != nil {
log.Fatalf("could not get process: %s", err)
}
stat, err := p.NewStat()
if err != nil {
log.Fatalf("could not get process stat: %s", err)
}
fmt.Printf("command: %s\n", stat.Comm)
fmt.Printf("cpu time: %fs\n", stat.CPUTime())
fmt.Printf("vsize: %dB\n", stat.VirtualMemory())
fmt.Printf("rss: %dB\n", stat.ResidentMemory())
}
fs.go
ipvs.go
mdstat.go
meminfo.go
mountinfo.go
mountstats.go
net_dev.go
net_sockstat.go
net_softnet.go
net_unix.go
proc.go
proc_environ.go
proc_fdinfo.go
proc_io.go
proc_limits.go
proc_ns.go
proc_psi.go
proc_stat.go
proc_status.go
schedstat.go
stat.go
vm.go
xfrm.go
zoneinfo.go
Package-Level Type Names (total 49, all are exported)
ARPEntry contains a single row of the columnar data represented in
/proc/net/arp.
Name of the device
MAC address
IP address
func FS.GatherARPEntries() ([]ARPEntry, error)
func parseARPEntries(data []byte) ([]ARPEntry, error)
func parseARPEntry(columns []string) (ARPEntry, error)
A BuddyInfo is the details parsed from /proc/buddyinfo.
The data is comprised of an array of free fragments of each size.
The sizes are 2^n*PAGE_SIZE, where n is the array index.
Node string
Sizes []float64
Zone string
func FS.BuddyInfo() ([]BuddyInfo, error)
func parseBuddyInfo(r io.Reader) ([]BuddyInfo, error)
CPUInfo contains general information about a system CPU found in /proc/cpuinfo
APICID string
AddressSizes string
BogoMips float64
Bugs []string
CLFlushSize uint
CPUCores uint
CPUFamily string
CPUIDLevel uint
CPUMHz float64
CacheAlignment uint
CacheSize string
CoreID string
FPU string
FPUException string
Flags []string
InitialAPICID string
Microcode string
Model string
ModelName string
PhysicalID string
PowerManagement string
Processor uint
Siblings uint
Stepping string
VendorID string
WP string
func FS.CPUInfo() ([]CPUInfo, error)
func parseCPUInfo(info []byte) ([]CPUInfo, error)
CPUStat shows how much time the cpu spend in various stages.
Guest float64
GuestNice float64
IRQ float64
Idle float64
Iowait float64
Nice float64
SoftIRQ float64
Steal float64
System float64
User float64
func parseCPUStat(line string) (CPUStat, int64, error)
Crypto holds info parsed from /proc/crypto.
Alignmask *uint64
Async bool
Blocksize *uint64
Chunksize *uint64
Ctxsize *uint64
Digestsize *uint64
Driver string
Geniv string
Internal string
Ivsize *uint64
MaxKeysize *uint64
Maxauthsize *uint64
MinKeysize *uint64
Module string
Name string
Priority *int64
Refcnt *int64
Seedsize *uint64
Selftest string
Type string
Walksize *uint64
func FS.Crypto() ([]Crypto, error)
func parseCrypto(cryptoData []byte) ([]Crypto, error)
FS represents the pseudo-filesystem sys, which provides an interface to
kernel data structures.
proc fs.FS
AllProcs returns a list of all currently available processes.
BuddyInfo reads the buddyinfo statistics from the specified `proc` filesystem.
CPUInfo returns information about current system CPUs.
See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
Crypto parses an crypto-file (/proc/crypto) and returns a slice of
structs containing the relevant info. More information available here:
https://kernel.readthedocs.io/en/sphinx-samples/crypto-API.html
GatherARPEntries retrieves all the ARP entries, parse the relevant columns,
and then return a slice of ARPEntry's.
GatherSoftnetStats reads /proc/net/softnet_stat, parse the relevant columns,
and then return a slice of SoftnetEntry's.
IPVSBackendStatus reads and returns the status of all (virtual,real) server pairs from the specified `proc` filesystem.
IPVSStats reads the IPVS statistics from the specified `proc` filesystem.
MDStat parses an mdstat-file (/proc/mdstat) and returns a slice of
structs containing the relevant info. More information available here:
https://raid.wiki.kernel.org/index.php/Mdstat
Meminfo returns an information about current kernel/system memory statistics.
See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
NetDev returns kernel/system statistics read from /proc/net/dev.
NetSockstat retrieves IPv4 socket statistics.
NetSockstat6 retrieves IPv6 socket statistics.
If IPv6 is disabled on this kernel, the returned error can be checked with
os.IsNotExist.
NewNetUnix returns data read from /proc/net/unix.
NewProc returns a process for the given pid.
Deprecated: use fs.Proc() instead
NewStat returns information about current cpu/process statistics.
See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
Deprecated: use fs.Stat() instead
NewXfrmStat reads the xfrm_stat statistics from the 'proc' filesystem.
PSIStatsForResource reads pressure stall information for the specified
resource from /proc/pressure/<resource>. At time of writing this can be
either "cpu", "memory" or "io".
Proc returns a process for the given pid.
Schedstat reads data from /proc/schedstat
Self returns a process for the current process.
Stat returns information about current cpu/process statistics.
See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
VM reads the VM statistics from the specified `proc` filesystem.
Zoneinfo parses an zoneinfo-file (/proc/zoneinfo) and returns a slice of
structs containing the relevant info. More information available here:
https://www.kernel.org/doc/Documentation/sysctl/vm.txt
func NewDefaultFS() (FS, error)
func NewFS(mountPoint string) (FS, error)
InotifyInfo represents a single inotify line in the fdinfo file.
Inode number
Mask of events being monitored
Device ID
Watch descriptor number
func parseInotifyInfo(line string) (*InotifyInfo, error)
IPVSBackendStatus holds current metrics of one virtual / real address pair.
The current number of active connections for this virtual/real address pair.
The current number of inactive connections for this virtual/real address pair.
The local (virtual) IP address.
The local firewall mark
The local (virtual) port.
The transport protocol (TCP, UDP).
The remote (real) IP address.
The remote (real) port.
The current weight of this virtual/real address pair.
func FS.IPVSBackendStatus() ([]IPVSBackendStatus, error)
func parseIPVSBackendStatus(file io.Reader) ([]IPVSBackendStatus, error)
IPVSStats holds IPVS statistics, as exposed by the kernel in `/proc/net/ip_vs_stats`.
Total count of connections.
Total incoming traffic.
Total incoming packages processed.
Total outgoing traffic.
Total outgoing packages processed.
func FS.IPVSStats() (IPVSStats, error)
func parseIPVSStats(r io.Reader) (IPVSStats, error)
MDStat holds info parsed from /proc/mdstat.
activity-state of the device.
Number of blocks on the device that are in sync.
Number of blocks the device holds.
Number of active disks.
Number of failed disks.
Spare disks in the device.
Total number of disks the device requires.
Name of the device.
func FS.MDStat() ([]MDStat, error)
func parseMDStat(mdStatData []byte) ([]MDStat, error)
Meminfo represents memory statistics.
Memory that has been used more recently and usually not
reclaimed unless absolutely necessary.
ActiveAnon uint64
ActiveFile uint64
AnonHugePages uint64
Non-file backed pages mapped into userspace page tables
Memory used for block device "bounce buffers"
Relatively temporary storage for raw disk blocks shouldn't
get tremendously large (20MB or so)
Cached uint64
CmaFree uint64
CmaTotal uint64
Based on the overcommit ratio ('vm.overcommit_ratio'),
this is the total amount of memory currently available to
be allocated on the system. This limit is only adhered to
if strict overcommit accounting is enabled (mode 2 in
'vm.overcommit_memory').
The CommitLimit is calculated with the following formula:
CommitLimit = ([total RAM pages] - [total huge TLB pages]) *
overcommit_ratio / 100 + [total swap pages]
For example, on a system with 1G of physical RAM and 7G
of swap with a `vm.overcommit_ratio` of 30 it would
yield a CommitLimit of 7.3G.
For more details, see the memory overcommit documentation
in vm/overcommit-accounting.
The amount of memory presently allocated on the system.
The committed memory is a sum of all of the memory which
has been allocated by processes, even if it has not been
"used" by them as of yet. A process which malloc()'s 1G
of memory, but only touches 300M of it will show up as
using 1G. This 1G is memory which has been "committed" to
by the VM and can be used at any time by the allocating
application. With strict overcommit enabled on the system
(mode 2 in 'vm.overcommit_memory'),allocations which would
exceed the CommitLimit (detailed above) will not be permitted.
This is useful if one needs to guarantee that processes will
not fail due to lack of memory once that memory has been
successfully allocated.
DirectMap1G uint64
DirectMap2M uint64
DirectMap4k uint64
Memory which is waiting to get written back to the disk
HardwareCorrupted uint64
HugePagesFree uint64
HugePagesRsvd uint64
HugePagesSurp uint64
HugePagesTotal uint64
Hugepagesize uint64
Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes
InactiveAnon uint64
InactiveFile uint64
KernelStack uint64
files which have been mapped, such as libraries
An estimate of how much memory is available for starting
new applications, without swapping. Calculated from
MemFree, SReclaimable, the size of the file LRU lists, and
the low watermarks in each zone. The estimate takes into
account that the system needs some page cache to function
well, and that not all reclaimable slab will be
reclaimable, due to items being in use. The impact of those
factors will vary from system to system.
The sum of LowFree+HighFree
Total usable ram (i.e. physical ram minus a few reserved
bits and the kernel binary code)
Mlocked uint64
NFS pages sent to the server, but not yet committed to
stable storage
amount of memory dedicated to the lowest level of page
tables.
Part of Slab, that might be reclaimed, such as caches
Part of Slab, that cannot be reclaimed on memory pressure
Shmem uint64
ShmemHugePages uint64
ShmemPmdMapped uint64
in-kernel data structures cache
Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it
doesn't need to be swapped out AGAIN because it is already
in the swapfile. This saves I/O)
Memory which has been evicted from RAM, and is temporarily
on the disk
total amount of swap space available
Unevictable uint64
largest contiguous block of vmalloc area which is free
total size of vmalloc memory area
amount of vmalloc area which is used
Memory which is actively being written back to the disk
Memory used by FUSE for temporary writeback buffers
func FS.Meminfo() (Meminfo, error)
func parseMemInfo(r io.Reader) (*Meminfo, error)
A Mount is a device mount parsed from /proc/[pid]/mountstats.
Name of the device.
The mount point of the device.
If available additional statistics related to this Mount.
Use a type assertion to determine if additional statistics are available.
The filesystem type used by the device.
func Proc.MountStats() ([]*Mount, error)
func parseMount(ss []string) (*Mount, error)
func parseMountStats(r io.Reader) ([]*Mount, error)
A MountInfo is a type that describes the details, options
for each mount, parsed from /proc/self/mountinfo.
The fields described in each entry of /proc/self/mountinfo
is described in the following man page.
http://man7.org/linux/man-pages/man5/proc.5.html
The Filesystem type
The value of `st_dev` for the files on this FS
Unique Id for the mount
The pathname of the mount point relative to the root
Zero or more optional fields
Mount options
The Id of the parent mount
The pathname of the directory in the FS that forms
the root for this mount
FS specific information or "none"
Superblock options
func GetMounts() ([]*MountInfo, error)
func GetProcMounts(pid int) ([]*MountInfo, error)
func Proc.MountInfo() ([]*MountInfo, error)
func parseMountInfo(info []byte) ([]*MountInfo, error)
func parseMountInfoString(mountString string) (*MountInfo, error)
A MountStats is a type which contains detailed statistics for a specific
type of Mount.
( T) mountStats()
MountStatsNFS
A MountStatsNFS is a MountStats implementation for NFSv3 and v4 mounts.
The age of the NFS mount.
Statistics related to byte counters for various operations.
Statistics related to various NFS event occurrences.
Statistics broken down by filesystem operation.
The mount options of the NFS mount.
The version of statistics provided.
Statistics about the NFS RPC transport.
mountStats implements MountStats.
T : MountStats
func parseMountStatsNFS(s *bufio.Scanner, statVersion string) (*MountStatsNFS, error)
Namespace represents a single namespace of a process.
// Inode number of the namespace. If two processes are in the same namespace their inodes will match.
// Namespace type.
Namespaces contains all of the namespaces that the process is contained in.
func Proc.Namespaces() (Namespaces, error)
NetDev is parsed from /proc/net/dev or /proc/[pid]/net/dev. The map keys
are interface names.
Total aggregates the values across interfaces and returns a new NetDevLine.
The Name field will be a sorted comma separated list of interface names.
parseLine parses a single line from the /proc/net/dev file. Header lines
must be filtered prior to calling this method.
func FS.NetDev() (NetDev, error)
func Proc.NetDev() (NetDev, error)
func newNetDev(file string) (NetDev, error)
NetDevLine is single line parsed from /proc/net/dev or /proc/[pid]/net/dev.
// The name of the interface.
// Cumulative count of bytes received.
// Cumulative count of compressed packets received by the device driver.
// Cumulative count of packets dropped while receiving.
// Cumulative count of receive errors encountered.
// Cumulative count of FIFO buffer errors.
// Cumulative count of packet framing errors.
// Cumulative count of multicast frames received by the device driver.
// Cumulative count of packets received.
// Cumulative count of bytes transmitted.
// Cumulative count of carrier losses detected by the device driver.
// Cumulative count of collisions detected on the interface.
// Cumulative count of compressed packets transmitted by the device driver.
// Cumulative count of packets dropped while transmitting.
// Cumulative count of transmit errors encountered.
// Cumulative count of FIFO buffer errors.
// Cumulative count of packets transmitted.
func NetDev.Total() NetDevLine
func NetDev.parseLine(rawLine string) (*NetDevLine, error)
A NetSockstat contains the output of /proc/net/sockstat{,6} for IPv4 or IPv6,
respectively.
Protocols []NetSockstatProtocol
Used is non-nil for IPv4 sockstat results, but nil for IPv6.
func FS.NetSockstat() (*NetSockstat, error)
func FS.NetSockstat6() (*NetSockstat, error)
func parseSockstat(r io.Reader) (*NetSockstat, error)
func readSockstat(name string) (*NetSockstat, error)
A NetSockstatProtocol contains statistics about a given socket protocol.
Pointer fields indicate that the value may or may not be present on any
given protocol.
Alloc *int
InUse int
Mem *int
Memory *int
Orphan *int
Protocol string
TW *int
func parseSockstatProtocol(kvs map[string]int) NetSockstatProtocol
NetUnix holds the data read from /proc/net/unix.
Rows []*NetUnixLine
( T) parseFlags(hexStr string) (NetUnixFlags, error)
( T) parseInode(inodeStr string) (uint64, error)
( T) parseKernelPtr(str string) (string, error)
(*T) parseLine(line string, hasInode bool, minFieldsCnt int) (*NetUnixLine, error)
( T) parseState(hexStr string) (NetUnixState, error)
( T) parseType(hexStr string) (NetUnixType, error)
( T) parseUsers(hexStr string) (uint64, error)
func NewNetUnix() (*NetUnix, error)
func NewNetUnixByPath(path string) (*NetUnix, error)
func NewNetUnixByReader(reader io.Reader) (*NetUnix, error)
func FS.NewNetUnix() (*NetUnix, error)
NetUnixFlags is the type of the flags field.
( T) String() string
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NetUnix.parseFlags(hexStr string) (NetUnixFlags, error)
NetUnixLine represents a line of /proc/net/unix.
Flags NetUnixFlags
Inode uint64
KernelPtr string
Path string
Protocol uint64
RefCount uint64
State NetUnixState
Type NetUnixType
func (*NetUnix).parseLine(line string, hasInode bool, minFieldsCnt int) (*NetUnixLine, error)
NetUnixState is the type of the state field.
( T) String() string
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NetUnix.parseState(hexStr string) (NetUnixState, error)
NetUnixType is the type of the type field.
( T) String() string
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func NetUnix.parseType(hexStr string) (NetUnixType, error)
A NFSBytesStats contains statistics about the number of bytes read and written
by an NFS client to and from an NFS server.
Number of bytes read using the read() syscall in O_DIRECT mode.
Number of bytes written using the write() syscall in O_DIRECT mode.
Number of bytes read using the read() syscall.
Number of pages read directly via mmap()'d files.
Number of bytes read from the NFS server, in total.
Number of bytes written using the write() syscall.
Number of pages written directly via mmap()'d files.
Number of bytes written to the NFS server, in total.
func parseNFSBytesStats(ss []string) (*NFSBytesStats, error)
A NFSEventsStats contains statistics about NFS event occurrences.
Number of times cached inode attributes are invalidated.
Unknown. Possibly unused.
Number of times an inode cache is cleared.
Number of times cached dentry nodes are re-validated from the server.
Number of times cached inode attributes are re-validated from the server.
Number of times the NFS server indicated EJUKEBOX; retrieving data from
offline storage.
Number of NFS v4.1+ pNFS reads.
Number of NFS v4.1+ pNFS writes.
Number of times the NFS server gave less data than expected while reading.
Number of times the NFS server wrote less data than expected while writing.
Number of times a file was removed while still open by another process.
Number of times files have been truncated.
Number of times permissions have been checked.
Number of times files have been closed and released.
Number of pending writes that have been forcefully flushed to the server.
Number of times fsync() has been called on directories and files.
Number of times directory entries have been read with getdents().
Number of times locking has been attempted on a file.
Number of times a directory lookup has occurred.
Number of times files or directories have been open()'d.
Number of pages read directly via mmap()'d files.
Number of times a group of pages have been read.
Number of times attributes have been set on inodes.
Number of updates (and potential writes) to pages.
Number of pages written directly via mmap()'d files.
Number of times a group of pages have been written.
Number of times a file has been grown due to writes beyond its existing end.
func parseNFSEventsStats(ss []string) (*NFSEventsStats, error)
A NFSOperationStats contains statistics for a single operation.
Number of bytes received for this operation, including RPC headers and payload.
Number of bytes sent for this operation, including RPC headers and payload.
Duration all requests spent queued for transmission before they were sent.
Duration from when a request was enqueued to when it was completely handled.
Duration it took to get a reply back after the request was transmitted.
Number of times a request has had a major timeout.
The name of the operation.
Number of requests performed for this operation.
Number of times an actual RPC request has been transmitted for this operation.
func parseNFSOperationStats(s *bufio.Scanner) ([]NFSOperationStats, error)
A NFSTransportStats contains statistics for the NFS mount RPC requests and
responses.
Number of times the NFS server sent a response with a transaction ID
unknown to this client.
Number of times the client has had to establish a connection from scratch
to the NFS server.
Number of times the client has made a TCP connection to the NFS server.
Duration (in jiffies, a kernel internal unit of time) the NFS mount has
spent waiting for connections to the server to be established.
A running counter, incremented on each request as the current difference
ebetween sends and receives.
A running counter, incremented on each request by the current backlog
queue size.
A running counter, incremented on each request as the current size of the
pending queue.
A running counter, incremented on each request as the current size of the
sending queue.
Duration since the NFS mount last saw any RPC traffic.
Maximum number of simultaneously active RPC requests ever used.
The local port used for the NFS mount.
The transport protocol used for the NFS mount.
Number of RPC responses for this mount received from the NFS server.
Number of RPC requests for this mount sent to the NFS server.
func parseNFSTransportStats(ss []string, statVersion string) (*NFSTransportStats, error)
Proc provides information about a running process.
The process ID.
fs fs.FS
CmdLine returns the command line of a process.
Comm returns the command name of a process.
Cwd returns the absolute path to the current working directory of the process.
Environ reads process environments from /proc/<pid>/environ
Executable returns the absolute path of the executable command of a process.
FDInfo constructor. On kernels older than 3.8, InotifyInfos will always be empty.
FileDescriptorTargets returns the targets of all file descriptors of a process.
If a file descriptor is not a symlink to a file (like a socket), that value will be the empty string.
FileDescriptors returns the currently open file descriptors of a process.
FileDescriptorsInfo retrieves information about all file descriptors of
the process.
FileDescriptorsLen returns the number of currently open file descriptors of
a process.
IO creates a new ProcIO instance from a given Proc instance.
Limits returns the current soft limits of the process.
MountInfo retrieves mount information for mount points in a
process's namespace.
It supplies information missing in `/proc/self/mounts` and
fixes various other problems with that file too.
MountStats retrieves statistics and configuration for mount points in a
process's namespace.
Namespaces reads from /proc/<pid>/ns/* to get the namespaces of which the
process is a member.
NetDev returns kernel/system statistics read from /proc/[pid]/net/dev.
NewLimits returns the current soft limits of the process.
Deprecated: use p.Limits() instead
NewStat returns the current status information of the process.
Deprecated: use p.Stat() instead
NewStatus returns the current status information of the process.
RootDir returns the absolute path to the process's root directory (as set by chroot)
Schedstat returns task scheduling information for the process.
Stat returns the current status information of the process.
( T) fileDescriptors() ([]string, error)
( T) path(pa ...string) string
func NewProc(pid int) (Proc, error)
func Self() (Proc, error)
func FS.NewProc(pid int) (Proc, error)
func FS.Proc(pid int) (Proc, error)
func FS.Self() (Proc, error)
ProcFDInfo contains represents file descriptor information.
File descriptor
File access mode and status flags
List of inotify lines (structed) in the fdinfo file (kernel 3.8+ only)
Mount point ID
File offset
func Proc.FDInfo(fd string) (*ProcFDInfo, error)
ProcFDInfos represents a list of ProcFDInfo structs.
InotifyWatchLen returns the total number of inotify watches
( T) Len() int
( T) Less(i, j int) bool
( T) Swap(i, j int)
T : sort.Interface
T : github.com/aws/aws-sdk-go/aws/corehandlers.lener
func Proc.FileDescriptorsInfo() (ProcFDInfos, error)
ProcIO models the content of /proc/<pid>/io.
Bytes written, but taking into account truncation. See
Documentation/filesystems/proc.txt in the kernel sources for
detailed explanation.
Chars read.
Bytes read.
Read syscalls.
Write syscalls.
Chars written.
Bytes written.
func Proc.IO() (ProcIO, error)
ProcLimits represents the soft limits for each of the process's resource
limits. For more information see getrlimit(2):
http://man7.org/linux/man-pages/man2/getrlimit.2.html.
Maximum size of the process's virtual memory address space in bytes.
CPU time limit in seconds.
Maximum size of a core file.
Maximum size of the process's data segment (initialized data,
uninitialized data, and heap).
Limit on the combined number of flock(2) locks and fcntl(2) leases that
this process may establish.
Maximum size of files that the process may create.
Maximum number of bytes of memory that may be locked into RAM.
Limit on the number of bytes that can be allocated for POSIX message
queues for the real user ID of the calling process.
Limit of the nice priority set using setpriority(2) or nice(2).
Value one greater than the maximum file descriptor number that can be
opened by this process.
Limit of signals that may be queued for the real user ID of the calling
process.
Maximum number of processes that can be created for the real user ID of
the calling process.
Limit of the real-time priority set using sched_setscheduler(2) or
sched_setparam(2).
Limit (in microseconds) on the amount of CPU time that a process
scheduled under a real-time scheduling policy may consume without making
a blocking system call.
Limit of the process's resident set in pages.
Maximum size of the process stack in bytes.
func Proc.Limits() (ProcLimits, error)
func Proc.NewLimits() (ProcLimits, error)
Procs represents a list of Proc structs.
( T) Len() int
( T) Less(i, j int) bool
( T) Swap(i, j int)
T : sort.Interface
T : github.com/aws/aws-sdk-go/aws/corehandlers.lener
func AllProcs() (Procs, error)
func FS.AllProcs() (Procs, error)
ProcSchedstat contains the values from /proc/<pid>/schedstat
RunTimeslices uint64
RunningNanoseconds uint64
WaitingNanoseconds uint64
func Proc.Schedstat() (ProcSchedstat, error)
func parseProcSchedstat(contents string) (stats ProcSchedstat, err error)
ProcStat provides status information about the process,
read from /proc/[pid]/stat.
The number of major faults that the process's waited-for children have
made.
The number of minor faults that the process's waited-for children have
made.
Amount of time that this process's waited-for children have been
scheduled in kernel mode, measured in clock ticks.
Amount of time that this process's waited-for children have been
scheduled in user mode, measured in clock ticks.
The filename of the executable.
The kernel flags word of the process.
The number of major faults the process has made which have required
loading a memory page from disk.
The number of minor faults the process has made which have not required
loading a memory page from disk.
The nice value, a value in the range 19 (low priority) to -20 (high
priority).
Number of threads in this process.
The process group ID of the process.
The process ID.
The PID of the parent of this process.
For processes running a real-time scheduling policy, this is the negated
scheduling priority, minus one.
Resident set size in pages.
Amount of time that this process has been scheduled in kernel mode,
measured in clock ticks.
The session ID of the process.
The time the process started after system boot, the value is expressed
in clock ticks.
The process state.
The ID of the foreground process group of the controlling terminal of
the process.
The controlling terminal of the process.
Amount of time that this process has been scheduled in user mode,
measured in clock ticks.
Virtual memory size in bytes.
proc fs.FS
CPUTime returns the total CPU user and system time in seconds.
ResidentMemory returns the resident memory size in bytes.
StartTime returns the unix timestamp of the process in seconds.
VirtualMemory returns the virtual memory size in bytes.
func Proc.NewStat() (ProcStat, error)
func Proc.Stat() (ProcStat, error)
ProcStatus provides status information about the process,
read from /proc/[pid]/stat.
Size of hugetlb memory portions
The process name.
Number of involuntary context switches.
The process ID.
Size of resident anonymous memory.
Size of resident file mappings.
Size of resident shared memory.
Thread group ID.
Size of data segments.
Size of text segments.
Peak resident set size.
Locked memory size.
Shared library code size.
Size of second-level page tables.
Page table entries size.
Peak virtual memory size.
Pinned memory size.
Resident set size (sum of RssAnnon RssFile and RssShmem).
Virtual memory size.
Size of stack segments.
Swapped-out virtual memory size by anonymous private.
Number of voluntary context switches.
TotalCtxtSwitches returns the total context switch.
(*T) fillStatus(k string, vString string, vUint uint64, vUintBytes uint64)
func Proc.NewStatus() (ProcStatus, error)
PSILine is a single line of values as returned by /proc/pressure/*
The Avg entries are averages over n seconds, as a percentage
The Total line is in microseconds
Avg10 float64
Avg300 float64
Avg60 float64
Total uint64
PSIStats represent pressure stall information from /proc/pressure/*
Some indicates the share of time in which at least some tasks are stalled
Full indicates the share of time in which all non-idle tasks are stalled simultaneously
Full *PSILine
Some *PSILine
func FS.PSIStatsForResource(resource string) (PSIStats, error)
func parsePSIStats(resource string, r io.Reader) (PSIStats, error)
Schedstat contains scheduler statistics from /proc/schedstat
See
https://www.kernel.org/doc/Documentation/scheduler/sched-stats.txt
for a detailed description of what these numbers mean.
Note the current kernel documentation claims some of the time units are in
jiffies when they are actually in nanoseconds since 2.6.23 with the
introduction of CFS. A fix to the documentation is pending. See
https://lore.kernel.org/patchwork/project/lkml/list/?series=403473
CPUs []*SchedstatCPU
func FS.Schedstat() (*Schedstat, error)
SchedstatCPU contains the values from one "cpu<N>" line
CPUNum string
RunTimeslices uint64
RunningNanoseconds uint64
WaitingNanoseconds uint64
SoftIRQStat represent the softirq statistics as exported in the procfs stat file.
A nice introduction can be found at https://0xax.gitbooks.io/linux-insides/content/interrupts/interrupts-9.html
It is possible to get per-cpu stats by reading /proc/softirqs
Block uint64
BlockIoPoll uint64
Hi uint64
Hrtimer uint64
NetRx uint64
NetTx uint64
Rcu uint64
Sched uint64
Tasklet uint64
Timer uint64
func parseSoftIRQStat(line string) (SoftIRQStat, uint64, error)
SoftnetEntry contains a single row of data from /proc/net/softnet_stat
Number of dropped packets
Number of processed packets
Number of times processing packets ran out of quota
func FS.GatherSoftnetStats() ([]SoftnetEntry, error)
func parseSoftnetEntries(data []byte) ([]SoftnetEntry, error)
func parseSoftnetEntry(columns []string) (SoftnetEntry, error)
Stat represents kernel/system statistics.
Boot time in seconds since the Epoch.
Per-CPU statistics.
Summed up cpu statistics.
Number of times a context switch happened.
Number of times a numbered IRQ was triggered.
Number of times interrupts were handled, which contains numbered and unnumbered IRQs.
Number of times a process was created.
Number of processes currently blocked (waiting for IO).
Number of processes currently running.
Detailed softirq statistics.
Number of times a softirq was scheduled.
func NewStat() (Stat, error)
func FS.NewStat() (Stat, error)
func FS.Stat() (Stat, error)
The VM interface is described at
https://www.kernel.org/doc/Documentation/sysctl/vm.txt
Each setting is exposed as a single file.
Each file contains one line with a single numerical value, except lowmem_reserve_ratio which holds an array
and numa_zonelist_order (deprecated) which is a string
// /proc/sys/vm/admin_reserve_kbytes
// /proc/sys/vm/block_dump
// /proc/sys/vm/compact_unevictable_allowed
// /proc/sys/vm/dirty_background_bytes
// /proc/sys/vm/dirty_background_ratio
// /proc/sys/vm/dirty_bytes
// /proc/sys/vm/dirty_expire_centisecs
// /proc/sys/vm/dirty_ratio
// /proc/sys/vm/dirty_writeback_centisecs
// /proc/sys/vm/dirtytime_expire_seconds
// /proc/sys/vm/drop_caches
// /proc/sys/vm/extfrag_threshold
// /proc/sys/vm/hugetlb_shm_group
// /proc/sys/vm/laptop_mode
// /proc/sys/vm/legacy_va_layout
// /proc/sys/vm/lowmem_reserve_ratio
// /proc/sys/vm/max_map_count
// /proc/sys/vm/memory_failure_early_kill
// /proc/sys/vm/memory_failure_recovery
// /proc/sys/vm/min_free_kbytes
// /proc/sys/vm/min_slab_ratio
// /proc/sys/vm/min_unmapped_ratio
// /proc/sys/vm/mmap_min_addr
// /proc/sys/vm/nr_hugepages
// /proc/sys/vm/nr_hugepages_mempolicy
// /proc/sys/vm/nr_overcommit_hugepages
// /proc/sys/vm/numa_stat
// /proc/sys/vm/numa_zonelist_order
// /proc/sys/vm/oom_dump_tasks
// /proc/sys/vm/oom_kill_allocating_task
// /proc/sys/vm/overcommit_kbytes
// /proc/sys/vm/overcommit_memory
// /proc/sys/vm/overcommit_ratio
// /proc/sys/vm/page-cluster
// /proc/sys/vm/panic_on_oom
// /proc/sys/vm/percpu_pagelist_fraction
// /proc/sys/vm/stat_interval
// /proc/sys/vm/swappiness
// /proc/sys/vm/user_reserve_kbytes
// /proc/sys/vm/vfs_cache_pressure
// /proc/sys/vm/watermark_boost_factor
// /proc/sys/vm/watermark_scale_factor
// /proc/sys/vm/zone_reclaim_mode
func FS.VM() (*VM, error)
XfrmStat models the contents of /proc/net/xfrm_stat.
XfrmAcquireError int
XfrmFwdHdrError int
No buffer is left
All errors which are not matched by other
Header Error
No policy is found for states
e.g. Inbound SAs are correct but no SP is found
No state found
i.e. either inbound SPI, address, or IPSEC protocol at SA is wrong
Policy discards
Policy error
State is expired
State is invalid
State has mismatch option
e.g. UDP encapsulation type is mismatched
Transformation mode specific error
Transformation protocol specific error
e.g. SA Key is wrong
Sequence error
e.g. sequence number is out of window
No matching template for states
e.g. Inbound SAs are correct but SP rule is wrong
Bundle check error
Bundle generation error
All errors which are not matched by others
No state was found
Policy discads
Policy is dead
Policy Error
State is expired
XfrmOutStateInvalid int
Transportation mode specific error
Transformation protocol specific error
Sequence error
i.e sequence number overflow
func NewXfrmStat() (XfrmStat, error)
func FS.NewXfrmStat() (XfrmStat, error)
Zoneinfo holds info parsed from /proc/zoneinfo.
High *int64
Low *int64
Managed *int64
Min *int64
Node string
NrActiveAnon *int64
NrActiveFile *int64
NrAnonPages *int64
NrAnonTransparentHugepages *int64
NrDirtied *int64
NrDirty *int64
NrFilePages *int64
NrFreePages *int64
NrInactiveAnon *int64
NrInactiveFile *int64
NrIsolatedAnon *int64
NrIsolatedFile *int64
NrKernelStack *int64
NrMapped *int64
NrMlockStack *int64
NrShmem *int64
NrSlabReclaimable *int64
NrSlabUnreclaimable *int64
NrUnevictable *int64
NrWriteback *int64
NrWritten *int64
NumaForeign *int64
NumaHit *int64
NumaInterleave *int64
NumaLocal *int64
NumaMiss *int64
NumaOther *int64
Present *int64
Protection []*int64
Scanned *int64
Spanned *int64
Zone string
func FS.Zoneinfo() ([]Zoneinfo, error)
func parseZoneinfo(zoneinfoData []byte) ([]Zoneinfo, error)
Package-Level Functions (total 50, in which 12 are exported)
AllProcs returns a list of all currently available processes under /proc.
Retrieves mountinfo information from `/proc/self/mountinfo`.
Retrieves mountinfo information from a processes' `/proc/<pid>/mountinfo`.
NewDefaultFS returns a new proc FS mounted under the default proc mountPoint.
It will error if the mount point directory can't be read or is a file.
NewFS returns a new proc FS mounted under the given proc mountPoint. It will error
if the mount point directory can't be read or is a file.
NewNetUnix returns data read from /proc/net/unix.
NewNetUnixByPath returns data read from /proc/net/unix by file path.
It might returns an error with partial parsed data, if an error occur after some data parsed.
NewNetUnixByReader returns data read from /proc/net/unix by a reader.
It might returns an error with partial parsed data, if an error occur after some data parsed.
NewProc returns a process for the given pid under /proc.
NewStat returns information about current cpu/process statistics.
See https://www.kernel.org/doc/Documentation/filesystems/proc.txt
Deprecated: use fs.Stat() instead
NewXfrmStat reads the xfrm_stat statistics.
Self returns a process for the current process read via /proc/self.
Package-Level Variables (total 11, none are exported)
Package-Level Constants (total 29, in which 1 are exported)
DefaultMountPoint is the common mount point of the proc filesystem.
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |