mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-10-28 08:20:49 +08:00
关于页展示宿主系统、处理器、架构、内核和资源占用,合并同一文件系统上的系统与 MSD 容量。 新增 Linux 宿主机重启和关机接口,在其他设置中提供二次确认、请求互斥及失败提示。 修正 Linux 磁盘已用空间计算,并补充设备信息和电源控制的后端单元测试。 验证:独立暂存快照前端构建通过;6 项后端测试通过;设置页保存、系统信息及模拟电源控制浏览器测试通过。
51 lines
986 B
Rust
51 lines
986 B
Rust
//! Host diagnostics used by the web status API.
|
|
|
|
use serde::Serialize;
|
|
|
|
use crate::error::Result;
|
|
|
|
mod host;
|
|
pub use host::{get_host_info, HostInfo};
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct DeviceInfo {
|
|
pub hostname: String,
|
|
pub cpu_model: String,
|
|
pub cpu_usage: f32,
|
|
pub memory_total: u64,
|
|
pub memory_used: u64,
|
|
pub network_addresses: Vec<NetworkAddress>,
|
|
pub serial_ports: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct NetworkAddress {
|
|
pub interface: String,
|
|
pub ip: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct DiskSpaceInfo {
|
|
pub total: u64,
|
|
pub available: u64,
|
|
pub used: u64,
|
|
}
|
|
|
|
#[cfg(unix)]
|
|
mod linux;
|
|
#[cfg(windows)]
|
|
mod windows;
|
|
|
|
#[cfg(unix)]
|
|
use linux as platform;
|
|
#[cfg(windows)]
|
|
use windows as platform;
|
|
|
|
pub fn get_disk_space(path: &std::path::Path) -> Result<DiskSpaceInfo> {
|
|
platform::get_disk_space(path)
|
|
}
|
|
|
|
pub fn get_device_info() -> DeviceInfo {
|
|
platform::get_device_info()
|
|
}
|