Skip to content
procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.
Branch: master
Clone or download
prombot and pgier makefile: update Makefile.common with newer version
Signed-off-by: prombot <prometheus-team@googlegroups.com>
Latest commit 90b65b6 Jun 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci enable codespell May 21, 2019
bcache remove top level constructor functions May 30, 2019
blockdevice remove top level constructor functions May 30, 2019
internal internal/util: use strconv.ParseInt's built-in hex handling Jun 12, 2019
nfs remove top level constructor functions May 30, 2019
scripts Add license check tool Feb 27, 2018
sysfs sysfs: fix typo in PowerSupply comments Jun 11, 2019
xfs remove top level constructor functions May 30, 2019
.gitignore Package fixtures directory using ttar Feb 28, 2018
.golangci.yml Synchronize Makefile.common from prometheus/prometheus (#152) Apr 25, 2019
CONTRIBUTING.md Replace AUTHORS.md by an updated MAINTAINERS.md Feb 16, 2017
LICENSE License cleanup Jan 22, 2015
MAINTAINERS.md Make @pgier a maintainer (#155) May 7, 2019
Makefile echoes when extracting fixtures May 16, 2019
Makefile.common makefile: update Makefile.common with newer version Jun 14, 2019
NOTICE License cleanup Jan 22, 2015
README.md re-add functions required by client_golang May 30, 2019
buddyinfo.go remove top level constructor functions May 30, 2019
buddyinfo_test.go remove top level constructor functions May 30, 2019
doc.go Update example Feb 22, 2015
fixtures.ttar Fix overflow in mounstats May 29, 2019
fs.go remove top level constructor functions May 30, 2019
fs_test.go Use FS struct for proc and sys mount points in submodules (#149) May 3, 2019
go.mod go.mod: add github.com/google/go-cmp Jun 11, 2019
go.sum go.mod: add github.com/google/go-cmp Jun 11, 2019
ipvs.go remove top level constructor functions May 30, 2019
ipvs_test.go remove top level constructor functions May 30, 2019
mdstat.go mdstat.go: split file I/O and parsing May 30, 2019
mdstat_test.go mdstat.go: split file I/O and parsing May 30, 2019
mountstats.go Fix overflow in mounstats May 29, 2019
mountstats_test.go remove top level constructor functions May 30, 2019
net_dev.go remove top level constructor functions May 30, 2019
net_dev_test.go remove top level constructor functions May 30, 2019
net_unix.go better kernel ptr format error msg for net/unix parser May 25, 2019
net_unix_test.go remove unused import from net_unix_test May 25, 2019
proc.go Re-add deprecated methods used by elastic/go-sysinfo Jun 3, 2019
proc_io.go remove top level constructor functions May 30, 2019
proc_io_test.go remove top level constructor functions May 30, 2019
proc_limits.go re-add functions required by client_golang May 30, 2019
proc_limits_test.go remove top level constructor functions May 30, 2019
proc_ns.go remove top level constructor functions May 30, 2019
proc_ns_test.go remove top level constructor functions May 30, 2019
proc_psi.go remove top level constructor functions May 30, 2019
proc_psi_test.go remove top level constructor functions May 30, 2019
proc_stat.go Fix deprecation note Jun 5, 2019
proc_stat_test.go remove top level constructor functions May 30, 2019
proc_status.go feat(): adding /proc/pid/status metrics May 10, 2019
proc_status_test.go remove top level constructor functions May 30, 2019
proc_test.go remove top level constructor functions May 30, 2019
stat.go Re-add deprecated methods used by elastic/go-sysinfo Jun 3, 2019
stat_test.go remove top level constructor functions May 30, 2019
ttar update vendored ttar May 16, 2019
xfrm.go Use FS struct for proc and sys mount points in submodules (#149) May 3, 2019
xfrm_test.go Use FS struct for proc and sys mount points in submodules (#149) May 3, 2019

README.md

procfs

This procfs 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, current 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()

Building and Testing

The procfs library is normally built as part of another application. However, when making changes to the library, the make test command can be used to run the API test suite.

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.

You can’t perform that action at this time.