#ifndef CPU_MONITOR_H #define CPU_MONITOR_H #include #include #include struct CpuStats { double totalUsagePercent; // Overall CPU usage (0-100%) std::vector coreUsagePercent; // Per-core usage }; class CpuMonitor { public: explicit CpuMonitor(); // Get overall CPU usage and per-core usage CpuStats getCpuUsage(); private: struct CpuTick { int64_t user; int64_t nice; int64_t system; int64_t idle; int64_t iowait; int64_t irq; int64_t softirq; }; struct CpuCoreState { CpuTick previous; CpuTick current; bool initialized; }; std::vector coreStates; // Index 0 is aggregate, 1+ are cores std::vector readCpuStats(); double calculateUsagePercent(const CpuTick &prev, const CpuTick &curr); int getNumberOfCores(); }; #endif // CPU_MONITOR_H