29 unsigned system_,
unsigned nice_,
unsigned idle_,
unsigned iowait_,
30 unsigned irq_,
unsigned softirq_,
unsigned steal_,
unsigned guest_)
31 : duration(duration_), user(user_), system(system_), nice(nice_), idle(idle_),
32 iowait(iowait_), irq(irq_), softirq(softirq_), steal(steal_), guest(guest_)
38 std::ifstream statfd (
"/proc/stat");
45 if (prefix.compare(
"cpu") != 0)
49 boost::long_long_type x;
50 for (
unsigned i=0; statfd.good() && statfd >> x; ++i) {
51 current.push_back( x);
60 boost::long_long_type
sum = 0;
61 CpuStatProbs::iterator c = current.begin();
62 CpuStatProbs::iterator p = probs.begin();
63 for (; c != current.end() && p != probs.end(); ++c, ++p) {
73 100 * (current[0] - probs[0]) / sum,
74 100 * (current[1] - probs[1]) / sum,
75 100 * (current[2] - probs[2]) / sum,
76 100 * (current[3] - probs[3]) / sum,
77 100 * (current[4] - probs[4]) / sum,
78 100 * (current[5] - probs[5]) / sum,
79 100 * (current[6] - probs[6]) / sum,
80 100 * (current[7] - probs[7]) / sum,
81 100 * (current[8] - probs[8]) / sum);
94 .doc(
"Returns the CPU usage based on /proc/stat since last call of this function");
99 os << procStats_.cpuStat();
105 boost::format fmtStat (
"user=%3.0d%% sys=%3.0d%% nice=%3.0d%% idle=%3.0d%% io=%3.0d%% irq=%3.0d%% sirq=%3.0d%% steal=%3.0d%% guest=%3.0d%% duration=%dms ");
config::time_type clock_type
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_milliseconds(clock_type const &v)
static SENF_CLOCKSERVICE_CONSTEXPR clock_type seconds(int64_type const &v)
ClockService::clock_type const & now()
void dump(std::ostream &os)
std::ostream & operator<<(std::ostream &os, CpuStat const &cs)
CpuStat(ClockService::clock_type duration=ClockService::milliseconds(0), unsigned user=0, unsigned system=0, unsigned nice=0, unsigned idle=0, unsigned iowait=0, unsigned irq=0, unsigned softirq=0, unsigned steal=0, unsigned guest=0)
ClockService::clock_type duration