-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Navid Yaghoobi <navidys@fedoraproject.org>
- Loading branch information
Showing
24 changed files
with
1,488 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: 'bug' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: 'feature' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Mark stale issues and pull requests | ||
|
||
# Please refer to https://github.com/actions/stale/blob/master/action.yml | ||
# to see all config knobs of the stale action. | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" | ||
|
||
jobs: | ||
stale: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/stale@v9 | ||
with: | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
stale-issue-message: 'A friendly reminder that this issue had no activity for 30 days.' | ||
stale-pr-message: 'A friendly reminder that this PR had no activity for 30 days.' | ||
stale-issue-label: 'stale-issue' | ||
stale-pr-label: 'stale-pr' | ||
days-before-stale: 30 | ||
days-before-close: 365 | ||
remove-stale-when-updated: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: validation | ||
on: | ||
pull_request: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
- uses: pre-commit/action@v3.0.1 | ||
|
||
DCO-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: get pr commits | ||
id: 'get-pr-commits' | ||
uses: tim-actions/get-pr-commits@v1.3.1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: DCO check | ||
uses: tim-actions/dco@master | ||
with: | ||
commits: ${{ steps.get-pr-commits.outputs.commits }} | ||
|
||
- name: check subject line length | ||
uses: tim-actions/commit-message-checker-with-regex@v0.3.2 | ||
with: | ||
commits: ${{ steps.get-pr-commits.outputs.commits }} | ||
pattern: '^.{0,72}(\n.*)*$' | ||
error: 'Subject too long (max 72)' | ||
|
||
codespell: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: codespell-project/actions-codespell@master | ||
with: | ||
check_filenames: true | ||
ignore_words_list: crate | ||
|
||
validate: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: make validate | ||
|
||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks.git | ||
rev: v3.4.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: mixed-line-ending | ||
- id: check-byte-order-marker | ||
- id: check-executables-have-shebangs | ||
- id: check-merge-conflict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[package] | ||
name = "procsys" | ||
version = "0.1.0" | ||
edition = "2021" | ||
authors = ["github.com/navidys/sysmetrics"] | ||
license = "MIT" | ||
readme = "README.md" | ||
description = "Rust library to retrieve system, kernel, and process metrics from the pseudo-filesystems /proc and /sys" | ||
|
||
[dependencies] | ||
env_logger = "0.11.3" | ||
getset = "0.1.2" | ||
log = "0.4.21" | ||
serde = { version = "1.0.203", features = ["derive"] } | ||
serde_json = "1.0.117" | ||
walkdir = "2.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Supported Features | ||
|
||
* `/sys/class/` | ||
* ✅ `dmi/id` | ||
* `bios_date` | ||
* `bios_release` | ||
* `bios_vendor` | ||
* `bios_version` | ||
* `board_asset_tag` | ||
* `board_name` | ||
* `board_serial` | ||
* `board_vendor` | ||
* `board_version` | ||
* `chassis_asset_tag` | ||
* `chassis_serial` | ||
* `chassis_type` | ||
* `chassis_vendor` | ||
* `product_family` | ||
* `product_name` | ||
* `product_serial` | ||
* `product_sku` | ||
* `product_uuid` | ||
* `sys_vendor` | ||
|
||
* ✅ `thermal/cooling_device<X>` | ||
* `type` | ||
* `max_state` | ||
* `cur_state` | ||
|
||
* ✅ `thermal/thermal_zone<X>` | ||
* `type` | ||
* `temp` | ||
* `policy` | ||
* `mode` | ||
* `passive` | ||
|
||
* ✅ `watchdog/<name>` | ||
* `bootstatus` | ||
* `options` | ||
* `fw_version` | ||
* `identity` | ||
* `nowayout` | ||
* `state` | ||
* `status` | ||
* `timeleft` | ||
* `timeout` | ||
* `min_timeout` | ||
* `max_timeout` | ||
* `pretimeout` | ||
* `pretimeout_governor` | ||
* `access_cs0` | ||
|
||
* `/sys/devices/system/` | ||
* ✅ `clocksource/clocksource<X>` | ||
* `available_clocksource` | ||
* `current_clocksource` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Get crate version by parsing the line that starts with version. | ||
CRATE_VERSION ?= $(shell grep ^version Cargo.toml | awk '{print $$3}') | ||
|
||
# Set path to cargo executable | ||
CARGO ?= cargo | ||
|
||
.PHONY: validate | ||
validate: $(CARGO_TARGET_DIR) ## Validate code | ||
$(CARGO) fmt --all -- --check | ||
$(CARGO) clippy -p procsys@$(CRATE_VERSION) -- -D warnings | ||
|
||
.PHONY: clean | ||
clean: ## Cleanup | ||
rm -rf target | ||
|
||
.PHONY: test | ||
test: $(CARGO_TARGET_DIR) ## Run unit tests | ||
$(CARGO) test | ||
|
||
.PHONY: codespell | ||
codespell: ## Run codespell | ||
@echo "running codespell" | ||
@codespell -S ./target,./targets -L crate | ||
|
||
_HLP_TGTS_RX = '^[[:print:]]+:.*?\#\# .*$$' | ||
_HLP_TGTS_CMD = grep -E $(_HLP_TGTS_RX) $(MAKEFILE_LIST) | ||
_HLP_TGTS_LEN = $(shell $(_HLP_TGTS_CMD) | cut -d : -f 1 | wc -L) | ||
_HLPFMT = "%-$(_HLP_TGTS_LEN)s %s\n" | ||
.PHONY: help | ||
help: ## Print listing of key targets with their descriptions | ||
@printf $(_HLPFMT) "Target:" "Description:" | ||
@printf $(_HLPFMT) "--------------" "--------------------" | ||
@$(_HLP_TGTS_CMD) | sort | \ | ||
awk 'BEGIN {FS = ":(.*)?## "}; \ | ||
{printf $(_HLPFMT), $$1, $$2}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
# procsys | ||
# procsys [![][img_crates]][crates] [![][img_doc]][doc] | ||
|
||
Rust library to retrieve system, kernel, and process metrics from the pseudo-filesystems /proc and /sys. | ||
|
||
See the docs for more information about supported features, or view the [features.md](https://github.com/navidys/procsys/blob/main/FEATURES.md) file of the project repository. | ||
|
||
## Examples | ||
|
||
There are several examples in the documents and also in the [examples](https://github.com/navidys/procsys/tree/main/examples) directory of project repository. | ||
|
||
|
||
``` | ||
use procsys::sysfs::class_watchdog; | ||
fn main() { | ||
let watchdog_devices = class_watchdog::collect(); | ||
for wdev in &watchdog_devices { | ||
println!("name: {}", wdev.name()); | ||
println!("boot status: {}", wdev.boot_status().unwrap_or_default()); | ||
println!("timeout: {}", wdev.timeout().unwrap_or_default()); | ||
println!("min_timeout: {}", wdev.min_timeout().unwrap_or_default()); | ||
println!("max_timeout: {}", wdev.max_timeout().unwrap_or_default()); | ||
} | ||
// print all watchdog devices information in json output | ||
match serde_json::to_string_pretty(&watchdog_devices) { | ||
Ok(output) => println!("{}", output), | ||
Err(err) => { | ||
log::error!("{}", err); | ||
std::process::exit(1); | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
Licensed under the [MIT License](https://github.com/navidys/procsys/blob/main/LICENSE). | ||
|
||
[img_crates]: https://img.shields.io/crates/v/procsys.svg | ||
[img_doc]: https://img.shields.io/badge/rust-documentation-blue.svg | ||
|
||
[crates]: https://crates.io/crates/procsys | ||
[doc]: https://docs.rs/procsys/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use procsys::sysfs; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let clocksources = sysfs::clocksource::collect(); | ||
|
||
for clock_src in &clocksources { | ||
println!("name: {}", clock_src.name()); | ||
println!( | ||
"available clocksource: {}", | ||
clock_src.available_clocksource().join(" "), | ||
); | ||
println!("current clocksource: {}", clock_src.current_clocksource()); | ||
} | ||
|
||
// print all clocksources information in json output | ||
match serde_json::to_string_pretty(&clocksources) { | ||
Ok(output) => println!("{}", output), | ||
Err(err) => { | ||
log::error!("{}", err); | ||
std::process::exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use procsys::sysfs; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let cooling_devices = sysfs::class_cooling::collect(); | ||
|
||
// print all cooling devices information in json output | ||
match serde_json::to_string_pretty(&cooling_devices) { | ||
Ok(output) => println!("{}", output), | ||
Err(err) => { | ||
log::error!("{}", err); | ||
std::process::exit(1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use procsys::sysfs; | ||
|
||
fn main() { | ||
env_logger::init(); | ||
|
||
let dmi_info = sysfs::class_dmi::collect(); | ||
|
||
println!( | ||
"bios date: {}", | ||
dmi_info.bios_date().to_owned().unwrap_or_default(), | ||
); | ||
|
||
println!( | ||
"bios release: {}", | ||
dmi_info.bios_release().to_owned().unwrap_or_default(), | ||
); | ||
|
||
// print all DMI information in json output | ||
match serde_json::to_string_pretty(&dmi_info) { | ||
Ok(output) => println!("{}", output), | ||
Err(err) => { | ||
log::error!("{}", err); | ||
std::process::exit(1); | ||
} | ||
} | ||
} |
Oops, something went wrong.