{status}
"## )) }
fn format_uptime(seconds: u64) -> String {
let days = seconds / 86400;
let hours = (seconds % 86400) / 3600;
let minutes = (seconds % 3600) / 60;
if days > 0 {
format!("{}d {}h {}m", days, hours, minutes)
} else if hours > 0 {
format!("{}h {}m", hours, minutes)
} else {
format!("{}m", minutes)
}
}
fn check_postgres() -> bool {
true
}
fn check_redis() -> bool {
true
}
fn check_minio() -> bool {
true
}
fn check_llm() -> bool {
true
}
async fn timestamp(State(_state): State
>) -> Html {
let now = Local::now();
Html(format!("Last updated: {}", now.format("%H:%M:%S")))
}
async fn bots(State(state): State>) -> Html {
let active_sessions = state
.session_manager
.try_lock()
.map(|sm| sm.active_count())
.unwrap_or(0);
Html(format!(
r##"
Active Sessions
{active_sessions}
"## )) }
async fn services_status(State(_state): State>) -> Html {
let services = vec![
("postgresql", check_postgres()),
("redis", check_redis()),
("minio", check_minio()),
("llm", check_llm()),
];
let mut status_updates = String::new();
for (name, running) in services {
let status = if running { "running" } else { "stopped" };
status_updates.push_str(&format!(
r##""##
));
}
Html(status_updates)
}
async fn resources_bars(State(_state): State>) -> Html {
#[cfg(feature = "monitoring")]
let (cpu_usage, memory_percent) = {
let mut sys = System::new_all();
sys.refresh_all();
let cpu_usage = sys.global_cpu_usage();
let total_memory = sys.total_memory();
let used_memory = sys.used_memory();
let memory_percent = if total_memory > 0 {
(used_memory as f64 / total_memory as f64) * 100.0
} else {
0.0
};
(cpu_usage, memory_percent)
};
#[cfg(not(feature = "monitoring"))]
let (cpu_usage, memory_percent): (f32, f32) = (0.0, 0.0);
Html(format!(
r##"
CPU
{cpu_usage:.0}%
MEM {memory_percent:.0}% "##, cpu_width = cpu_usage.min(100.0f32), mem_width = memory_percent.min(100.0f32), )) }
async fn activity_latest(State(_state): State>) -> Html {
Html("System monitoring active...".to_string())
}
async fn metric_sessions(State(state): State>) -> Html {
let active_sessions = state
.session_manager
.try_lock()
.map(|sm| sm.active_count())
.unwrap_or(0);
Html(active_sessions.to_string())
}
async fn metric_messages(State(_state): State>) -> Html {
Html("--".to_string())
}
async fn metric_response_time(State(_state): State>) -> Html {
Html("--".to_string())
}
async fn trend_sessions(State(_state): State>) -> Html {
Html("↑ 0%".to_string())
}
async fn rate_messages(State(_state): State>) -> Html {
Html("0/hr".to_string())
}
async fn sessions_panel(State(state): State>) -> Html {
let active_sessions = state
.session_manager
.try_lock()
.map(|sm| sm.active_count())
.unwrap_or(0);
Html(format!(
r##""## )) }
async fn messages_panel(State(_state): State>) -> Html {
Html(
r##""## .to_string(), ) }