1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-01 06:46:55 +03:00

MCOL-1875 - fixed issue with calulating module cpu usage

This commit is contained in:
David Hill
2018-11-16 11:04:08 -06:00
parent fe80c01bc9
commit 668a61c389

View File

@ -556,7 +556,7 @@ void ServerMonitor::getCPUdata()
string tmpsystemCpu = tmpDir + "/processCpu";
cmd = "top -b -n 6 -d 1 | awk '{print $5}' | grep %id > " + tmpsystemCpu;
cmd = "top -b -n 6 -d 1 | grep '%Cpu' | awk '{print $8}' > " + tmpsystemCpu;
system(cmd.c_str());
ifstream oldFile (tmpsystemCpu.c_str());
@ -569,13 +569,17 @@ void ServerMonitor::getCPUdata()
while (oldFile.getline(line, 400))
{
string buf = line;
string::size_type pos = buf.find ('%', 0);
if (pos != string::npos)
string::size_type pos = buf.find ('id,', 0);
if (pos == string::npos)
{
systemIdle = systemIdle + atol(buf.substr(0, pos - 1).c_str());
count++;
}
else
{
systemIdle = systemIdle + 100;
count++;
}
}
oldFile.close();