diff --git a/CMakeLists.txt b/CMakeLists.txt index f44d22e..ea18669 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ if (WIN32) file(GLOB_RECURSE PlatformDepSource ${WinDep}/monitoring/*.cpp ${WinDep}/ui/*.cpp + ${WinDep}/*.cpp ) endif (WIN32) @@ -32,6 +33,7 @@ if (UNIX) file(GLOB_RECURSE PlatformDepSource ${LinuxDep}/monitoring/*.cpp ${LinuxDep}/ui/*.cpp + ${LinuxDep}/*.cpp ) endif (UNIX) diff --git a/SystemAPIDocs.md b/SystemAPIDocs.md new file mode 100644 index 0000000..0726e70 --- /dev/null +++ b/SystemAPIDocs.md @@ -0,0 +1,3 @@ +# Documentation + +> NOTE: Instantating the System class without prior initialization of CPU and Memory will cause a segmentation fault diff --git a/bin/bluelog-2018-12-12-1534.log b/bin/bluelog-2018-12-12-1534.log deleted file mode 100644 index e69de29..0000000 diff --git a/bin/core b/bin/core deleted file mode 100644 index d324344..0000000 Binary files a/bin/core and /dev/null differ diff --git a/bin/resource-monitor b/bin/resource-monitor index c17bfaf..a8327bd 100755 Binary files a/bin/resource-monitor and b/bin/resource-monitor differ diff --git a/include/common.h b/include/common.h index b5acde5..08c4c23 100644 --- a/include/common.h +++ b/include/common.h @@ -5,19 +5,4 @@ #include #include -std::vector execcommand(std::string command) { - char buffer[128]; - std::vector 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; -} - +std::vector execcommand(std::string command); diff --git a/include/sys.h b/include/sys.h index 07ec564..a00dc51 100644 --- a/include/sys.h +++ b/include/sys.h @@ -10,3 +10,14 @@ struct Sys { unsigned short CPU_CORES; }; + +class System { +public: + System(); + Sys* getSystemSpec(); + virtual ~System(); +private: + Sys* m_Sys; +}; + +static System* System_Instance; diff --git a/platform/linux/common.cpp b/platform/linux/common.cpp index 280d919..b6338f2 100644 --- a/platform/linux/common.cpp +++ b/platform/linux/common.cpp @@ -1,22 +1,22 @@ -// #include +#include -// #include -// #include -// #include -// #include +#include +#include +#include +#include -// std::vector exec(std::string command) { -// char buffer[128]; -// std::vector 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; -// } +std::vector execcommand(std::string command) { + char buffer[128]; + std::vector 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; +} diff --git a/platform/linux/monitoring/system.cpp b/platform/linux/monitoring/system.cpp new file mode 100644 index 0000000..0e3cd6a --- /dev/null +++ b/platform/linux/monitoring/system.cpp @@ -0,0 +1,23 @@ +#include + +System::System() { + this->m_Sys = new Sys(); + + if (CPU_Instance = NULL) { + CPU_Instance = new CPU(); + } + + if (Memory_Instance == NULL) { + Memory_Instance = new Memory(); + } + + +} + +Sys* System::getSystemSpec() { + return m_Sys; +} + +System::~System() { + +} diff --git a/src/main.cpp b/src/main.cpp index 4258ba9..49809b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,26 +1,27 @@ #include -#include -#include #include #include int main(int argc, char** argv) { - CPU* cpu = new CPU(); - CPU_Instance = cpu; + CPU_Instance = new CPU(); + Memory_Instance = new Memory(); + System_Instance = new System(); - Memory* mem = new Memory(); - Memory_Instance = mem; + CPU_Instance->START_CPU_POLLING(); + Memory_Instance->START_MEMORY_POLLING(); - cpu->START_CPU_POLLING(); - mem->START_MEMORY_POLLING(); + sleep(1); + + std::cout << std::endl; + Sys* sys = System_Instance->getSystemSpec(); while(1) { sleep(1); std::cout << std::endl; - for (unsigned int thread = 0; thread <= cpu->CPU_HARDWARE_THREADS; thread++) { - std::cout << "CORE " << thread << " USAGE: " << cpu->CPU_PERCENT(thread) << std::endl; + for (unsigned int thread = 0; thread <= CPU_Instance->CPU_HARDWARE_THREADS; thread++) { + std::cout << "CORE " << thread << " USAGE: " << CPU_Instance->CPU_PERCENT(thread) << std::endl; } - std::cout << "CPU FREQUENCY: " << cpu->cpuStat->FREQ << "MHz" << std::endl; + std::cout << "CPU FREQUENCY: " << CPU_Instance->cpuStat->FREQ << "MHz" << std::endl; } }