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

..03-May-2022-

.circleci/H10-Feb-2021-

bcache/H10-Feb-2021-

blockdevice/H10-Feb-2021-

btrfs/H10-Feb-2021-

internal/H10-Feb-2021-

iscsi/H10-Feb-2021-

nfs/H10-Feb-2021-

scripts/H10-Feb-2021-

sysfs/H10-Feb-2021-

xfs/H10-Feb-2021-

.gitignoreH A D10-Feb-202111

.golangci.ymlH A D10-Feb-202134

CODE_OF_CONDUCT.mdH A D10-Feb-2021155

CONTRIBUTING.mdH A D10-Feb-20216.5 KiB

LICENSEH A D10-Feb-202111.1 KiB

MAINTAINERS.mdH A D10-Feb-2021102

MakefileH A D10-Feb-2021859

Makefile.commonH A D10-Feb-20219.8 KiB

NOTICEH A D10-Feb-2021237

README.mdH A D10-Feb-20212.7 KiB

SECURITY.mdH A D10-Feb-2021170

arp.goH A D10-Feb-20212.2 KiB

arp_test.goH A D10-Feb-20211.2 KiB

buddyinfo.goH A D10-Feb-20212.2 KiB

buddyinfo_test.goH A D10-Feb-20212.3 KiB

cpuinfo.goH A D10-Feb-202112.2 KiB

cpuinfo_armx.goH A D10-Feb-2021681

cpuinfo_mipsx.goH A D10-Feb-2021700

cpuinfo_others.goH A D10-Feb-2021761

cpuinfo_ppcx.goH A D10-Feb-2021685

cpuinfo_riscvx.goH A D10-Feb-2021687

cpuinfo_s390x.goH A D10-Feb-2021663

cpuinfo_test.goH A D10-Feb-202111.7 KiB

cpuinfo_x86.goH A D10-Feb-2021681

crypto.goH A D10-Feb-20213.5 KiB

crypto_test.goH A D10-Feb-20213.1 KiB

doc.goH A D10-Feb-20211.3 KiB

fixtures.ttarH A D10-Feb-2021258 KiB

fs.goH A D10-Feb-20211.4 KiB

fs_test.goH A D10-Feb-20211.1 KiB

fscache.goH A D10-Feb-202115.4 KiB

fscache_test.goH A D10-Feb-20216.7 KiB

go.modH A D10-Feb-2021198

go.sumH A D10-Feb-2021798

ipvs.goH A D10-Feb-20215.9 KiB

ipvs_test.goH A D10-Feb-20216.6 KiB

kernel_random.goH A D10-Feb-20212.1 KiB

kernel_random_test.goH A D10-Feb-20211.6 KiB

loadavg.goH A D10-Feb-20211.6 KiB

loadavg_test.goH A D10-Feb-20212.1 KiB

mdstat.goH A D10-Feb-20216.2 KiB

mdstat_test.goH A D10-Feb-20214.8 KiB

meminfo.goH A D10-Feb-20218.1 KiB

meminfo_test.goH A D10-Feb-20212.5 KiB

mountinfo.goH A D10-Feb-20215.2 KiB

mountinfo_test.goH A D10-Feb-20216.9 KiB

mountstats.goH A D10-Feb-202118.6 KiB

mountstats_test.goH A D10-Feb-202116.8 KiB

net_conntrackstat.goH A D10-Feb-20213.8 KiB

net_conntrackstat_test.goH A D10-Feb-20212.6 KiB

net_dev.goH A D10-Feb-20216.4 KiB

net_dev_test.goH A D10-Feb-20212.5 KiB

net_ip_socket.goH A D10-Feb-20216.6 KiB

net_ip_socket_test.goH A D10-Feb-20213.3 KiB

net_protocols.goH A D10-Feb-20215.4 KiB

net_protocols_test.goH A D10-Feb-20214.9 KiB

net_sockstat.goH A D10-Feb-20214.3 KiB

net_sockstat_test.goH A D10-Feb-20214.6 KiB

net_softnet.goH A D10-Feb-20212.5 KiB

net_softnet_test.goH A D10-Feb-20211.3 KiB

net_tcp.goH A D10-Feb-20212.1 KiB

net_tcp_test.goH A D10-Feb-20214.1 KiB

net_udp.goH A D10-Feb-20212.1 KiB

net_udp_test.goH A D10-Feb-20214.1 KiB

net_unix.goH A D10-Feb-20215.9 KiB

net_unix_test.goH A D10-Feb-20213.8 KiB

proc.goH A D10-Feb-20217.3 KiB

proc_cgroup.goH A D10-Feb-20213.6 KiB

proc_cgroup_test.goH A D10-Feb-20212.4 KiB

proc_environ.goH A D10-Feb-20211.1 KiB

proc_environ_test.goH A D10-Feb-20211.3 KiB

proc_fdinfo.goH A D10-Feb-20213.4 KiB

proc_fdinfo_test.goH A D10-Feb-2021989

proc_io.goH A D10-Feb-20211.6 KiB

proc_io_test.goH A D10-Feb-20211.4 KiB

proc_limits.goH A D10-Feb-20214.8 KiB

proc_limits_test.goH A D10-Feb-20211.3 KiB

proc_maps.goH A D10-Feb-20214.5 KiB

proc_maps32_test.goH A D10-Feb-20212.2 KiB

proc_maps64_test.goH A D10-Feb-20213.4 KiB

proc_ns.goH A D10-Feb-20211.9 KiB

proc_ns_test.goH A D10-Feb-20211.2 KiB

proc_psi.goH A D10-Feb-20213.3 KiB

proc_psi_test.goH A D10-Feb-20213.9 KiB

proc_smaps.goH A D10-Feb-20213.8 KiB

proc_smaps_test.goH A D10-Feb-20212.3 KiB

proc_stat.goH A D10-Feb-20215.3 KiB

proc_stat_test.goH A D10-Feb-20212.9 KiB

proc_status.goH A D10-Feb-20214.4 KiB

proc_status_test.goH A D10-Feb-20213.2 KiB

proc_test.goH A D10-Feb-20216.5 KiB

schedstat.goH A D10-Feb-20213 KiB

schedstat_test.goH A D10-Feb-20213.5 KiB

slab.goH A D10-Feb-20213.5 KiB

slab_test.goH A D10-Feb-20212.3 KiB

stat.goH A D10-Feb-20217.1 KiB

stat_test.goH A D10-Feb-20212.2 KiB

swaps.goH A D10-Feb-20212.2 KiB

swaps_test.goH A D10-Feb-20212.7 KiB

ttarH A D10-Feb-202111.6 KiB

vm.goH A D10-Feb-20217.7 KiB

vm_test.goH A D10-Feb-20213 KiB

xfrm.goH A D10-Feb-20214.8 KiB

xfrm_test.goH A D10-Feb-20213.1 KiB

zoneinfo.goH A D10-Feb-20216.3 KiB

zoneinfo_test.goH A D10-Feb-20212.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