NAC_Blockchain/nac-monitor/src/dashboard/mod.rs

31 lines
1.1 KiB
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use crate::metrics::NodeMetrics;
use crate::alerts::{Alert, AlertLevel};
pub struct Dashboard;
impl Dashboard {
pub fn display(metrics: &NodeMetrics, alerts: &[Alert]) {
println!("\n╔════════════════════════════════════════╗");
println!("║ NAC节点监控仪表板 ║");
println!("╚════════════════════════════════════════╝\n");
metrics.display();
if !alerts.is_empty() {
println!("\n⚠️ 告警信息:");
for alert in alerts {
let level_str = match alert.level {
AlertLevel::Info => " INFO",
AlertLevel::Warning => "⚠️ WARN",
AlertLevel::Critical => "🚨 CRIT",
};
println!(" {} {}", level_str, alert.message);
}
} else {
println!("\n✅ 无告警");
}
println!();
}
}