Skip to content
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

ImSingee/procfs

This branch is 4 commits ahead of, 149 commits behind prometheus/procfs:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2246fee · Oct 3, 2024
Dec 17, 2022
Dec 17, 2022
Jun 19, 2022
Nov 4, 2022
Jun 19, 2022
Mar 21, 2023
Jun 19, 2022
Dec 17, 2022
Sep 25, 2022
Mar 20, 2023
Mar 20, 2023
Jun 7, 2022
Jun 7, 2022
Nov 25, 2021
May 6, 2022
Jun 19, 2022
Jan 22, 2015
May 7, 2019
Jun 7, 2022
Mar 24, 2023
Jan 22, 2015
Jul 5, 2021
May 6, 2022
Jun 19, 2022
Sep 20, 2021
Feb 10, 2021
May 30, 2019
Jul 5, 2021
Apr 15, 2022
Dec 17, 2022
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
Feb 10, 2021
Nov 26, 2019
Dec 17, 2022
Mar 7, 2023
Jun 7, 2022
Feb 10, 2021
Mar 27, 2020
Apr 1, 2023
Apr 1, 2023
Jun 19, 2022
May 30, 2019
Apr 15, 2022
Jun 7, 2022
Nov 25, 2021
Jan 23, 2020
Oct 3, 2024
Oct 3, 2024
Feb 10, 2021
Jan 11, 2021
Apr 17, 2020
Apr 17, 2020
Dec 17, 2022
Jan 21, 2022
Mar 21, 2023
Mar 21, 2023
Nov 24, 2021
Nov 24, 2021
Nov 25, 2021
Mar 24, 2021
Nov 25, 2021
Jan 11, 2021
Feb 10, 2021
Nov 25, 2019
Dec 18, 2022
Dec 18, 2022
Feb 5, 2021
Jun 7, 2022
Feb 8, 2021
Jun 7, 2022
Feb 10, 2021
Nov 26, 2019
Feb 23, 2023
Feb 23, 2023
Jan 26, 2022
Jan 26, 2022
Oct 13, 2022
Aug 9, 2021
Mar 7, 2023
Sep 2, 2022
Feb 3, 2021
Dec 9, 2021
Dec 17, 2022
Nov 25, 2021
Jun 20, 2019
Nov 25, 2021
Jun 26, 2019
Dec 17, 2022
Dec 17, 2022
Oct 4, 2019
May 30, 2019
Nov 25, 2021
Jan 11, 2021
Apr 15, 2022
Apr 15, 2022
Apr 15, 2022
Dec 17, 2022
Sep 24, 2022
Feb 10, 2021
May 30, 2019
Nov 25, 2021
Sep 25, 2022
Apr 15, 2022
Apr 15, 2022
Sep 24, 2022
Sep 24, 2022
Sep 24, 2022
Sep 24, 2022
Mar 7, 2023
Jul 17, 2022
Oct 11, 2022
Oct 11, 2022
Jul 20, 2022
Jul 20, 2022
Apr 6, 2020
Nov 25, 2021
Nov 25, 2021
Nov 25, 2021
Feb 9, 2021
Apr 17, 2022
Apr 15, 2022
Oct 29, 2022
May 30, 2019
Jan 21, 2020
Jan 21, 2022
Mar 7, 2023
Mar 7, 2023
May 16, 2019
Dec 17, 2022
Apr 15, 2022
Jun 19, 2022
Apr 15, 2022

Repository files navigation

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

rm -rf fixtures
make test

Next, make the required changes to the extracted files in the 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 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.3%
  • Shell 1.6%
  • Makefile 0.1%