Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| aaec8e691c | |||
| 4a8cfbbde4 | |||
| d93260529b | |||
| 41e1be451e | |||
| 2863526ec8 | |||
| 5da9213da6 | |||
| a7755f02ae | |||
| b886fb2045 | |||
| cfb02e1763 | |||
| 5b53ca3d52 |
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.249"
|
version = "0.1.258"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -301,7 +301,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.249"
|
version = "0.1.258"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -325,7 +325,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.249"
|
version = "0.1.258"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-agent"
|
name = "cm-dashboard-agent"
|
||||||
version = "0.1.250"
|
version = "0.1.259"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -282,8 +282,8 @@ impl Collector for CpuCollector {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate status using thresholds
|
// Calculate status using thresholds (use 5-minute average for stability)
|
||||||
agent_data.system.cpu.load_status = self.calculate_load_status(agent_data.system.cpu.load_1min);
|
agent_data.system.cpu.load_status = self.calculate_load_status(agent_data.system.cpu.load_5min);
|
||||||
agent_data.system.cpu.temperature_status = if let Some(temp) = agent_data.system.cpu.temperature_celsius {
|
agent_data.system.cpu.temperature_status = if let Some(temp) = agent_data.system.cpu.temperature_celsius {
|
||||||
self.calculate_temperature_status(temp)
|
self.calculate_temperature_status(temp)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use cm_dashboard_shared::{AgentData, ServiceData, SubServiceData, SubServiceMetr
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tracing::debug;
|
use tracing::{debug, info};
|
||||||
|
|
||||||
use super::{Collector, CollectorError};
|
use super::{Collector, CollectorError};
|
||||||
use crate::config::SystemdConfig;
|
use crate::config::SystemdConfig;
|
||||||
@@ -154,7 +154,8 @@ impl SystemdCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if service_name == "openvpn-vpn-connection" && status_info.active_state == "active" {
|
if service_name == "openvpn-vpn-download" && status_info.active_state == "active" {
|
||||||
|
// Add VPN route
|
||||||
if let Some(external_ip) = self.get_vpn_external_ip() {
|
if let Some(external_ip) = self.get_vpn_external_ip() {
|
||||||
let metrics = Vec::new();
|
let metrics = Vec::new();
|
||||||
|
|
||||||
@@ -165,9 +166,8 @@ impl SystemdCollector {
|
|||||||
service_type: "vpn_route".to_string(),
|
service_type: "vpn_route".to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if service_name == "openvpn-vpn-download" && status_info.active_state == "active" {
|
// Add torrent stats
|
||||||
if let Some((active_count, download_mbps, upload_mbps)) = self.get_qbittorrent_stats() {
|
if let Some((active_count, download_mbps, upload_mbps)) = self.get_qbittorrent_stats() {
|
||||||
let metrics = Vec::new();
|
let metrics = Vec::new();
|
||||||
|
|
||||||
@@ -178,6 +178,18 @@ impl SystemdCollector {
|
|||||||
service_type: "torrent_stats".to_string(),
|
service_type: "torrent_stats".to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add active torrent copy status for each copy operation
|
||||||
|
for torrent_name in self.get_active_torrent_copies() {
|
||||||
|
let metrics = Vec::new();
|
||||||
|
|
||||||
|
sub_services.push(SubServiceData {
|
||||||
|
name: format!("Copy: {}", torrent_name),
|
||||||
|
service_status: Status::Info,
|
||||||
|
metrics,
|
||||||
|
service_type: "torrent_copy".to_string(),
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if service_name == "nftables" && status_info.active_state == "active" {
|
if service_name == "nftables" && status_info.active_state == "active" {
|
||||||
@@ -186,7 +198,7 @@ impl SystemdCollector {
|
|||||||
if !tcp_ports.is_empty() {
|
if !tcp_ports.is_empty() {
|
||||||
let metrics = Vec::new();
|
let metrics = Vec::new();
|
||||||
sub_services.push(SubServiceData {
|
sub_services.push(SubServiceData {
|
||||||
name: format!("TCP: {}", tcp_ports),
|
name: format!("wan tcp: {}", tcp_ports),
|
||||||
service_status: Status::Info,
|
service_status: Status::Info,
|
||||||
metrics,
|
metrics,
|
||||||
service_type: "firewall_port".to_string(),
|
service_type: "firewall_port".to_string(),
|
||||||
@@ -196,7 +208,7 @@ impl SystemdCollector {
|
|||||||
if !udp_ports.is_empty() {
|
if !udp_ports.is_empty() {
|
||||||
let metrics = Vec::new();
|
let metrics = Vec::new();
|
||||||
sub_services.push(SubServiceData {
|
sub_services.push(SubServiceData {
|
||||||
name: format!("UDP: {}", udp_ports),
|
name: format!("wan udp: {}", udp_ports),
|
||||||
service_status: Status::Info,
|
service_status: Status::Info,
|
||||||
metrics,
|
metrics,
|
||||||
service_type: "firewall_port".to_string(),
|
service_type: "firewall_port".to_string(),
|
||||||
@@ -914,14 +926,19 @@ impl SystemdCollector {
|
|||||||
/// Get nftables open ports grouped by protocol
|
/// Get nftables open ports grouped by protocol
|
||||||
/// Returns: (tcp_ports_string, udp_ports_string)
|
/// Returns: (tcp_ports_string, udp_ports_string)
|
||||||
fn get_nftables_open_ports(&self) -> (String, String) {
|
fn get_nftables_open_ports(&self) -> (String, String) {
|
||||||
let output = Command::new("timeout")
|
let output = Command::new("sudo")
|
||||||
.args(&["3", "sudo", "nft", "list", "ruleset"])
|
.args(&["/run/current-system/sw/bin/nft", "list", "ruleset"])
|
||||||
.output();
|
.output();
|
||||||
|
|
||||||
let output = match output {
|
let output = match output {
|
||||||
Ok(out) if out.status.success() => out,
|
Ok(out) if out.status.success() => out,
|
||||||
_ => {
|
Ok(out) => {
|
||||||
debug!("Failed to run nft list ruleset");
|
info!("nft command failed with status: {:?}, stderr: {}",
|
||||||
|
out.status, String::from_utf8_lossy(&out.stderr));
|
||||||
|
return (String::new(), String::new());
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
info!("Failed to execute nft command: {}", e);
|
||||||
return (String::new(), String::new());
|
return (String::new(), String::new());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -929,7 +946,7 @@ impl SystemdCollector {
|
|||||||
let output_str = match String::from_utf8(output.stdout) {
|
let output_str = match String::from_utf8(output.stdout) {
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
debug!("Failed to parse nft output as UTF-8");
|
info!("Failed to parse nft output as UTF-8");
|
||||||
return (String::new(), String::new());
|
return (String::new(), String::new());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -991,7 +1008,7 @@ impl SystemdCollector {
|
|||||||
let tcp_str = tcp_vec.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(", ");
|
let tcp_str = tcp_vec.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(", ");
|
||||||
let udp_str = udp_vec.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(", ");
|
let udp_str = udp_vec.iter().map(|p| p.to_string()).collect::<Vec<_>>().join(", ");
|
||||||
|
|
||||||
debug!("nftables WAN ports - TCP: '{}', UDP: '{}'", tcp_str, udp_str);
|
info!("nftables WAN ports - TCP: '{}', UDP: '{}'", tcp_str, udp_str);
|
||||||
|
|
||||||
(tcp_str, udp_str)
|
(tcp_str, udp_str)
|
||||||
}
|
}
|
||||||
@@ -1083,6 +1100,31 @@ impl SystemdCollector {
|
|||||||
|
|
||||||
Some((active_count, download_mbps, upload_mbps))
|
Some((active_count, download_mbps, upload_mbps))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check for active torrent copy operations
|
||||||
|
/// Returns: Vec of filenames currently being copied
|
||||||
|
fn get_active_torrent_copies(&self) -> Vec<String> {
|
||||||
|
let marker_dir = "/tmp/torrent-copy";
|
||||||
|
let mut active_copies = Vec::new();
|
||||||
|
|
||||||
|
// Read all marker files from directory
|
||||||
|
if let Ok(entries) = std::fs::read_dir(marker_dir) {
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
if let Ok(file_type) = entry.file_type() {
|
||||||
|
if file_type.is_file() {
|
||||||
|
// Filename is the marker (sanitized torrent name)
|
||||||
|
if let Some(filename) = entry.file_name().to_str() {
|
||||||
|
// Convert sanitized name back (replace _ with /)
|
||||||
|
let display_name = filename.replace('_', "/");
|
||||||
|
active_copies.push(display_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
active_copies
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard"
|
name = "cm-dashboard"
|
||||||
version = "0.1.250"
|
version = "0.1.259"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -556,7 +556,14 @@ impl TuiApp {
|
|||||||
));
|
));
|
||||||
|
|
||||||
if Some(host) == self.current_host.as_ref() {
|
if Some(host) == self.current_host.as_ref() {
|
||||||
// Selected host in bold background color against status background
|
// Selected host with brackets in bold background color against status background
|
||||||
|
host_spans.push(Span::styled(
|
||||||
|
"[",
|
||||||
|
Style::default()
|
||||||
|
.fg(Theme::background())
|
||||||
|
.bg(background_color)
|
||||||
|
.add_modifier(Modifier::BOLD),
|
||||||
|
));
|
||||||
host_spans.push(Span::styled(
|
host_spans.push(Span::styled(
|
||||||
host.clone(),
|
host.clone(),
|
||||||
Style::default()
|
Style::default()
|
||||||
@@ -564,6 +571,13 @@ impl TuiApp {
|
|||||||
.bg(background_color)
|
.bg(background_color)
|
||||||
.add_modifier(Modifier::BOLD),
|
.add_modifier(Modifier::BOLD),
|
||||||
));
|
));
|
||||||
|
host_spans.push(Span::styled(
|
||||||
|
"]",
|
||||||
|
Style::default()
|
||||||
|
.fg(Theme::background())
|
||||||
|
.bg(background_color)
|
||||||
|
.add_modifier(Modifier::BOLD),
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
// Other hosts in normal background color against status background
|
// Other hosts in normal background color against status background
|
||||||
host_spans.push(Span::styled(
|
host_spans.push(Span::styled(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "cm-dashboard-shared"
|
name = "cm-dashboard-shared"
|
||||||
version = "0.1.250"
|
version = "0.1.259"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
Reference in New Issue
Block a user