• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H11-Nov-2019-

bcache/H11-Nov-2019-

blockdevice/H11-Nov-2019-

btrfs/H11-Nov-2019-

internal/H11-Nov-2019-

iscsi/H11-Nov-2019-

nfs/H11-Nov-2019-

scripts/H11-Nov-2019-

sysfs/H11-Nov-2019-

xfs/H11-Nov-2019-

.gitignoreH A D11-Nov-201911

.golangci.ymlH A D11-Nov-2019144

CONTRIBUTING.mdH A D11-Nov-20196.5 KiB

LICENSEH A D11-Nov-201911.1 KiB

MAINTAINERS.mdH A D11-Nov-2019102

MakefileH A D11-Nov-2019859

Makefile.commonH A D11-Nov-20198.9 KiB

NOTICEH A D11-Nov-2019237

README.mdH A D11-Nov-20192.7 KiB

arp.goH A D11-Nov-20192.2 KiB

arp_test.goH A D11-Nov-20191.2 KiB

buddyinfo.goH A D11-Nov-20192.2 KiB

buddyinfo_test.goH A D11-Nov-20192.3 KiB

cpuinfo.goH A D11-Nov-20194.3 KiB

cpuinfo_test.goH A D11-Nov-20191.9 KiB

crypto.goH A D11-Nov-20193.5 KiB

crypto_test.goH A D11-Nov-20192.7 KiB

doc.goH A D11-Nov-20191.3 KiB

fixtures.ttarH A D11-Nov-2019193 KiB

fs.goH A D11-Nov-20191.4 KiB

fs_test.goH A D11-Nov-20191.1 KiB

go.modH A D11-Nov-2019145

go.sumH A D11-Nov-2019376

ipvs.goH A D11-Nov-20195.9 KiB

ipvs_test.goH A D11-Nov-20196.6 KiB

mdstat.goH A D11-Nov-20195.6 KiB

mdstat_test.goH A D11-Nov-20193.9 KiB

meminfo.goH A D11-Nov-201912.3 KiB

meminfo_test.goH A D11-Nov-20192 KiB

mountinfo.goH A D11-Nov-20195.2 KiB

mountinfo_test.goH A D11-Nov-20195.6 KiB

mountstats.goH A D11-Nov-201918.1 KiB

mountstats_test.goH A D11-Nov-201911.9 KiB

net_dev.goH A D11-Nov-20196.4 KiB

net_dev_test.goH A D11-Nov-20192.5 KiB

net_softnet.goH A D11-Nov-20192.8 KiB

net_softnet_test.goH A D11-Nov-20191.1 KiB

net_unix.goH A D11-Nov-20196.8 KiB

net_unix_test.goH A D11-Nov-20193.9 KiB

proc.goH A D11-Nov-20196.9 KiB

proc_environ.goH A D11-Nov-20191.1 KiB

proc_environ_test.goH A D11-Nov-20191.3 KiB

proc_fdinfo.goH A D11-Nov-20193.2 KiB

proc_fdinfo_test.goH A D11-Nov-2019989

proc_io.goH A D11-Nov-20191.6 KiB

proc_io_test.goH A D11-Nov-20191.4 KiB

proc_limits.goH A D11-Nov-20194.6 KiB

proc_limits_test.goH A D11-Nov-20191.2 KiB

proc_ns.goH A D11-Nov-20191.9 KiB

proc_ns_test.goH A D11-Nov-20191.2 KiB

proc_psi.goH A D11-Nov-20193.3 KiB

proc_psi_test.goH A D11-Nov-20193.9 KiB

proc_stat.goH A D11-Nov-20195.3 KiB

proc_stat_test.goH A D11-Nov-20192.9 KiB

proc_status.goH A D11-Nov-20193.8 KiB

proc_status_test.goH A D11-Nov-20192.6 KiB

proc_test.goH A D11-Nov-20196 KiB

schedstat.goH A D11-Nov-20192.9 KiB

schedstat_test.goH A D11-Nov-20193.5 KiB

stat.goH A D11-Nov-20197.1 KiB

stat_test.goH A D11-Nov-20192.2 KiB

ttarH A D11-Nov-201911.6 KiB

vm.goH A D11-Nov-20197.7 KiB

vm_test.goH A D11-Nov-20192.9 KiB

xfrm.goH A D11-Nov-20194.8 KiB

xfrm_test.goH A D11-Nov-20193.1 KiB

zoneinfo.goH A D11-Nov-20196.3 KiB

zoneinfo_test.goH A D11-Nov-20192.6 KiB

README.md

1# procfs
2
3This package provides functions to retrieve system, kernel, and process
4metrics from the pseudo-filesystems /proc and /sys.
5
6*WARNING*: This package is a work in progress. Its API may still break in
7backwards-incompatible ways without warnings. Use it at your own risk.
8
9[![GoDoc](https://godoc.org/github.com/prometheus/procfs?status.png)](https://godoc.org/github.com/prometheus/procfs)
10[![Build Status](https://travis-ci.org/prometheus/procfs.svg?branch=master)](https://travis-ci.org/prometheus/procfs)
11[![Go Report Card](https://goreportcard.com/badge/github.com/prometheus/procfs)](https://goreportcard.com/report/github.com/prometheus/procfs)
12
13## Usage
14
15The procfs library is organized by packages based on whether the gathered data is coming from
16/proc, /sys, or both.  Each package contains an `FS` type which represents the path to either /proc,
17/sys, or both.  For example, cpu statistics are gathered from
18`/proc/stat` and are available via the root procfs package.  First, the proc filesystem mount
19point is initialized, and then the stat information is read.
20
21```go
22fs, err := procfs.NewFS("/proc")
23stats, err := fs.Stat()
24```
25
26Some sub-packages such as `blockdevice`, require access to both the proc and sys filesystems.
27
28```go
29    fs, err := blockdevice.NewFS("/proc", "/sys")
30    stats, err := fs.ProcDiskstats()
31```
32
33## Package Organization
34
35The packages in this project are organized according to (1) whether the data comes from the `/proc` or
36`/sys` filesystem and (2) the type of information being retrieved.  For example, most process information
37can be gathered from the functions in the root `procfs` package.  Information about block devices such as disk drives
38is available in the `blockdevices` sub-package.
39
40## Building and Testing
41
42The procfs library is intended to be built as part of another application, so there are no distributable binaries.
43However, most of the API includes unit tests which can be run with `make test`.
44
45### Updating Test Fixtures
46
47The procfs library includes a set of test fixtures which include many example files from
48the `/proc` and `/sys` filesystems.  These fixtures are included as a [ttar](https://github.com/ideaship/ttar) file
49which is extracted automatically during testing.  To add/update the test fixtures, first
50ensure the `fixtures` directory is up to date by removing the existing directory and then
51extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
52
53```bash
54rm -rf fixtures
55make test
56```
57
58Next, make the required changes to the extracted files in the `fixtures` directory.  When
59the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file
60based on the updated `fixtures` directory.  And finally, verify the changes using
61`git diff fixtures.ttar`.
62