use std::collections::{BTreeMap, VecDeque}; use std::time::{Duration, Instant}; use telemetry::frame::{Frame, StreamId}; use telemetry::hardware::cpu::{ CpuCoreSample, CpuHostSample, CpuProcessSample, HOST_CPU_CHANNEL, HostCpuSample, }; use telemetry::hardware::gpu::{ GpuDeviceSample, GpuProcessSample, HOST_GPU_CHANNEL, HostGpuSample, }; use telemetry::hardware::net::{HOST_NET_CHANNEL, HostNetSample, NetInterfaceSample}; use telemetry::Record; use parking_lot::RwLock; use serde::Serialize; use serde_json::{Value, json}; use crate::view::DashboardView; use crate::{FrameEvent, StreamEvent}; const HARDWARE_HTML: &str = include_str!("hardware_page.html"); const CHANNELS: &[&str] = &[]; const HISTORY_CAP: usize = 300; const HISTORY_MIN_INTERVAL: Duration = Duration::from_millis(900); const LIVE_TTL: Duration = Duration::from_secs(5); #[derive(Default)] pub struct HardwareDashboardView { state: RwLock, } #[derive(Default)] struct HardwareDashboardState { nodes: BTreeMap, } struct NodeHardwareState { stream: StreamEvent, last_seen: Instant, decode_errors: BTreeMap<&'static str, String>, cpu: Option, gpu: Option, net: Option, process: Option, history: VecDeque, } /// Managed-process state folded from `proc.