gonna redo CPUinfo class with workers and structs, started that
This commit is contained in:
Binary file not shown.
22
include/common.h
Normal file
22
include/common.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
std::vector<std::string> exec(std::string command) {
|
||||
char buffer[128];
|
||||
std::vector<std::string> result;
|
||||
FILE* pipe = popen(command.c_str(), "r");
|
||||
try {
|
||||
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
|
||||
result.push_back(buffer);
|
||||
}
|
||||
} catch (...) {
|
||||
pclose(pipe);
|
||||
throw;
|
||||
}
|
||||
pclose(pipe);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <cpu.h>
|
||||
#include <temp.h>
|
||||
#include <gpu.h>
|
||||
#include <memstat.h>
|
||||
|
||||
struct Sys {
|
||||
unsigned long long SYSTEM_UPTIME;
|
||||
unsigned short CPU_CORES;
|
||||
|
||||
};
|
||||
|
||||
2
include/temp.h
Normal file
2
include/temp.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
|
||||
22
platform/linux/common.cpp
Normal file
22
platform/linux/common.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// #include <common.h>
|
||||
|
||||
// #include <iostream>
|
||||
// #include <stdexcept>
|
||||
// #include <stdio.h>
|
||||
// #include <string>
|
||||
|
||||
// std::vector<std::string> exec(std::string command) {
|
||||
// char buffer[128];
|
||||
// std::vector<std::string> result;
|
||||
// FILE* pipe = popen(command.c_str(), "r");
|
||||
// try {
|
||||
// while (fgets(buffer, sizeof buffer, pipe) != NULL) {
|
||||
// result.push_back(buffer);
|
||||
// }
|
||||
// } catch (...) {
|
||||
// pclose(pipe);
|
||||
// throw;
|
||||
// }
|
||||
// pclose(pipe);
|
||||
// return result;
|
||||
// }
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <cpu.h>
|
||||
#include <memstat.h>
|
||||
#include <sys.h>
|
||||
#include <common.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
@@ -14,6 +14,11 @@ int main(int argc, char** argv) {
|
||||
cpu->START_CPU_POLLING();
|
||||
mem->START_MEMORY_POLLING();
|
||||
|
||||
std::vector<std::string> lscpu = exec("lscpu");
|
||||
for (unsigned int i = 0; i < lscpu.size(); i++) {
|
||||
std::cout << lscpu[i] << std::endl;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
sleep(1);
|
||||
std::cout << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user