src/linux_parser.cpp
// Read and return CPU utilization in a vector<strings> with all 10 values
Read and return CPU utilization in a vector with all 10 values
Read and return CPU utilization in a vector with all 10 values
vector<string> LinuxParser::CpuUtilization() { 
  vector<string> cpu_values;
  string line, label, value;
  std::ifstream stream(kProcDirectory + kStatFilename);
  if (stream.is_open()) {
    std::getline(stream, line);
    std::istringstream linestream(line);
    linestream >> label;
    while (linestream) {
      linestream >> value;
      cpu_values.push_back(value);
    }
  }
  return cpu_values; 
}
vector < string > LinuxParser :: CpuUtilization ( ) { vector < string > cpu_values ; string line , label , value ; std :: ifstream stream ( kProcDirectory + kStatFilename ) ; if ( stream . is_open ( ) ) { std :: getline ( stream , line ) ; std :: istringstream linestream ( line ) ; linestream >> label ; while ( linestream ) { linestream >> value ; cpu_values . push_back ( value ) ; } } return cpu_values ; }
Read and return CPU utilization in a vector<strings> with all 10 values
Read and return CPU utilization in a vector<strings > with all 10 values