refactor: rename sysinfo tool to aster-sysinfo (#16)
The sysinfo name was too generic and misleading. This tool provides sensor values from the system for `asterctl` and is not a generic system information tool.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "sysinfo"
|
||||
version = "0.1.0"
|
||||
name = "aster-sysinfo"
|
||||
version = "0.2.0"
|
||||
description = "System sensor provider for asterctl"
|
||||
|
||||
rust-version.workspace = true
|
||||
@@ -37,11 +37,11 @@ Options:
|
||||
|
||||
Single test run with printing all sensors in the console:
|
||||
```shell
|
||||
sysinfo --console
|
||||
aster-sysinfo --console
|
||||
```
|
||||
|
||||
Normal mode providing sensor values for `asterctl` in `/tmp/sensors/sysinfo.txt` every 3 seconds:
|
||||
|
||||
```shell
|
||||
sysinfo --refresh 3 --out /tmp/sensors/sysinfo.txt
|
||||
aster-sysinfo --refresh 3 --out /tmp/sensors/aster-sysinfo.txt
|
||||
```
|
||||
@@ -20,7 +20,7 @@ use std::process::{Command, exit};
|
||||
use std::thread::sleep;
|
||||
use std::time::{Duration, Instant};
|
||||
use sysinfo::{Components, DiskKind, Disks, Networks, System};
|
||||
use tempfile::{Builder, NamedTempFile};
|
||||
use tempfile::Builder;
|
||||
|
||||
/// Proof of concept sensor value collection for the asterctl screen control tool.
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -66,7 +66,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let use_smartctl = false;
|
||||
|
||||
if let Some(out_file) = &args.out && let Some(parent) = out_file.parent() {
|
||||
if let Some(out_file) = &args.out
|
||||
&& let Some(parent) = out_file.parent()
|
||||
{
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
let mut sensors = HashMap::with_capacity(64);
|
||||
@@ -81,7 +83,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
|
||||
if !refresh.is_zero() {
|
||||
info!("Starting sysinfo with refresh={}ms", refresh.as_millis());
|
||||
info!(
|
||||
"Starting aster-sysinfo with refresh={}ms",
|
||||
refresh.as_millis()
|
||||
);
|
||||
}
|
||||
|
||||
loop {
|
||||
@@ -91,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
sysinfo_source.update_sensors(&mut sensors)?;
|
||||
|
||||
if !disk_refresh.is_zero() && disk_refresh_time.elapsed() > disk_refresh {
|
||||
info!("Refreshing individual disks");
|
||||
debug!("Refreshing individual disks");
|
||||
update_linux_storage_sensors(&mut sensors, use_smartctl)?;
|
||||
disk_refresh_time = Instant::now();
|
||||
}
|
||||
@@ -137,7 +142,9 @@ fn write_sensor_file(
|
||||
fs::create_dir_all(temp_path)?;
|
||||
|
||||
debug!("Creating a new named temp file in {temp_path:?}");
|
||||
Builder::new().permissions(all_read_perm).tempfile_in(temp_path)?
|
||||
Builder::new()
|
||||
.permissions(all_read_perm)
|
||||
.tempfile_in(temp_path)?
|
||||
} else {
|
||||
debug!("Creating a new named temp file");
|
||||
Builder::new().permissions(all_read_perm).tempfile()?
|
||||
@@ -187,6 +194,7 @@ impl SysinfoSource {
|
||||
|
||||
pub fn refresh(&mut self) {
|
||||
self.sys.refresh_all();
|
||||
debug!("Refreshing disks, components, networks");
|
||||
// TODO research "remove_not_listed_###" refresh parameter
|
||||
self.disks.refresh(false);
|
||||
self.components.refresh(false);
|
||||
@@ -202,6 +210,7 @@ impl SysinfoSource {
|
||||
&self,
|
||||
sensors: &mut HashMap<String, String>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
debug!("Refreshing sensors");
|
||||
for cpu in self.sys.cpus() {
|
||||
add_sensor(
|
||||
sensors,
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "asterctl-lcd"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "AOOSTAR WTR MAX / GEM12+ PRO screen protocol"
|
||||
|
||||
rust-version.workspace = true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "asterctl"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = "AOOSTAR WTR MAX Screen Control tool"
|
||||
readme = "../../README.md"
|
||||
|
||||
@@ -11,7 +11,7 @@ license.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
asterctl-lcd = { path = "../asterctl-lcd", version = "0.1.0" }
|
||||
asterctl-lcd = { path = "../asterctl-lcd", version = "0.2.0" }
|
||||
|
||||
anyhow = "1.0.98"
|
||||
clap = { version = "4.5.42", features = ["derive"] }
|
||||
|
||||
Reference in New Issue
Block a user