//! Resource utilization monitoring module

pub mod cpu;
pub mod io;
pub mod memory;
pub mod report;
pub mod rhai;
pub mod sample;
pub mod tests;
pub mod utilization;

pub use report::UtilizationReport;
pub use sample::UtilizationSample;

use std::time::{SystemTime, UNIX_EPOCH};

/// Sample all system resources at once
pub fn resource_monitor() -> UtilizationSample {
    let timestamp = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .unwrap_or_default()
        .as_millis()
        .to_string();

    let cpu_percent = cpu::sample_cpu_utilization() * 100.0; // Convert to percentage
    let (memory_percent, memory_used_bytes, memory_total_bytes) = memory::sample_memory_usage();
    let (io_wait_percent, io_queue_depth) = io::sample_io_statistics();

    UtilizationSample {
        timestamp,
        cpu_percent,
        memory_percent,
        memory_used_bytes,
        memory_total_bytes,
        io_wait_percent,
        io_queue_depth,
    }
}
