{"id":13579363,"url":"https://github.com/eminence/procfs","last_synced_at":"2025-05-13T23:06:00.567Z","repository":{"id":32592892,"uuid":"135060366","full_name":"eminence/procfs","owner":"eminence","description":"Rust library for reading the Linux procfs filesystem","archived":false,"fork":false,"pushed_at":"2025-05-01T02:10:37.000Z","size":960,"stargazers_count":399,"open_issues_count":30,"forks_count":122,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-03T01:12:52.409Z","etag":null,"topics":["linux","proc-filesystem","procfs","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eminence.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-27T15:48:49.000Z","updated_at":"2025-05-01T02:10:41.000Z","dependencies_parsed_at":"2023-11-07T17:44:00.065Z","dependency_job_id":"8c4d30d0-7714-4a30-a35a-24424f3b3917","html_url":"https://github.com/eminence/procfs","commit_stats":{"total_commits":533,"total_committers":74,"mean_commits":7.202702702702703,"dds":0.5121951219512195,"last_synced_commit":"2f7889bf86a6f1026398431a505e236fe2ff0064"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eminence%2Fprocfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eminence%2Fprocfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eminence%2Fprocfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eminence%2Fprocfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eminence","download_url":"https://codeload.github.com/eminence/procfs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254040745,"owners_count":22004604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","proc-filesystem","procfs","rust"],"created_at":"2024-08-01T15:01:38.701Z","updated_at":"2025-05-13T23:05:55.558Z","avatar_url":"https://github.com/eminence.png","language":"Rust","readme":"procfs\n======\n\n[![Crate](https://img.shields.io/crates/v/procfs.svg)](https://crates.io/crates/procfs)\n[![Docs](https://docs.rs/procfs/badge.svg)](https://docs.rs/procfs)\n[![Minimum rustc version](https://img.shields.io/badge/rustc-1.70+-lightgray.svg)](https://github.com/eminence/procfs#minimum-rust-version)\n\n\nThis crate is an interface to the `proc` pseudo-filesystem on linux, which is normally mounted as `/proc`.\nLong-term, this crate aims to be fairly feature complete, but at the moment not all files are exposed.\nSee the docs for info on what's supported, or view the [support.md](https://github.com/eminence/procfs/blob/master/support.md)\nfile in the code repository.\n\n## Examples\nThere are several examples in the docs and in the [examples folder](https://github.com/eminence/procfs/tree/master/procfs/examples)\nof the code repository.\n\nHere's a small example that prints out all processes that are running on the same tty as the calling\nprocess.  This is very similar to what \"ps\" does in its default mode:\n\n```rust\nfn main() {\n    let me = procfs::process::Process::myself().unwrap();\n    let me_stat = me.stat().unwrap();\n    let tps = procfs::ticks_per_second();\n\n    println!(\"{: \u003e5} {: \u003c8} {: \u003e8} {}\", \"PID\", \"TTY\", \"TIME\", \"CMD\");\n\n    let tty = format!(\"pty/{}\", me_stat.tty_nr().1);\n    for prc in procfs::process::all_processes().unwrap() {\n        let prc = prc.unwrap();\n        let stat = prc.stat().unwrap();\n        if stat.tty_nr == me_stat.tty_nr {\n            // total_time is in seconds\n            let total_time =\n                (stat.utime + stat.stime) as f32 / (tps as f32);\n            println!(\n                \"{: \u003e5} {: \u003c8} {: \u003e8} {}\",\n                stat.pid, tty, total_time, stat.comm\n            );\n        }\n    }\n}\n\n```\n\nHere's another example that shows how to get the current memory usage of the current process:\n\n```rust\nuse procfs::process::Process;\n\nfn main() {\n    let me = Process::myself().unwrap();\n    let me_stat = me.stat().unwrap();\n    println!(\"PID: {}\", me.pid);\n\n    let page_size = procfs::page_size();\n    println!(\"Memory page size: {}\", page_size);\n\n    println!(\"== Data from /proc/self/stat:\");\n    println!(\"Total virtual memory used: {} bytes\", me_stat.vsize);\n    println!(\n        \"Total resident set: {} pages ({} bytes)\",\n        me_stat.rss,\n        me_stat.rss * page_size\n    );\n}\n\n```\n\nThere are a few ways to get this data, so also checkout the longer\n[self_memory](https://github.com/eminence/procfs/blob/master/procfs/examples/self_memory.rs) example for more\ndetails.\n\n## Cargo features\n\nThe following cargo features are available:\n\n* `chrono` -- Default.  Optional.  This feature enables a few methods that return values as `DateTime` objects.\n* `flate2` -- Default.  Optional.  This feature enables parsing gzip compressed `/proc/config.gz` file via the `procfs::kernel_config` method.\n* `backtrace` -- Optional.  This feature lets you get a stack trace whenever an `InternalError` is raised.\n* `serde1` -- Optional.  This feature allows most structs to be serialized and deserialized using serde 1.0.  Note, this\nfeature requires a version of rust newer than 1.70.0 (which is the MSRV for procfs).  The exact version required is not\nspecified here, since serde does not not have an MSRV policy.\n\n## Minimum Rust Version\n\nThis crate is only tested against the latest stable rustc compiler, but may\nwork with older compilers.  See [msrv.md](msrv.md) for more details.\n\n## License\n\nThe procfs library is licensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nFor additional copyright information regarding documentation, please also see the COPYRIGHT.txt file.\n\n### Contribution\n\nContributions are welcome, especially in the areas of documentation and testing on older kernels.\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the Apache-2.0\nlicense, shall be dual licensed as above, without any additional terms or\nconditions.\n","funding_links":[],"categories":["Rust","库"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feminence%2Fprocfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feminence%2Fprocfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feminence%2Fprocfs/lists"}