Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 748a9f3a3b | |||
| 5c6b11c794 | |||
| 9f0aa5f806 | |||
| fc247bd0ad |
@@ -304,6 +304,12 @@ exclude_fs_types = ["tmpfs", "devtmpfs", "sysfs", "proc"]
|
|||||||
### Display Format
|
### Display Format
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Network:
|
||||||
|
● eno1:
|
||||||
|
├─ ip: 192.168.30.105
|
||||||
|
└─ tailscale0: 100.125.108.16
|
||||||
|
● eno2:
|
||||||
|
└─ ip: 192.168.32.105
|
||||||
CPU:
|
CPU:
|
||||||
● Load: 0.23 0.21 0.13
|
● Load: 0.23 0.21 0.13
|
||||||
└─ Freq: 1048 MHz
|
└─ Freq: 1048 MHz
|
||||||
|
|||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -279,7 +279,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -324,7 +324,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use crate::collectors::{
|
|||||||
cpu::CpuCollector,
|
cpu::CpuCollector,
|
||||||
disk::DiskCollector,
|
disk::DiskCollector,
|
||||||
memory::MemoryCollector,
|
memory::MemoryCollector,
|
||||||
|
network::NetworkCollector,
|
||||||
nixos::NixOSCollector,
|
nixos::NixOSCollector,
|
||||||
systemd::SystemdCollector,
|
systemd::SystemdCollector,
|
||||||
};
|
};
|
||||||
@@ -77,7 +78,11 @@ impl Agent {
|
|||||||
if config.collectors.backup.enabled {
|
if config.collectors.backup.enabled {
|
||||||
collectors.push(Box::new(BackupCollector::new()));
|
collectors.push(Box::new(BackupCollector::new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.collectors.network.enabled {
|
||||||
|
collectors.push(Box::new(NetworkCollector::new(config.collectors.network.clone())));
|
||||||
|
}
|
||||||
|
|
||||||
if config.collectors.nixos.enabled {
|
if config.collectors.nixos.enabled {
|
||||||
collectors.push(Box::new(NixOSCollector::new(config.collectors.nixos.clone())));
|
collectors.push(Box::new(NixOSCollector::new(config.collectors.nixos.clone())));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ pub mod cpu;
|
|||||||
pub mod disk;
|
pub mod disk;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod memory;
|
pub mod memory;
|
||||||
|
pub mod network;
|
||||||
pub mod nixos;
|
pub mod nixos;
|
||||||
pub mod systemd;
|
pub mod systemd;
|
||||||
|
|
||||||
|
|||||||
143
agent/src/collectors/network.rs
Normal file
143
agent/src/collectors/network.rs
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
use async_trait::async_trait;
|
||||||
|
use cm_dashboard_shared::{AgentData, NetworkInterfaceData, Status};
|
||||||
|
use std::process::Command;
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
|
use super::{Collector, CollectorError};
|
||||||
|
use crate::config::NetworkConfig;
|
||||||
|
|
||||||
|
/// Network interface collector with physical/virtual classification and link status
|
||||||
|
pub struct NetworkCollector {
|
||||||
|
_config: NetworkConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NetworkCollector {
|
||||||
|
pub fn new(config: NetworkConfig) -> Self {
|
||||||
|
Self { _config: config }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if interface is physical (not virtual)
|
||||||
|
fn is_physical_interface(name: &str) -> bool {
|
||||||
|
// Physical interface patterns
|
||||||
|
matches!(
|
||||||
|
&name[..],
|
||||||
|
s if s.starts_with("eth")
|
||||||
|
|| s.starts_with("ens")
|
||||||
|
|| s.starts_with("enp")
|
||||||
|
|| s.starts_with("wlan")
|
||||||
|
|| s.starts_with("wlp")
|
||||||
|
|| s.starts_with("eno")
|
||||||
|
|| s.starts_with("enx")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get link status for an interface
|
||||||
|
fn get_link_status(interface: &str) -> Status {
|
||||||
|
let operstate_path = format!("/sys/class/net/{}/operstate", interface);
|
||||||
|
|
||||||
|
match std::fs::read_to_string(&operstate_path) {
|
||||||
|
Ok(state) => {
|
||||||
|
let state = state.trim();
|
||||||
|
match state {
|
||||||
|
"up" => Status::Ok,
|
||||||
|
"down" => Status::Inactive,
|
||||||
|
"unknown" => Status::Warning,
|
||||||
|
_ => Status::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(_) => Status::Unknown,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collect network interfaces using ip command
|
||||||
|
async fn collect_interfaces(&self) -> Vec<NetworkInterfaceData> {
|
||||||
|
let mut interfaces = Vec::new();
|
||||||
|
|
||||||
|
match Command::new("ip").args(["-j", "addr"]).output() {
|
||||||
|
Ok(output) if output.status.success() => {
|
||||||
|
let json_str = String::from_utf8_lossy(&output.stdout);
|
||||||
|
|
||||||
|
if let Ok(json_data) = serde_json::from_str::<serde_json::Value>(&json_str) {
|
||||||
|
if let Some(ifaces) = json_data.as_array() {
|
||||||
|
for iface in ifaces {
|
||||||
|
let name = iface["ifname"].as_str().unwrap_or("").to_string();
|
||||||
|
|
||||||
|
// Skip loopback and empty names
|
||||||
|
if name.is_empty() || name == "lo" {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut ipv4_addresses = Vec::new();
|
||||||
|
let mut ipv6_addresses = Vec::new();
|
||||||
|
|
||||||
|
// Extract IP addresses
|
||||||
|
if let Some(addr_info) = iface["addr_info"].as_array() {
|
||||||
|
for addr in addr_info {
|
||||||
|
if let Some(family) = addr["family"].as_str() {
|
||||||
|
if let Some(local) = addr["local"].as_str() {
|
||||||
|
match family {
|
||||||
|
"inet" => ipv4_addresses.push(local.to_string()),
|
||||||
|
"inet6" => {
|
||||||
|
// Skip link-local IPv6 addresses (fe80::)
|
||||||
|
if !local.starts_with("fe80:") {
|
||||||
|
ipv6_addresses.push(local.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only add interfaces that have at least one IP address
|
||||||
|
// This filters out ifb*, dummy interfaces, etc. that have no IPs
|
||||||
|
if ipv4_addresses.is_empty() && ipv6_addresses.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine if physical and get status
|
||||||
|
let is_physical = Self::is_physical_interface(&name);
|
||||||
|
let link_status = if is_physical {
|
||||||
|
Self::get_link_status(&name)
|
||||||
|
} else {
|
||||||
|
Status::Unknown // Virtual interfaces don't have meaningful link status
|
||||||
|
};
|
||||||
|
|
||||||
|
interfaces.push(NetworkInterfaceData {
|
||||||
|
name,
|
||||||
|
ipv4_addresses,
|
||||||
|
ipv6_addresses,
|
||||||
|
is_physical,
|
||||||
|
link_status,
|
||||||
|
parent_interface: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!("Failed to execute ip command: {}", e);
|
||||||
|
}
|
||||||
|
Ok(output) => {
|
||||||
|
debug!("ip command failed with status: {}", output.status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl Collector for NetworkCollector {
|
||||||
|
async fn collect_structured(&self, agent_data: &mut AgentData) -> Result<(), CollectorError> {
|
||||||
|
debug!("Collecting network interface data");
|
||||||
|
|
||||||
|
// Collect all network interfaces
|
||||||
|
let interfaces = self.collect_interfaces().await;
|
||||||
|
|
||||||
|
agent_data.system.network.interfaces = interfaces;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cm_dashboard_shared::{AgentData, NetworkInterfaceData};
|
use cm_dashboard_shared::AgentData;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
@@ -32,9 +32,6 @@ impl NixOSCollector {
|
|||||||
// Set NixOS build/generation information
|
// Set NixOS build/generation information
|
||||||
agent_data.build_version = self.get_nixos_generation().await;
|
agent_data.build_version = self.get_nixos_generation().await;
|
||||||
|
|
||||||
// Collect network interfaces
|
|
||||||
agent_data.system.network.interfaces = self.get_network_interfaces().await;
|
|
||||||
|
|
||||||
// Set current timestamp
|
// Set current timestamp
|
||||||
agent_data.timestamp = chrono::Utc::now().timestamp() as u64;
|
agent_data.timestamp = chrono::Utc::now().timestamp() as u64;
|
||||||
|
|
||||||
@@ -104,72 +101,6 @@ impl NixOSCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get network interfaces and their IP addresses
|
|
||||||
async fn get_network_interfaces(&self) -> Vec<NetworkInterfaceData> {
|
|
||||||
let mut interfaces = Vec::new();
|
|
||||||
|
|
||||||
// Use ip command with JSON output for easier parsing
|
|
||||||
match Command::new("ip").args(["-j", "addr"]).output() {
|
|
||||||
Ok(output) if output.status.success() => {
|
|
||||||
let json_str = String::from_utf8_lossy(&output.stdout);
|
|
||||||
|
|
||||||
// Parse JSON output
|
|
||||||
if let Ok(json_data) = serde_json::from_str::<serde_json::Value>(&json_str) {
|
|
||||||
if let Some(ifaces) = json_data.as_array() {
|
|
||||||
for iface in ifaces {
|
|
||||||
let name = iface["ifname"].as_str().unwrap_or("").to_string();
|
|
||||||
|
|
||||||
// Skip loopback and empty names
|
|
||||||
if name.is_empty() || name == "lo" {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut ipv4_addresses = Vec::new();
|
|
||||||
let mut ipv6_addresses = Vec::new();
|
|
||||||
|
|
||||||
// Extract IP addresses
|
|
||||||
if let Some(addr_info) = iface["addr_info"].as_array() {
|
|
||||||
for addr in addr_info {
|
|
||||||
if let Some(family) = addr["family"].as_str() {
|
|
||||||
if let Some(local) = addr["local"].as_str() {
|
|
||||||
match family {
|
|
||||||
"inet" => ipv4_addresses.push(local.to_string()),
|
|
||||||
"inet6" => {
|
|
||||||
// Skip link-local IPv6 addresses (fe80::)
|
|
||||||
if !local.starts_with("fe80:") {
|
|
||||||
ipv6_addresses.push(local.to_string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only add interfaces that have at least one IP address
|
|
||||||
if !ipv4_addresses.is_empty() || !ipv6_addresses.is_empty() {
|
|
||||||
interfaces.push(NetworkInterfaceData {
|
|
||||||
name,
|
|
||||||
ipv4_addresses,
|
|
||||||
ipv6_addresses,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
debug!("Failed to execute ip command: {}", e);
|
|
||||||
}
|
|
||||||
Ok(output) => {
|
|
||||||
debug!("ip command failed with status: {}", output.status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaces
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -616,7 +616,7 @@ impl SystemWidget {
|
|||||||
result.join(", ")
|
result.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Render network section for display
|
/// Render network section for display with physical/virtual grouping
|
||||||
fn render_network(&self) -> Vec<Line<'_>> {
|
fn render_network(&self) -> Vec<Line<'_>> {
|
||||||
let mut lines = Vec::new();
|
let mut lines = Vec::new();
|
||||||
|
|
||||||
@@ -624,25 +624,68 @@ impl SystemWidget {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, interface) in self.network_interfaces.iter().enumerate() {
|
// Separate physical and virtual interfaces
|
||||||
let is_last = i == self.network_interfaces.len() - 1;
|
let physical: Vec<_> = self.network_interfaces.iter().filter(|i| i.is_physical).collect();
|
||||||
|
let virtual_interfaces: Vec<_> = self.network_interfaces.iter().filter(|i| !i.is_physical).collect();
|
||||||
|
|
||||||
|
// Render physical interfaces
|
||||||
|
for (phy_idx, interface) in physical.iter().enumerate() {
|
||||||
|
let is_last_physical = phy_idx == physical.len() - 1 && virtual_interfaces.is_empty();
|
||||||
|
|
||||||
|
// Physical interface header with status icon
|
||||||
|
let mut header_spans = vec![];
|
||||||
|
header_spans.extend(StatusIcons::create_status_spans(
|
||||||
|
interface.link_status.clone(),
|
||||||
|
&format!("{}:", interface.name)
|
||||||
|
));
|
||||||
|
lines.push(Line::from(header_spans));
|
||||||
|
|
||||||
|
// Show IPs nested under the interface
|
||||||
|
let ip_count = interface.ipv4_addresses.len() + interface.ipv6_addresses.len();
|
||||||
|
let mut ip_index = 0;
|
||||||
|
|
||||||
|
// IPv4 addresses
|
||||||
|
for ipv4 in &interface.ipv4_addresses {
|
||||||
|
ip_index += 1;
|
||||||
|
let is_last_ip = ip_index == ip_count && is_last_physical;
|
||||||
|
let tree_symbol = if is_last_ip { " └─ " } else { " ├─ " };
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(format!("ip: {}", ipv4), Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPv6 addresses
|
||||||
|
for ipv6 in &interface.ipv6_addresses {
|
||||||
|
ip_index += 1;
|
||||||
|
let is_last_ip = ip_index == ip_count && is_last_physical;
|
||||||
|
let tree_symbol = if is_last_ip { " └─ " } else { " ├─ " };
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
|
Span::styled(format!("ip: {}", ipv6), Typography::secondary()),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render standalone virtual interfaces (those without a parent)
|
||||||
|
for (virt_idx, interface) in virtual_interfaces.iter().enumerate() {
|
||||||
|
let is_last = virt_idx == virtual_interfaces.len() - 1;
|
||||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
|
||||||
// Show interface name
|
// Virtual interface with IPs
|
||||||
let mut interface_text = format!("{}: ", interface.name);
|
let ip_text = if !interface.ipv4_addresses.is_empty() {
|
||||||
|
Self::compress_ipv4_addresses(&interface.ipv4_addresses)
|
||||||
|
} else if !interface.ipv6_addresses.is_empty() {
|
||||||
|
interface.ipv6_addresses.join(", ")
|
||||||
|
} else {
|
||||||
|
String::new()
|
||||||
|
};
|
||||||
|
|
||||||
// Add compressed IPv4 addresses
|
let interface_text = if !ip_text.is_empty() {
|
||||||
if !interface.ipv4_addresses.is_empty() {
|
format!("{}: {}", interface.name, ip_text)
|
||||||
interface_text.push_str(&Self::compress_ipv4_addresses(&interface.ipv4_addresses));
|
} else {
|
||||||
}
|
format!("{}:", interface.name)
|
||||||
|
};
|
||||||
// Add IPv6 addresses (no compression for now)
|
|
||||||
if !interface.ipv6_addresses.is_empty() {
|
|
||||||
if !interface.ipv4_addresses.is_empty() {
|
|
||||||
interface_text.push_str(", ");
|
|
||||||
}
|
|
||||||
interface_text.push_str(&interface.ipv6_addresses.join(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled(tree_symbol, Typography::tree()),
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
@@ -672,28 +715,18 @@ impl SystemWidget {
|
|||||||
Span::styled(format!("Agent: {}", agent_version_text), Typography::secondary())
|
Span::styled(format!("Agent: {}", agent_version_text), Typography::secondary())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// Network section
|
|
||||||
if !self.network_interfaces.is_empty() {
|
|
||||||
lines.push(Line::from(vec![
|
|
||||||
Span::styled("Network:", Typography::widget_title())
|
|
||||||
]));
|
|
||||||
|
|
||||||
let network_lines = self.render_network();
|
|
||||||
lines.extend(network_lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CPU section
|
// CPU section
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("CPU:", Typography::widget_title())
|
Span::styled("CPU:", Typography::widget_title())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let load_text = self.format_cpu_load();
|
let load_text = self.format_cpu_load();
|
||||||
let cpu_spans = StatusIcons::create_status_spans(
|
let cpu_spans = StatusIcons::create_status_spans(
|
||||||
self.cpu_status.clone(),
|
self.cpu_status.clone(),
|
||||||
&format!("Load: {}", load_text)
|
&format!("Load: {}", load_text)
|
||||||
);
|
);
|
||||||
lines.push(Line::from(cpu_spans));
|
lines.push(Line::from(cpu_spans));
|
||||||
|
|
||||||
let freq_text = self.format_cpu_frequency();
|
let freq_text = self.format_cpu_frequency();
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled(" └─ ", Typography::tree()),
|
Span::styled(" └─ ", Typography::tree()),
|
||||||
@@ -704,7 +737,7 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("RAM:", Typography::widget_title())
|
Span::styled("RAM:", Typography::widget_title())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
let memory_text = self.format_memory_usage();
|
let memory_text = self.format_memory_usage();
|
||||||
let memory_spans = StatusIcons::create_status_spans(
|
let memory_spans = StatusIcons::create_status_spans(
|
||||||
self.memory_status.clone(),
|
self.memory_status.clone(),
|
||||||
@@ -716,16 +749,16 @@ impl SystemWidget {
|
|||||||
for (i, tmpfs) in self.tmpfs_mounts.iter().enumerate() {
|
for (i, tmpfs) in self.tmpfs_mounts.iter().enumerate() {
|
||||||
let is_last = i == self.tmpfs_mounts.len() - 1;
|
let is_last = i == self.tmpfs_mounts.len() - 1;
|
||||||
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
let tree_symbol = if is_last { " └─ " } else { " ├─ " };
|
||||||
|
|
||||||
let usage_text = if tmpfs.total_gb > 0.0 {
|
let usage_text = if tmpfs.total_gb > 0.0 {
|
||||||
format!("{:.0}% {:.1}GB/{:.1}GB",
|
format!("{:.0}% {:.1}GB/{:.1}GB",
|
||||||
tmpfs.usage_percent,
|
tmpfs.usage_percent,
|
||||||
tmpfs.used_gb,
|
tmpfs.used_gb,
|
||||||
tmpfs.total_gb)
|
tmpfs.total_gb)
|
||||||
} else {
|
} else {
|
||||||
"— —/—".to_string()
|
"— —/—".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tmpfs_spans = vec![
|
let mut tmpfs_spans = vec![
|
||||||
Span::styled(tree_symbol, Typography::tree()),
|
Span::styled(tree_symbol, Typography::tree()),
|
||||||
];
|
];
|
||||||
@@ -736,6 +769,16 @@ impl SystemWidget {
|
|||||||
lines.push(Line::from(tmpfs_spans));
|
lines.push(Line::from(tmpfs_spans));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Network section
|
||||||
|
if !self.network_interfaces.is_empty() {
|
||||||
|
lines.push(Line::from(vec![
|
||||||
|
Span::styled("Network:", Typography::widget_title())
|
||||||
|
]));
|
||||||
|
|
||||||
|
let network_lines = self.render_network();
|
||||||
|
lines.extend(network_lines);
|
||||||
|
}
|
||||||
|
|
||||||
// Storage section
|
// Storage section
|
||||||
lines.push(Line::from(vec![
|
lines.push(Line::from(vec![
|
||||||
Span::styled("Storage:", Typography::widget_title())
|
Span::styled("Storage:", Typography::widget_title())
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.164"
|
version = "0.1.168"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ pub struct NetworkInterfaceData {
|
|||||||
pub name: String,
|
pub name: String,
|
||||||
pub ipv4_addresses: Vec<String>,
|
pub ipv4_addresses: Vec<String>,
|
||||||
pub ipv6_addresses: Vec<String>,
|
pub ipv6_addresses: Vec<String>,
|
||||||
|
pub is_physical: bool,
|
||||||
|
pub link_status: Status,
|
||||||
|
pub parent_interface: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CPU monitoring data
|
/// CPU monitoring data
|
||||||
|
|||||||
Reference in New Issue
Block a user