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

..20-Dec-2019-

internal/fs/H20-Dec-2019-5324

xfs/H20-Dec-2019-524379

CONTRIBUTING.mdH A D20-Dec-2019870 1914

LICENSEH A D20-Dec-201911.1 KiB202169

MAINTAINERS.mdH A D20-Dec-2019102 32

MakefileH A D20-Dec-2019859 3012

Makefile.commonH A D20-Dec-20198.8 KiB273198

NOTICEH A D20-Dec-2019237 85

README.mdH A D20-Dec-20192.3 KiB5439

buddyinfo.goH A D20-Dec-20192.2 KiB8656

doc.goH A D20-Dec-20191.3 KiB461

fixtures.ttarH A D20-Dec-201974.7 KiB1,8091,798

fs.goH A D20-Dec-20191.4 KiB4418

go.modH A D20-Dec-201998 42

go.sumH A D20-Dec-2019209 32

ipvs.goH A D20-Dec-20195.9 KiB240188

mdstat.goH A D20-Dec-20194.4 KiB152104

mountstats.goH A D20-Dec-201918.1 KiB622397

net_dev.goH A D20-Dec-20196.4 KiB207160

net_unix.goH A D20-Dec-20196.8 KiB276208

proc.goH A D20-Dec-20196 KiB268186

proc_io.goH A D20-Dec-20191.6 KiB6633

proc_limits.goH A D20-Dec-20194.6 KiB158102

proc_ns.goH A D20-Dec-20191.9 KiB6941

proc_psi.goH A D20-Dec-20193.3 KiB10256

proc_stat.goH A D20-Dec-20195.4 KiB199108

proc_status.goH A D20-Dec-20193.8 KiB163104

stat.goH A D20-Dec-20197 KiB245178

ttarH A D20-Dec-201911.6 KiB414328

xfrm.goH A D20-Dec-20194.8 KiB188127

README.md

1# procfs
2
3This procfs 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, /sys, or both.  For example, current cpu statistics are gathered from
17`/proc/stat` and are available via the root procfs package.  First, the proc filesystem mount
18point is initialized, and then the stat information is read.
19
20```go
21fs, err := procfs.NewFS("/proc")
22stats, err := fs.Stat()
23```
24
25Some sub-packages such as `blockdevice`, require access to both the proc and sys filesystems.
26
27```go
28    fs, err := blockdevice.NewFS("/proc", "/sys")
29    stats, err := fs.ProcDiskstats()
30```
31
32## Building and Testing
33
34The procfs library is normally built as part of another application.  However, when making
35changes to the library, the `make test` command can be used to run the API test suite.
36
37### Updating Test Fixtures
38
39The procfs library includes a set of test fixtures which include many example files from
40the `/proc` and `/sys` filesystems.  These fixtures are included as a [ttar](https://github.com/ideaship/ttar) file
41which is extracted automatically during testing.  To add/update the test fixtures, first
42ensure the `fixtures` directory is up to date by removing the existing directory and then
43extracting the ttar file using `make fixtures/.unpacked` or just `make test`.
44
45```bash
46rm -rf fixtures
47make test
48```
49
50Next, make the required changes to the extracted files in the `fixtures` directory.  When
51the changes are complete, run `make update_fixtures` to create a new `fixtures.ttar` file
52based on the updated `fixtures` directory.  And finally, verify the changes using
53`git diff fixtures.ttar`.
54