|
|
|
@ -27,6 +27,28 @@ int num;
|
|
|
|
|
bool loggingOn;
|
|
|
|
|
uint64_t log_start, log_end;
|
|
|
|
|
|
|
|
|
|
string exec(string command) {
|
|
|
|
|
char buffer[128];
|
|
|
|
|
string result = "";
|
|
|
|
|
|
|
|
|
|
// Open pipe to file
|
|
|
|
|
FILE* pipe = popen(command.c_str(), "r");
|
|
|
|
|
if (!pipe) {
|
|
|
|
|
return "popen failed!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// read till end of process:
|
|
|
|
|
while (!feof(pipe)) {
|
|
|
|
|
|
|
|
|
|
// use buffer to read and add to result
|
|
|
|
|
if (fgets(buffer, 128, pipe) != NULL)
|
|
|
|
|
result += buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pclose(pipe);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void writeFile(string filename){
|
|
|
|
|
out.open(filename, ios::out | ios::app);
|
|
|
|
|
out << "os," << "cpu," << "gpu," << "ram," << "kernel," << "driver" << endl;
|
|
|
|
|