Skip to content

Commit

Permalink
Merge pull request #8 from baens/fix-for-parsing
Browse files Browse the repository at this point in the history
Fix parsing of the 2nd field of a pid stat field
  • Loading branch information
tobespc authored Sep 1, 2016
2 parents a1af779 + 538ee86 commit 6587a77
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ibmras/monitoring/plugins/common/cpu/cpuplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,17 @@ bool CpuPlugin::read_process_cpu_time(uint64* proctime, const uint32 NS_PER_HZ)
int32 dummyInt;
uint32 dummyUInt;
std::string dummyStr;
filestream >> dummyInt >> dummyStr >> dummyStr >> dummyInt >> dummyInt;
filestream >> dummyInt >> dummyStr;

// the second parameter in a /proc/<pid>/stat is a possible filename
// of the running process. This can pose a problem if the filename
// has a space (i.e. (Passenger NodeA)). This checks to read the stream
// until the end parenthese is found.
while(dummyStr.back() != ')') {
filestream >> dummyStr;
}

filestream >> dummyStr >> dummyInt >> dummyInt;
filestream >> dummyInt >> dummyInt >> dummyInt >> dummyUInt >> dummyUInt;
filestream >> dummyUInt >> dummyUInt >> dummyUInt;
filestream >> user >> kernel;
Expand Down

0 comments on commit 6587a77

Please sign in to comment.