25 unsigned long long int luser_mode_time = 0, lnice_time = 0, lsystem_time = 0,
26 lidle_time = 0, liowait_time = 0, lirq_time = 0,
27 lsoftirq_time = 0, lsteal_time = 0, lguest_time = 0,
30 aCPULine >> luser_mode_time;
31 aCPULine >> lnice_time;
32 aCPULine >> lsystem_time;
33 aCPULine >> lidle_time;
34 aCPULine >> liowait_time;
35 aCPULine >> lirq_time;
36 aCPULine >> lsoftirq_time;
37 aCPULine >> lsteal_time;
38 aCPULine >> lguest_time;
39 aCPULine >> lguest_nice_time;
42 luser_mode_time -= lguest_time;
43 lnice_time -= lguest_nice_time;
46 unsigned long long int lidle_all_time = 0, lsystem_all_time = 0,
47 lguest_all_time = 0, ltotal_time = 0;
49 lidle_all_time = lidle_time + liowait_time;
50 lsystem_all_time = lsystem_time + lirq_time + lsoftirq_time;
51 lguest_all_time = lguest_time + lguest_nice_time;
52 ltotal_time = luser_mode_time + lnice_time + lsystem_all_time +
53 lidle_all_time + lsteal_time + lguest_all_time;
106 vCPUData_[cpunb].ProcessLine(aCPULine);
113 aif.open(
"/proc/stat", std::ifstream::in);
116 while (std::getline(aif, aline)) {
118 std::istringstream anISSLine(aline);
119 std::string line_hdr;
120 anISSLine >> line_hdr;
123 std::size_t pos = line_hdr.find(
"cpu");
124 std::string str_cpunbr = line_hdr.substr(pos + 3);
127 if (pos == 0 and str_cpunbr.empty()) {
128 gCPUData_.ProcessLine(anISSLine);
129 gCPUData_.cpu_id_ = -1;
133 std::istringstream iss(str_cpunbr);
139 if (lcpunb > cpuNb_) cpuNb_ = lcpunb;
142 ProcessCPULine(lcpunb, anISSLine);
149 vCPUData_.resize(cpuNb_ + 1);
150 for (
unsigned long i = 0; i < (
unsigned long)cpuNb_; i++)
unsigned long long int idle_period_
Time spend in doing nothing.
unsigned long long int total_time_
Various classes of time spend by the CPUTotal time.
unsigned long long int user_mode_time_
Time spend in user mode.
unsigned long long int system_all_time_
Time spend in system mode.
unsigned long long int steal_time_
void ProcessCPULine(unsigned int cpunb, std::istringstream &aCPULine)
unsigned long long int guest_time_
unsigned long long int user_mode_period_
Time spend in user mode.
unsigned long long int softirq_period_
Time spend in servicing software interrupts.
void init()
Read /proc/state file to extract CPU count.
unsigned long long int system_time_
Time spend in system mode.
unsigned long long int idle_all_time_
Time spend in doing nothing.
void readProcStat()
Update CPU data information from /proc/stat.
unsigned long long int nice_time_
Time spend in user mode with low priority (nice mode)
unsigned long long int system_all_period_
Time spend in all system mode.
unsigned long long int guest_period_
unsigned long long int idle_all_period_
Time spend in doing nothing.
unsigned long long int iowait_period_
Time spend in waiting an input/output to complete.
unsigned long long int steal_period_
unsigned long long int softirq_time_
Time spend in servicing software interrupts.
unsigned long long int idle_time_
Time spend in doing nothing.
void ProcessLine(std::istringstream &aCPULine)
unsigned long long int nice_period_
Time spend in user mode with low priority (nice mode)
unsigned long long int irq_time_
Time spend in servicing hardware interrupts.
unsigned long long int iowait_time_
Time spend in waiting an input/output to complete.
unsigned long long int irq_period_
Time spend in servicing hardware interrupts.
unsigned long long int total_period_
Various classes of time spend by the CPU by periodTotal time.
unsigned long long int computePeriod(unsigned long long int &a, unsigned long long int &b)
unsigned long long int system_period_
Time spend in system mode.