lm::LoadMonitor::ProcessorStats::OneCpuStats Class Reference

Data read from /proc/stat for on CPU. More...


Public Member Functions

 OneCpuStats (void)
 Empty default ctor.
 OneCpuStats (const std::string &line)
 Parse line from the file.
OneCpuStats operator- (const OneCpuStats &b) const
 Subtract corresponding values from two caches.
long long Sum (void) const
 Sum values in this cache.

Data Fields

std::vector< long long > stat_cache
 Data from file.

Static Public Attributes

static const size_t CPU_IDLE_COLUMN = 3
 Index of the column with "idle time".


Detailed Description

Data read from /proc/stat for on CPU.

This stores all numbers for one processor that are in the /proc/stat file. Each cpu line looks like this:
cpu? USER NICE SYSTEM IDLE IOWAIT IRQ SOFTIRQ
where ? is index of the cpu (or space if line represents global stats) and all USER ... SOFTIRQ are times that given processor spent doing tasks associated with given column. Number of columns is different between different kernels, but first four field are supported always. All fields are in USER_HZ, which usually is 1/100th of a second (but may be different and I know of no sane way of determining that value). We are usually interested only in the fourth column which counts time spent in the idle thread, but we still need to consider other columns when calculating CPU usage.


Constructor & Destructor Documentation

lm::LoadMonitor::ProcessorStats::OneCpuStats::OneCpuStats ( void   )  [inline]

Empty default ctor.

lm::LoadMonitor::ProcessorStats::OneCpuStats::OneCpuStats ( const std::string &  line  ) 

Parse line from the file.

This will parse given string and extract all columns with numbers into the vector.

Parameters:
line One line from the /proc/stat file which contains data about the CPU.


Member Function Documentation

LoadMonitor::ProcessorStats::OneCpuStats lm::LoadMonitor::ProcessorStats::OneCpuStats::operator- ( const OneCpuStats b  )  const

Subtract corresponding values from two caches.

Subtracts two caches. Works like n-dimensional vector subtraction.

Parameters:
b Cache to subtract from this.
Returns:
Result of "vector" subtraction of the two cache items.

long long lm::LoadMonitor::ProcessorStats::OneCpuStats::Sum ( void   )  const

Sum values in this cache.

Sums all values stored in this cache.

Returns:
Sum of all items in this cache.


Field Documentation

const size_t lm::LoadMonitor::ProcessorStats::OneCpuStats::CPU_IDLE_COLUMN = 3 [static]

Index of the column with "idle time".

std::vector< long long > lm::LoadMonitor::ProcessorStats::OneCpuStats::stat_cache

Data from file.


The documentation for this class was generated from the following files:
Generated on Tue Dec 19 17:43:49 2006 for Load Monitor for Linux by  doxygen 1.4.7