15 #include <unordered_map>
26 explicit cpuLoad(std::string procFileName =
"/proc/stat"):
27 procFile(
std::move(procFileName)), cpuName(
"") {};
43 std::tuple<uint64_t , uint64_t, uint64_t, uint64_t>
getCpuTimes() {
44 auto cpuLoad_ = this->parseStatFile(this->procFile);
45 return std::make_tuple(cpuLoad_.at(
"cpu").at(
"user"),
46 cpuLoad_.at(
"cpu").at(
"nice"),
47 cpuLoad_.at(
"cpu").at(
"system"),
48 cpuLoad_.at(
"cpu").at(
"idle"));
61 std::string
getCPUName(
const std::string& cpuNameFile =
"/proc/cpuinfo");
64 void calculateCpuUsage();
65 std::map<std::string, std::unordered_map<std::string, uint64_t>> parseStatFile(
const std::string& fileName);
66 void upDateCPUUsage();
67 std::chrono::system_clock::time_point currentTime;
70 std::map<std::string, double> cpuUsage;
71 std::map<std::string, std::unordered_map<std::string, uint64_t>> cpuLoadMap;
72 std::map<std::string, std::unordered_map<std::string, uint64_t>> oldCpuLoadMap;