NLMISC::CCPUTimeStat Class Reference

Utility class to read cpu time information from /proc/stat and /cpu/pid/stat Allows accurate timing measures for both cpu and process (at least at OS timing accuracy) Call peekMeasures() once in a while (once a second, for instance, to avoid to much load) then call each getCPU. More...

#include <cpu_time_stat.h>

List of all members.

Classes

struct  CTickStat

Public Member Functions

 CCPUTimeStat ()
Detailed measures

These methods allow you to check precisely what consumes cpu power, (user processes/kernel/nice processes.

..)



float getCPUUserLoad (TMeasureType type=Instant) const
 Get User Load.
float getCPUSystemLoad (TMeasureType type=Instant) const
 Get System Load.
float getCPUNiceLoad (TMeasureType type=Instant) const
 Get Nice Load.
float getCPUIOWaitLoad (TMeasureType type=Instant) const
 Get Nice Load.
float getProcessUserLoad (TMeasureType type=Instant) const
 Get User load for this process (children excluded).
float getProcessSystemLoad (TMeasureType type=Instant) const
 Get Sytem load for this process (children excluded).
float getProcessCUserLoad (TMeasureType type=Instant) const
 Get User load for this process (children included).
float getProcessCSystemLoad (TMeasureType type=Instant) const
 Get Sytem load for this process (children included).
float getProcessCLoad (TMeasureType type=Instant) const
 Get overall load for this process (children included).

Static Public Member Functions

static bool getCPUTicks (uint64 &user, uint64 &nice, uint64 &system, uint64 &idle, uint64 &iowait)
 Get absolute ticks value for the whole cpu set e.g.
static bool getPIDTicks (uint64 &utime, uint64 &stime, uint64 &cutime, uint64 &cstime, uint pid)
 Get absolute ticks values for a specific pid.

Private Attributes

uint32 _PID
bool _FirstTime
uint64 _LastCPUTicks
CTickStat _CPUUser
CTickStat _CPUNice
CTickStat _CPUSystem
CTickStat _CPUIdle
CTickStat _CPUIOWait
uint64 _LastPIDTicks
CTickStat _PIDUTime
CTickStat _PIDSTime
CTickStat _PIDCUTime
CTickStat _PIDCSTime

Measure peeking and reading



enum  TMeasureType { Instant, Mean, Peak }
void peekMeasures ()
 Peek measure.
float getCPULoad (TMeasureType type=Instant) const
 Get Overall CPU Load Call this method to know the overall server CPU usage (0=min, 1=max) All processes running on the same machine will return approximately the same value.
float getProcessLoad (TMeasureType type=Instant) const
 Get overall load for this process (children excluded) Call this method to know the CPU usage for this process (0=min, 1=max) Please note that quadriprocessor machines will show maximum of 0.25 per process (0.5 for a biprocessor).

Detailed Description

Utility class to read cpu time information from /proc/stat and /cpu/pid/stat Allows accurate timing measures for both cpu and process (at least at OS timing accuracy) Call peekMeasures() once in a while (once a second, for instance, to avoid to much load) then call each getCPU.

.. and getProcess... methods to get instant CPU or Process load.

Author:
Benjamin Legros
Nevrax France
Date:
2004

Definition at line 45 of file cpu_time_stat.h.


Member Enumeration Documentation

Enumerator:
Instant 
Mean 
Peak 

Definition at line 68 of file cpu_time_stat.h.


Constructor & Destructor Documentation

NLMISC::CCPUTimeStat::CCPUTimeStat (  ) 

Definition at line 101 of file cpu_time_stat.cpp.

References _PID.


Member Function Documentation

float NLMISC::CCPUTimeStat::getCPUIOWaitLoad ( TMeasureType  type = Instant  )  const [inline]

Get Nice Load.

Definition at line 111 of file cpu_time_stat.h.

References _CPUIOWait, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

float NLMISC::CCPUTimeStat::getCPULoad ( TMeasureType  type = Instant  )  const [inline]

Get Overall CPU Load Call this method to know the overall server CPU usage (0=min, 1=max) All processes running on the same machine will return approximately the same value.

Definition at line 81 of file cpu_time_stat.h.

References _CPUIOWait, _CPUNice, _CPUSystem, _CPUUser, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

float NLMISC::CCPUTimeStat::getCPUNiceLoad ( TMeasureType  type = Instant  )  const [inline]

Get Nice Load.

Definition at line 109 of file cpu_time_stat.h.

References _CPUNice, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

float NLMISC::CCPUTimeStat::getCPUSystemLoad ( TMeasureType  type = Instant  )  const [inline]

Get System Load.

Definition at line 107 of file cpu_time_stat.h.

References _CPUSystem, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

bool NLMISC::CCPUTimeStat::getCPUTicks ( uint64 user,
uint64 nice,
uint64 system,
uint64 idle,
uint64 iowait 
) [static]

Get absolute ticks value for the whole cpu set e.g.

a foursome of cpu will all tell their ticks through these numbers

Definition at line 49 of file cpu_time_stat.cpp.

References NL_I64.

Referenced by peekMeasures().

float NLMISC::CCPUTimeStat::getCPUUserLoad ( TMeasureType  type = Instant  )  const [inline]

Get User Load.

Definition at line 105 of file cpu_time_stat.h.

References _CPUUser, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

bool NLMISC::CCPUTimeStat::getPIDTicks ( uint64 utime,
uint64 stime,
uint64 cutime,
uint64 cstime,
uint  pid 
) [static]

Get absolute ticks values for a specific pid.

Definition at line 74 of file cpu_time_stat.cpp.

References NL_I64, nlunreferenced, and NLMISC::toString().

Referenced by peekMeasures().

float NLMISC::CCPUTimeStat::getProcessCLoad ( TMeasureType  type = Instant  )  const [inline]

Get overall load for this process (children included).

Definition at line 122 of file cpu_time_stat.h.

References _PIDCSTime, _PIDCUTime, and NLMISC::CCPUTimeStat::CTickStat::get().

float NLMISC::CCPUTimeStat::getProcessCSystemLoad ( TMeasureType  type = Instant  )  const [inline]

Get Sytem load for this process (children included).

Definition at line 120 of file cpu_time_stat.h.

References _PIDCSTime, and NLMISC::CCPUTimeStat::CTickStat::get().

float NLMISC::CCPUTimeStat::getProcessCUserLoad ( TMeasureType  type = Instant  )  const [inline]

Get User load for this process (children included).

Definition at line 118 of file cpu_time_stat.h.

References _PIDCUTime, and NLMISC::CCPUTimeStat::CTickStat::get().

float NLMISC::CCPUTimeStat::getProcessLoad ( TMeasureType  type = Instant  )  const [inline]

Get overall load for this process (children excluded) Call this method to know the CPU usage for this process (0=min, 1=max) Please note that quadriprocessor machines will show maximum of 0.25 per process (0.5 for a biprocessor).

Children of a process are processes that have been launched from this process (that is, this process is marked as parent of the child process, see ppid, fork() and/or exec()) Unused but by the AES (all launched services are children of the AES)

Definition at line 92 of file cpu_time_stat.h.

References _PIDSTime, _PIDUTime, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

float NLMISC::CCPUTimeStat::getProcessSystemLoad ( TMeasureType  type = Instant  )  const [inline]

Get Sytem load for this process (children excluded).

Definition at line 116 of file cpu_time_stat.h.

References _PIDSTime, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

float NLMISC::CCPUTimeStat::getProcessUserLoad ( TMeasureType  type = Instant  )  const [inline]

Get User load for this process (children excluded).

Definition at line 114 of file cpu_time_stat.h.

References _PIDUTime, and NLMISC::CCPUTimeStat::CTickStat::get().

Referenced by NLNET::NLMISC_CATEGORISED_DYNVARIABLE().

void NLMISC::CCPUTimeStat::peekMeasures (  ) 

Member Data Documentation

Definition at line 195 of file cpu_time_stat.h.

Referenced by peekMeasures().

Definition at line 196 of file cpu_time_stat.h.

Referenced by getCPUIOWaitLoad(), getCPULoad(), and peekMeasures().

Definition at line 193 of file cpu_time_stat.h.

Referenced by getCPULoad(), getCPUNiceLoad(), and peekMeasures().

Definition at line 194 of file cpu_time_stat.h.

Referenced by getCPULoad(), getCPUSystemLoad(), and peekMeasures().

Definition at line 192 of file cpu_time_stat.h.

Referenced by getCPULoad(), getCPUUserLoad(), and peekMeasures().

Definition at line 189 of file cpu_time_stat.h.

Referenced by peekMeasures().

Definition at line 191 of file cpu_time_stat.h.

Referenced by peekMeasures().

Definition at line 198 of file cpu_time_stat.h.

Referenced by peekMeasures().

Definition at line 188 of file cpu_time_stat.h.

Referenced by CCPUTimeStat(), and peekMeasures().

Definition at line 202 of file cpu_time_stat.h.

Referenced by getProcessCLoad(), getProcessCSystemLoad(), and peekMeasures().

Definition at line 201 of file cpu_time_stat.h.

Referenced by getProcessCLoad(), getProcessCUserLoad(), and peekMeasures().

Definition at line 200 of file cpu_time_stat.h.

Referenced by getProcessLoad(), getProcessSystemLoad(), and peekMeasures().

Definition at line 199 of file cpu_time_stat.h.

Referenced by getProcessLoad(), getProcessUserLoad(), and peekMeasures().


The documentation for this class was generated from the following files:

Generated on Thu Jan 7 08:30:17 2010 for NeL by  doxygen 1.6.1