30 lines
611 B
C++
30 lines
611 B
C++
#include "utilization.hpp"
|
|
|
|
#include <thread>
|
|
#include "log.hpp"
|
|
|
|
namespace rims {
|
|
|
|
void mythread_analyzer_cb(struct thread_analyzer_info *info) {
|
|
ULOG_DEBUG(
|
|
"thread name, memfree, cpu : %s, %d, %d",
|
|
info->name,
|
|
info->stack_size - info->stack_used,
|
|
info->utilization // cpu usage in %
|
|
);
|
|
}
|
|
|
|
void ThreadAnalyzer::loop() {
|
|
while (true) {
|
|
std::this_thread::sleep_for(std::chrono::seconds{5});
|
|
thread_analyzer_run(mythread_analyzer_cb, 0);
|
|
}
|
|
}
|
|
|
|
void ThreadAnalyzerThread::threadMain() {
|
|
ThreadAnalyzer ta;
|
|
ta.loop();
|
|
}
|
|
|
|
} // namespace rims
|