Skip to content
Snippets Groups Projects
Commit a5f071bb authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #3695: Log an error if CPU load on core 0 is critical

parent a517b948
No related branches found
No related tags found
No related merge requests found
......@@ -102,11 +102,23 @@ void LogThread::writeCPUstats(std::stringstream &str)
struct CPUload load;
struct timeval tv;
static size_t lowIdleCount = 0;
if (readCPUstats(load)) {
gettimeofday( &tv, 0 );
float timediff = (tv.tv_sec - previousTimeval.tv_sec) + (tv.tv_usec - previousTimeval.tv_usec)/1.0e6;
unsigned idle0 = static_cast<unsigned>((load.idle0 - previousLoad.idle0) / timediff);
if (idle0 < 10)
lowIdleCount++;
else
lowIdleCount = 0;
// TODO: Don't print this error in non-realtime mode
if (lowIdleCount == 5)
LOG_ERROR("CPU load critical on core 0");
//str << ", us/sy/in/id: ["
str << ", us/sy/in/id(0): ["
<< fixed << setprecision(0)
......@@ -114,7 +126,7 @@ void LogThread::writeCPUstats(std::stringstream &str)
<< (unsigned(load.system - previousLoad.system) + 2) / 4 / timediff << '/'
<< (unsigned(load.interrupt - previousLoad.interrupt) + 2) / 4 / timediff << '/'
<< (unsigned(load.idle - previousLoad.idle) + 2) / 4 / timediff << '('
<< (unsigned(load.idle0 - previousLoad.idle0) / timediff) << ")]";
<< idle0 << ")]";
#if 0
<< "], id: ["
<< (unsigned(load.idlePerCore[0] - previousLoad.idlePerCore[0]) << '/'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment