From da20ea0626533baed457f3844af18c98ba722501 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 9 Dec 2018 20:42:13 +0000 Subject: [PATCH] Figured out the issue, scanf starts from begining of a stream --- .vscode/settings.json | 8 +++++++- bin/resource-monitor | Bin 75124 -> 75124 bytes platform/linux/monitoring/cpu.cpp | 9 ++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b4d9aa0..76fdc80 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,6 +33,12 @@ "tuple": "cpp", "type_traits": "cpp", "typeinfo": "cpp", - "utility": "cpp" + "utility": "cpp", + "condition_variable": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "functional": "cpp", + "mutex": "cpp", + "sstream": "cpp" } } \ No newline at end of file diff --git a/bin/resource-monitor b/bin/resource-monitor index 05cf2bb7982c56efc4ff7233132c6e8cd386a604..4abee2642970e315f40fd148d5086a1f7b1c3560 100755 GIT binary patch delta 94 zcmexzisj2GmJKr)MUuKjt#`&5Uw`vzDfg3K51v;3jy2u9hH2cbEu@b3rliAslnulv1Xf(#jZOJ0EyWowg3PC diff --git a/platform/linux/monitoring/cpu.cpp b/platform/linux/monitoring/cpu.cpp index 5318a11..412a98b 100644 --- a/platform/linux/monitoring/cpu.cpp +++ b/platform/linux/monitoring/cpu.cpp @@ -57,13 +57,8 @@ void CPU::CPU_POLL(CPU* cpu) { unsigned long long tluser, tnice, tsystem, tidle, tiowait, tirq, tsoftirq = 0; FILE* ProcStatCPUThread = fopen("/proc/stat", "r"); - // char c = fgetc(ProcStatCPU); - // while (c != -1) { - // printf ("%c", c); - // c = fgetc(ProcStatCPU); - // } - fscanf(ProcStatCPUThread, "cpu0 %llu %llu %llu %llu %llu %llu %llu", - &tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq); + fscanf(ProcStatCPUThread, "%*s %llu %llu %llu %llu %llu %llu %llu", + &tluser, &tnice, &tsystem, &tidle, &tiowait, &tirq, &tsoftirq); // WONT WORK fclose(ProcStatCPUThread); std::cout << tluser << " " << tnice << " " << tsystem << " " << tidle