diff --git a/RTCP/IONProc/src/LogThread.cc b/RTCP/IONProc/src/LogThread.cc index 4b3a123f33b7a6b2e5f40e1f5bc2758e9ddd9308..ccf585bbec17a030d7f0a816cf0bc36e32fc9d93 100644 --- a/RTCP/IONProc/src/LogThread.cc +++ b/RTCP/IONProc/src/LogThread.cc @@ -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]) << '/'