Skip to content
/ procfs Public
forked from prometheus/procfs

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.

License

Notifications You must be signed in to change notification settings

jritter/procfs

This branch is up to date with prometheus/procfs:master.

Folders and files

NameName
Last commit message
Last commit date
Oct 1, 2024
Sep 7, 2024
Feb 3, 2025
Feb 3, 2025
Nov 26, 2024
Sep 6, 2024
Feb 3, 2025
Jul 17, 2023
Sep 22, 2023
Jun 15, 2023
Jun 3, 2024
Feb 3, 2025
Feb 3, 2025
Jun 7, 2022
Jun 7, 2022
Feb 3, 2025
May 6, 2022
Jun 19, 2022
Jan 22, 2015
Apr 9, 2024
Jun 7, 2022
Sep 22, 2024
Jan 22, 2015
Feb 3, 2025
May 6, 2022
Feb 3, 2025
Sep 20, 2021
May 12, 2024
May 23, 2023
Jul 5, 2021
Apr 15, 2022
Apr 10, 2024
Apr 15, 2022
Dec 17, 2022
Apr 15, 2022
Dec 17, 2022
Apr 15, 2022
Apr 15, 2022
Apr 15, 2022
Dec 17, 2022
Apr 15, 2022
Apr 10, 2024
Nov 26, 2019
Dec 17, 2022
Nov 26, 2024
Feb 3, 2025
Sep 22, 2023
Jun 7, 2022
Feb 3, 2025
Mar 27, 2020
Feb 2, 2025
Feb 2, 2025
Apr 10, 2024
May 30, 2019
Apr 15, 2022
Jun 7, 2022
Apr 10, 2024
Jan 23, 2020
May 13, 2024
Jun 3, 2024
Apr 10, 2024
Dec 14, 2023
Apr 10, 2024
Apr 17, 2020
Feb 3, 2025
May 12, 2024
Apr 10, 2024
Jun 3, 2024
Nov 24, 2021
Feb 3, 2025
Feb 3, 2025
Nov 24, 2021
Feb 3, 2025
Nov 28, 2023
May 23, 2023
Jan 11, 2021
Jun 15, 2023
Jun 15, 2023
Apr 10, 2024
Nov 25, 2019
Apr 10, 2024
May 20, 2023
Jun 3, 2024
Feb 15, 2024
Feb 15, 2024
Feb 15, 2024
Feb 8, 2021
Jun 3, 2024
Feb 3, 2025
Nov 26, 2019
Apr 10, 2024
Feb 23, 2023
May 23, 2023
Jan 26, 2022
May 5, 2023
Aug 9, 2021
May 12, 2024
Feb 3, 2025
Feb 3, 2021
May 23, 2023
Dec 17, 2022
Nov 25, 2021
Jun 20, 2019
Sep 22, 2023
Jun 26, 2019
May 23, 2023
Dec 17, 2022
Feb 3, 2025
May 30, 2019
Apr 10, 2024
Jan 11, 2021
Sep 22, 2023
Apr 15, 2022
Sep 22, 2023
May 23, 2023
Sep 24, 2022
Apr 10, 2024
May 30, 2019
Apr 10, 2024
Jul 17, 2023
Feb 3, 2025
Apr 15, 2022
May 23, 2023
Sep 24, 2022
Sep 24, 2022
Sep 24, 2022
Feb 15, 2024
Jul 17, 2022
Jul 14, 2024
Jul 14, 2024
Apr 10, 2024
May 23, 2023
Jun 3, 2024
Nov 25, 2021
Nov 25, 2021
May 23, 2023
Feb 9, 2021
Apr 10, 2024
Apr 15, 2022
Apr 10, 2024
Jul 10, 2023
Apr 10, 2024
Jan 21, 2022
Apr 10, 2024
Mar 7, 2023
May 16, 2019
May 23, 2023
Apr 15, 2022
Apr 10, 2024
Apr 15, 2022

procfs

This 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.

Go Reference CircleCI 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, 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()

Package Organization

The packages in this project are organized according to (1) whether the data comes from the /proc or /sys filesystem and (2) the type of information being retrieved. For example, most process information can be gathered from the functions in the root procfs package. Information about block devices such as disk drives is available in the blockdevices sub-package.

Building and Testing

The procfs library is intended to be built as part of another application, so there are no distributable binaries.
However, most of the API includes unit tests which can be run with make test.

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 testdata/fixtures directory is up to date by removing the existing directory and then extracting the ttar file using make testdata/fixtures/.unpacked or just make test.

rm -rf testdata/fixtures
make test

Next, make the required changes to the extracted files in the testdata/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 testdata/fixtures.ttar.

About

procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.5%
  • Shell 1.4%
  • Makefile 0.1%