You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ben Kochie 4850c19784
Unwrap infiband error (#264)
2 days ago
.circleci enable codespell 9 months ago
bcache remove top level constructor functions 8 months ago
blockdevice remove top level constructor functions 8 months ago
btrfs Add tests and fixtures for Btrfs 4 months ago
internal procfs: implement parsing of NetSockstat{,6} 2 months ago
iscsi procfs: re-enable golangci-lint and fix issues 2 months ago
nfs remove top level constructor functions 8 months ago
scripts Add license check tool 2 years ago
sysfs Unwrap infiband error (#264) 2 days ago
xfs Expose xs_qm_dquot_unused XFS counter 2 weeks ago
.gitignore Package fixtures directory using ttar 2 years ago
.golangci.yml procfs: re-enable golangci-lint and fix issues 2 months ago
CONTRIBUTING.md introduce new function ReadFileNoStat 4 months ago
LICENSE License cleanup 5 years ago
MAINTAINERS.md Make @pgier a maintainer (#155) 9 months ago
Makefile echoes when extracting fixtures 9 months ago
Makefile.common makefile: update Makefile.common with newer version 2 months ago
NOTICE License cleanup 5 years ago
README.md update readme and contributing guide 5 months ago
arp.go define constants outside of loop 6 months ago
arp_test.go rebase Initial support for parsing /proc/net/arp #105 from @skottler 6 months ago
buddyinfo.go fixing a few golint warnings 5 months ago
buddyinfo_test.go remove top level constructor functions 8 months ago
cpuinfo.go introduce new function ReadFileNoStat 4 months ago
cpuinfo_test.go use string type for ID fields and float64 for CPU MHz 5 months ago
crypto.go procfs: clean up /proc/crypto parser and tests 2 months ago
crypto_test.go procfs: clean up /proc/crypto parser and tests 2 months ago
doc.go Update example 5 years ago
fixtures.ttar Fix the overflow while parsing ipv6 addr inside net_udp.go 3 weeks ago
fs.go remove top level constructor functions 8 months ago
fs_test.go Improved error message in getProcFixtures() 8 months ago
go.mod update go module dependencies 4 months ago
go.sum update go module dependencies 4 months ago
ipvs.go introduce new function ReadFileNoStat 4 months ago
ipvs_test.go remove top level constructor functions 8 months ago
loadavg.go Add support for /proc/loadavg 3 weeks ago
loadavg_test.go Add support for /proc/loadavg 3 weeks ago
mdstat.go Minor refactorings: 8 months ago
mdstat_test.go Minor refactorings: 8 months ago
meminfo.go procfs: simplify meminfo parser 2 months ago
meminfo_test.go feat: Add support for meminfo 3 months ago
mountinfo.go Update mountinfo parsing (#228) 3 months ago
mountinfo_test.go Update mountinfo parsing (#228) 3 months ago
mountstats.go Fix overflow in mounstats 8 months ago
mountstats_test.go remove top level constructor functions 8 months ago
net_conntrackstat.go Added parsing netfilter conntrack statistics from net/stat/nf_conntrack 3 weeks ago
net_conntrackstat_test.go Added parsing netfilter conntrack statistics from net/stat/nf_conntrack 3 weeks ago
net_dev.go Fix: RxPackets is doubled in package procfs (#226) 4 months ago
net_dev_test.go remove top level constructor functions 8 months ago
net_sockstat.go procfs: ensure NetSockstat6 compatibility with os.IsNotExist 2 months ago
net_sockstat_test.go procfs: ensure NetSockstat6 compatibility with os.IsNotExist 2 months ago
net_softnet.go procfs: clean up softnet parsing APIs and code 1 month ago
net_softnet_test.go procfs: clean up softnet parsing APIs and code 1 month ago
net_udp.go Use net.IP instead of []uint8 for IPs. 3 weeks ago
net_udp_test.go Use net.IP instead of []uint8 for IPs. 3 weeks ago
net_unix.go procfs: change Unix to UNIX per Go conventions 2 months ago
net_unix_test.go procfs: change Unix to UNIX per Go conventions 2 months ago
proc.go Update mountinfo parsing (#228) 3 months ago
proc_environ.go introduce new function ReadFileNoStat 4 months ago
proc_environ_test.go update fixtures for proc environ 8 months ago
proc_fdinfo.go introduce new function ReadFileNoStat 4 months ago
proc_fdinfo_test.go Parse fdinfo and inotify stats from /proc/[pid]/fdinfo/[fd] (#115) 7 months ago
proc_io.go introduce new function ReadFileNoStat 4 months ago
proc_io_test.go remove top level constructor functions 8 months ago
proc_limits.go re-add functions required by client_golang 8 months ago
proc_limits_test.go remove top level constructor functions 8 months ago
proc_ns.go remove top level constructor functions 8 months ago
proc_ns_test.go remove top level constructor functions 8 months ago
proc_psi.go introduce new function ReadFileNoStat 4 months ago
proc_psi_test.go remove top level constructor functions 8 months ago
proc_stat.go introduce new function ReadFileNoStat 4 months ago
proc_stat_test.go remove top level constructor functions 8 months ago
proc_status.go Add UIDs to ProcStatus struct 2 months ago
proc_status_test.go Add UIDs to ProcStatus struct 2 months ago
proc_test.go Parse fdinfo and inotify stats from /proc/[pid]/fdinfo/[fd] (#115) 7 months ago
schedstat.go fixing a few golint warnings 5 months ago
schedstat_test.go Fix seconds reported by schedstat 6 months ago
stat.go Convert stat parser to ReadFileNoStat() (#231) 3 months ago
stat_test.go remove top level constructor functions 8 months ago
swaps.go Add support for /proc/swaps 4 weeks ago
swaps_test.go swaps_test.go: Use subtests and add a fixture test 4 weeks ago
ttar update vendored ttar 9 months ago
vm.go Change vm to use *int64 instead of int64 in struct fields 6 months ago
vm_test.go procfs: re-enable golangci-lint and fix issues 2 months ago
xfrm.go Use FS struct for proc and sys mount points in submodules (#149) 9 months ago
xfrm_test.go Use FS struct for proc and sys mount points in submodules (#149) 9 months ago
zoneinfo.go address review on !195 6 months ago
zoneinfo_test.go remove duplicate test util function 6 months ago

README.md

procfs

This package provides functions to retrieve system, kernel, and process metrics from the pseudo-filesystems /proc and /sys.

WARNING: This package is a work in progress. Its API may still break in backwards-incompatible ways without warnings. Use it at your own risk.

GoDoc Build Status Go Report Card

Usage

The procfs library is organized by packages based on whether the gathered data is coming from /proc, /sys, or both. Each package contains an FS type which represents the path to either /proc, /sys, or both. For example, cpu statistics are gathered from /proc/stat and are available via the root procfs package. First, the proc filesystem mount point is initialized, and then the stat information is read.

fs, err := procfs.NewFS("/proc")
stats, err := fs.Stat()

Some sub-packages such as blockdevice, require access to both the proc and sys filesystems.

    fs, err := blockdevice.NewFS("/proc", "/sys")
    stats, err := fs.ProcDiskstats()

Package Organization

The packages in this project are organized according to (1) whether the data comes from the /proc or /sys filesystem and (2) the type of information being retrieved. For example, most process information can be gathered from the functions in the root procfs package. Information about block devices such as disk drives is available in the blockdevices sub-package.

Building and Testing

The procfs library is intended to be built as part of another application, so there are no distributable binaries.
However, most of the API includes unit tests which can be run with make test.

Updating Test Fixtures

The procfs library includes a set of test fixtures which include many example files from the /proc and /sys filesystems. These fixtures are included as a ttar file which is extracted automatically during testing. To add/update the test fixtures, first ensure the fixtures directory is up to date by removing the existing directory and then extracting the ttar file using make fixtures/.unpacked or just make test.

rm -rf fixtures
make test

Next, make the required changes to the extracted files in the fixtures directory. When the changes are complete, run make update_fixtures to create a new fixtures.ttar file based on the updated fixtures directory. And finally, verify the changes using git diff fixtures.ttar.