fixed units
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 5s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 5s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m8s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 3m5s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m56s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m24s
Rust Cross-Platform Build / Create Tag (push) Successful in 6s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 1s
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 5s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 5s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m8s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 3m5s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m56s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m24s
Rust Cross-Platform Build / Create Tag (push) Successful in 6s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 1s
This commit is contained in:
@@ -62,7 +62,7 @@ pub async fn register_with_server(
|
|||||||
cpu_type: hardware.cpu.name.clone().unwrap_or_default(),
|
cpu_type: hardware.cpu.name.clone().unwrap_or_default(),
|
||||||
cpu_cores: (hardware.cpu.cores).unwrap_or_default(),
|
cpu_cores: (hardware.cpu.cores).unwrap_or_default(),
|
||||||
gpu_type: hardware.gpu.name.clone().unwrap_or_default(),
|
gpu_type: hardware.gpu.name.clone().unwrap_or_default(),
|
||||||
ram_size: hardware.memory.total.unwrap_or_default(),
|
ram_size: hardware.memory.total_size.unwrap_or_default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Try to register (will retry on failure)
|
// Try to register (will retry on failure)
|
||||||
|
@@ -8,7 +8,7 @@ use crate::docker::container::{get_available_container};
|
|||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
use bollard::query_parameters::{CreateImageOptions, RestartContainerOptions, InspectContainerOptions};
|
use bollard::query_parameters::{CreateImageOptions, RestartContainerOptions};
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
|
|
||||||
/// Handles a message from the backend server and dispatches the appropriate action.
|
/// Handles a message from the backend server and dispatches the appropriate action.
|
||||||
|
@@ -14,8 +14,8 @@ use std::error::Error;
|
|||||||
/// ## Units
|
/// ## Units
|
||||||
/// - `current_load`: GPU usage as a percentage (**0.0–100.0**)
|
/// - `current_load`: GPU usage as a percentage (**0.0–100.0**)
|
||||||
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
|
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
|
||||||
/// - `vram_total`: Total VRAM in **megabytes (MB)**
|
/// - `vram_total`: Total VRAM in **bytes**
|
||||||
/// - `vram_used`: Used VRAM in **megabytes (MB)**
|
/// - `vram_used`: Used VRAM in **bytes**
|
||||||
///
|
///
|
||||||
/// GPU statistics for the host system.
|
/// GPU statistics for the host system.
|
||||||
///
|
///
|
||||||
@@ -23,8 +23,8 @@ use std::error::Error;
|
|||||||
/// - `name`: GPU model name (string)
|
/// - `name`: GPU model name (string)
|
||||||
/// - `current_load`: GPU usage as a percentage (**0.0–100.0**)
|
/// - `current_load`: GPU usage as a percentage (**0.0–100.0**)
|
||||||
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
|
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
|
||||||
/// - `vram_total`: Total VRAM in **megabytes (MB)**
|
/// - `vram_total`: Total VRAM in **bytes**
|
||||||
/// - `vram_used`: Used VRAM in **megabytes (MB)**
|
/// - `vram_used`: Used VRAM in **bytes**
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GpuInfo {
|
pub struct GpuInfo {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
@@ -69,7 +69,7 @@ pub async fn get_gpu_info() -> Result<GpuInfo, Box<dyn Error + Send + Sync>> {
|
|||||||
/// Queries NVML for GPU metrics: temperature, load, VRAM used/total.
|
/// Queries NVML for GPU metrics: temperature, load, VRAM used/total.
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>>` - Tuple of (temperature °C, load %, VRAM used MB, VRAM total MB).
|
/// * `Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>>` - Tuple of (temperature °C, load %, VRAM used bytes, VRAM total bytes).
|
||||||
pub fn get_gpu_metrics() -> Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>> {
|
pub fn get_gpu_metrics() -> Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>> {
|
||||||
let nvml = Nvml::init();
|
let nvml = Nvml::init();
|
||||||
if let Ok(nvml) = nvml {
|
if let Ok(nvml) = nvml {
|
||||||
|
@@ -13,33 +13,35 @@ use sysinfo::System;
|
|||||||
/// - **Error Handling:** Graceful fallback if metrics are unavailable.
|
/// - **Error Handling:** Graceful fallback if metrics are unavailable.
|
||||||
///
|
///
|
||||||
/// ## Units
|
/// ## Units
|
||||||
/// - `total`, `used`, `free`: RAM in **megabytes (MB)**
|
/// - `total`, `used`, `free`: RAM in **bytes**
|
||||||
///
|
///
|
||||||
/// Memory statistics for the host system.
|
/// Memory statistics for the host system.
|
||||||
///
|
///
|
||||||
/// # Fields
|
/// # Fields
|
||||||
/// - `total`: Total RAM in **megabytes (MB)**
|
/// - `total`: Total RAM in **bytes**
|
||||||
/// - `used`: Used RAM in **megabytes (MB)**
|
/// - `used`: Used RAM in **bytes**
|
||||||
/// - `free`: Free RAM in **megabytes (MB)**
|
/// - `free`: Free RAM in **bytes**
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MemoryInfo {
|
pub struct MemoryInfo {
|
||||||
pub total: Option<f64>,
|
pub total_size: Option<f64>,
|
||||||
pub used: Option<f64>,
|
pub used: Option<f64>,
|
||||||
pub free: Option<f64>,
|
pub free: Option<f64>,
|
||||||
|
pub current_load: Option<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Collects memory information (total, used, free RAM).
|
/// Collects memory information (total, used, free RAM).
|
||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `Result<MemoryInfo>` - Memory statistics or error if unavailable.
|
/// * `Result<MemoryInfo>` - Memory statistics or error if unavailable.
|
||||||
pub async fn get_memory_info() -> Result<MemoryInfo> {
|
pub async fn get_memory_info() -> Result<MemoryInfo, Box<dyn Error + Send + Sync>> {
|
||||||
let mut sys = System::new();
|
let mut sys = System::new();
|
||||||
sys.refresh_memory();
|
sys.refresh_memory();
|
||||||
|
|
||||||
Ok(MemoryInfo {
|
Ok(MemoryInfo {
|
||||||
total: Some(sys.total_memory() as f64),
|
total_size: Some(sys.total_memory() as f64),
|
||||||
used: Some(sys.used_memory() as f64),
|
used: Some(sys.used_memory() as f64),
|
||||||
free: Some(sys.free_memory() as f64),
|
free: Some(sys.free_memory() as f64),
|
||||||
|
current_load: Some(get_memory_usage(&mut sys).unwrap() as f64)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ pub async fn get_memory_info() -> Result<MemoryInfo> {
|
|||||||
///
|
///
|
||||||
/// # Returns
|
/// # Returns
|
||||||
/// * `Result<f64, Box<dyn Error + Send + Sync>>` - Memory usage as percentage.
|
/// * `Result<f64, Box<dyn Error + Send + Sync>>` - Memory usage as percentage.
|
||||||
pub fn _get_memory_usage(sys: &mut System) -> Result<f64, Box<dyn Error + Send + Sync>> {
|
pub fn get_memory_usage(sys: &mut System) -> Result<f64, Box<dyn Error + Send + Sync>> {
|
||||||
sys.refresh_memory();
|
sys.refresh_memory();
|
||||||
Ok((sys.used_memory() as f64 / sys.total_memory() as f64) * 100.0)
|
Ok((sys.used_memory() as f64 / sys.total_memory() as f64) * 100.0)
|
||||||
}
|
}
|
||||||
|
@@ -105,9 +105,9 @@ impl Collector {
|
|||||||
gpu_load: hardware.gpu.current_load.unwrap_or_default(),
|
gpu_load: hardware.gpu.current_load.unwrap_or_default(),
|
||||||
gpu_temp: hardware.gpu.current_temp.unwrap_or_default(),
|
gpu_temp: hardware.gpu.current_temp.unwrap_or_default(),
|
||||||
gpu_vram_size: hardware.gpu.vram_total.unwrap_or_default(),
|
gpu_vram_size: hardware.gpu.vram_total.unwrap_or_default(),
|
||||||
gpu_vram_usage: hardware.gpu.vram_used.unwrap_or_default(),
|
gpu_vram_load: hardware.gpu.current_load.unwrap_or_default(),
|
||||||
ram_load: hardware.memory.used.unwrap_or_default(),
|
ram_load: hardware.memory.current_load.unwrap_or_default(),
|
||||||
ram_size: hardware.memory.total.unwrap_or_default(),
|
ram_size: hardware.memory.total_size.unwrap_or_default(),
|
||||||
disk_size: hardware.disk.total_size.unwrap_or_default(),
|
disk_size: hardware.disk.total_size.unwrap_or_default(),
|
||||||
disk_usage: hardware.disk.total_used.unwrap_or_default(),
|
disk_usage: hardware.disk.total_used.unwrap_or_default(),
|
||||||
disk_temp: 0.0, // not supported
|
disk_temp: 0.0, // not supported
|
||||||
|
@@ -47,12 +47,12 @@ pub struct RegistrationDto {
|
|||||||
/// - `cpu_temp`: CPU temperature in **degrees Celsius (°C)**
|
/// - `cpu_temp`: CPU temperature in **degrees Celsius (°C)**
|
||||||
/// - `gpu_load`: GPU usage as a percentage (**0.0–100.0**)
|
/// - `gpu_load`: GPU usage as a percentage (**0.0–100.0**)
|
||||||
/// - `gpu_temp`: GPU temperature in **degrees Celsius (°C)**
|
/// - `gpu_temp`: GPU temperature in **degrees Celsius (°C)**
|
||||||
/// - `gpu_vram_size`: Total GPU VRAM in **megabytes (MB)**
|
/// - `gpu_vram_size`: Total GPU VRAM in **bytes**
|
||||||
/// - `gpu_vram_usage`: Used GPU VRAM in **megabytes (MB)**
|
/// - `gpu_vram_load`: GPU Usage of VRAM as a percentage (**0.0–100.0**)
|
||||||
/// - `ram_load`: Used RAM in **megabytes (MB)**
|
/// - `ram_load`: RAM usage as a percentage (**0.0–100.0**)
|
||||||
/// - `ram_size`: Total RAM in **megabytes (MB)**
|
/// - `ram_size`: Total RAM in **bytes**
|
||||||
/// - `disk_size`: Total disk size in **megabytes (MB)**
|
/// - `disk_size`: Total disk size in **bytes**
|
||||||
/// - `disk_usage`: Used disk space in **megabytes (MB)**
|
/// - `disk_usage`: Used disk space in **bytes**
|
||||||
/// - `disk_temp`: Disk temperature in **degrees Celsius (°C)** (if available)
|
/// - `disk_temp`: Disk temperature in **degrees Celsius (°C)** (if available)
|
||||||
/// - `net_rx`: Network receive rate in **bytes per second (B/s)**
|
/// - `net_rx`: Network receive rate in **bytes per second (B/s)**
|
||||||
/// - `net_tx`: Network transmit rate in **bytes per second (B/s)**
|
/// - `net_tx`: Network transmit rate in **bytes per second (B/s)**
|
||||||
@@ -72,8 +72,8 @@ pub struct MetricDto {
|
|||||||
pub gpu_temp: f64,
|
pub gpu_temp: f64,
|
||||||
#[serde(rename = "gpu_Vram_Size")]
|
#[serde(rename = "gpu_Vram_Size")]
|
||||||
pub gpu_vram_size: f64,
|
pub gpu_vram_size: f64,
|
||||||
#[serde(rename = "gpu_Vram_Usage")]
|
#[serde(rename = "gpu_Vram_Load")]
|
||||||
pub gpu_vram_usage: f64,
|
pub gpu_vram_load: f64,
|
||||||
#[serde(rename = "ram_Load")]
|
#[serde(rename = "ram_Load")]
|
||||||
pub ram_load: f64,
|
pub ram_load: f64,
|
||||||
#[serde(rename = "ram_Size")]
|
#[serde(rename = "ram_Size")]
|
||||||
|
Reference in New Issue
Block a user