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

..03-May-2022-

.circleci/H26-Aug-2020-6458

bcache/H26-Aug-2020-823633

blockdevice/H26-Aug-2020-556406

btrfs/H26-Aug-2020-423280

internal/H26-Aug-2020-542315

iscsi/H26-Aug-2020-606465

nfs/H26-Aug-2020-1,2991,095

scripts/H26-Aug-2020-3012

sysfs/H26-Aug-2020-2,7361,973

xfs/H26-Aug-2020-1,7311,468

.gitignoreH A D26-Aug-202011 21

.golangci.ymlH A D26-Aug-202034 54

CODE_OF_CONDUCT.mdH A D26-Aug-2020155 42

CONTRIBUTING.mdH A D26-Aug-20206.5 KiB12282

LICENSEH A D26-Aug-202011.1 KiB202169

MAINTAINERS.mdH A D26-Aug-2020102 32

MakefileH A D26-Aug-2020859 3012

Makefile.commonH A D26-Aug-20209.6 KiB301223

NOTICEH A D26-Aug-2020237 85

README.mdH A D26-Aug-20202.7 KiB6245

arp.goH A D26-Aug-20202.2 KiB8654

arp_test.goH A D26-Aug-20201.2 KiB4424

buddyinfo.goH A D26-Aug-20202.2 KiB8656

buddyinfo_test.goH A D26-Aug-20202.3 KiB7551

cpuinfo.goH A D26-Aug-202011.8 KiB465413

cpuinfo_armx.goH A D26-Aug-2020681 202

cpuinfo_mipsx.goH A D26-Aug-2020700 202

cpuinfo_others.goH A D26-Aug-2020761 202

cpuinfo_ppcx.goH A D26-Aug-2020685 202

cpuinfo_s390x.goH A D26-Aug-2020663 192

cpuinfo_test.goH A D26-Aug-202010.9 KiB376320

cpuinfo_x86.goH A D26-Aug-2020681 202

crypto.goH A D26-Aug-20203.5 KiB154115

crypto_test.goH A D26-Aug-20203.1 KiB131109

doc.goH A D26-Aug-20201.3 KiB461

fixtures.ttarH A D26-Aug-2020222.3 KiB6,1866,073

fs.goH A D26-Aug-20201.4 KiB4418

fs_test.goH A D26-Aug-20201.1 KiB4021

fscache.goH A D26-Aug-202015.4 KiB423298

fscache_test.goH A D26-Aug-20206.7 KiB137119

go.modH A D26-Aug-2020198 107

go.sumH A D26-Aug-2020583 76

ipvs.goH A D26-Aug-20205.9 KiB242189

ipvs_test.goH A D26-Aug-20206.6 KiB255229

kernel_random.goH A D26-Aug-20202.1 KiB6332

kernel_random_test.goH A D26-Aug-20201.6 KiB5130

loadavg.goH A D26-Aug-20201.6 KiB6339

loadavg_test.goH A D26-Aug-20202.1 KiB9471

mdstat.goH A D26-Aug-20205.7 KiB198137

mdstat_test.goH A D26-Aug-20204 KiB7148

meminfo.goH A D26-Aug-20208 KiB278184

meminfo_test.goH A D26-Aug-20202 KiB7860

mountinfo.goH A D26-Aug-20205.2 KiB181125

mountinfo_test.goH A D26-Aug-20206.9 KiB185166

mountstats.goH A D26-Aug-202018.3 KiB630402

mountstats_test.goH A D26-Aug-202015.8 KiB500470

net_conntrackstat.goH A D26-Aug-20203.8 KiB154108

net_conntrackstat_test.goH A D26-Aug-20202.6 KiB8668

net_dev.goH A D26-Aug-20206.4 KiB206159

net_dev_test.goH A D26-Aug-20202.5 KiB8761

net_sockstat.goH A D26-Aug-20204.3 KiB164103

net_sockstat_test.goH A D26-Aug-20204.6 KiB214173

net_softnet.goH A D26-Aug-20202.5 KiB10360

net_softnet_test.goH A D26-Aug-20201.3 KiB6038

net_udp.goH A D26-Aug-20206.7 KiB230159

net_udp_test.goH A D26-Aug-20206.7 KiB258240

net_unix.goH A D26-Aug-20205.9 KiB258175

net_unix_test.goH A D26-Aug-20203.8 KiB171128

proc.goH A D26-Aug-20207.3 KiB320222

proc_cgroup.goH A D26-Aug-20203.6 KiB9955

proc_cgroup_test.goH A D26-Aug-20202.4 KiB9473

proc_environ.goH A D26-Aug-20201.1 KiB3817

proc_environ_test.goH A D26-Aug-20201.3 KiB4828

proc_fdinfo.goH A D26-Aug-20203.4 KiB13489

proc_fdinfo_test.goH A D26-Aug-2020989 3519

proc_io.goH A D26-Aug-20201.6 KiB6027

proc_io_test.goH A D26-Aug-20201.4 KiB4729

proc_limits.goH A D26-Aug-20204.6 KiB158102

proc_limits_test.goH A D26-Aug-20201.2 KiB4527

proc_maps.goH A D26-Aug-20204.5 KiB210139

proc_maps32_test.goH A D26-Aug-20202.2 KiB9265

proc_maps64_test.goH A D26-Aug-20203.4 KiB137110

proc_ns.goH A D26-Aug-20201.9 KiB6941

proc_ns_test.goH A D26-Aug-20201.2 KiB4526

proc_psi.goH A D26-Aug-20203.3 KiB10154

proc_psi_test.goH A D26-Aug-20203.9 KiB150116

proc_smaps.goH A D26-Aug-20203.8 KiB166110

proc_smaps_test.goH A D26-Aug-20202.3 KiB9267

proc_stat.goH A D26-Aug-20205.3 KiB193103

proc_stat_test.goH A D26-Aug-20202.9 KiB12898

proc_status.goH A D26-Aug-20204.4 KiB171107

proc_status_test.goH A D26-Aug-20203.2 KiB11085

proc_test.goH A D26-Aug-20206.5 KiB279246

schedstat.goH A D26-Aug-20202.9 KiB11973

schedstat_test.goH A D26-Aug-20203.5 KiB13094

stat.goH A D26-Aug-20207.1 KiB245179

stat_test.goH A D26-Aug-20202.2 KiB7541

swaps.goH A D26-Aug-20202.2 KiB9063

swaps_test.goH A D26-Aug-20202.7 KiB11491

ttarH A D26-Aug-202011.6 KiB414328

vm.goH A D26-Aug-20207.7 KiB211178

vm_test.goH A D26-Aug-20203 KiB8868

xfrm.goH A D26-Aug-20204.8 KiB188127

xfrm_test.goH A D26-Aug-20203.1 KiB6750

zoneinfo.goH A D26-Aug-20206.3 KiB197166

zoneinfo_test.goH A D26-Aug-20202.6 KiB4524

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