| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# ProcStats Class Reference

`#include <ProcStats.h>`

Collaboration diagram for ProcStats:

[legend]
List of all members.

## Detailed Description

Definition at line 25 of file ProcStats.h.

## Public Member Functions
bool | fetch (procInfo &fill_me)
double | pageSize () const
## Static Public Member Functions
static ProcStats * | instance ()
## Private Member Functions
| ProcStats ()
| ~ProcStats ()
## Private Attributes
int | fd
double | pg_size
procInfo | curr
std::string | fname
char | buf [500]
bool | valid
## Static Private Attributes
static ProcStats * | inst
## Friends
struct | cleanup
## Classes
struct | cleanup

## Constructor & Destructor Documentation

ProcStats::ProcStats | ( |  | ) | `[private]`

Definition at line 78 of file ProcStats.cpp.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), cerr, endl(), fd, fname, pg_size, std::basic_ostringstream< _CharT, _Traits, _Alloc >::str(), and valid.

    00078                     :valid(false)
    00079 {
    00080 #ifdef __linux
    00081   pg_size = sysconf(_SC_PAGESIZE); // getpagesize();
    00082   std::ostringstream ost;
    00083
    00084   ost << "/proc/" << getpid() << "/stat";
    00085   fname = ost.str();
    00086   if((fd=open(fname.c_str(),O_RDONLY))<0)
    00087   {
    00088     cerr << "Failed to open " << ost.str() << endl;
    00089     return;
    00090   }
    00091 #endif
    00092   valid=true;
    00093 }

ProcStats::~ProcStats | ( |  | ) | `[private]`

Definition at line 95 of file ProcStats.cpp.

References fd.

    00096 {
    00097 #ifdef __linux
    00098   close(fd);
    00099 #endif
    00100 }

## Member Function Documentation

ProcStats * ProcStats::instance | ( |  | ) | `[static]`

Definition at line 69 of file ProcStats.cpp.

References c, and inst.

Referenced by MemStatAuditor::printinfo(), and MemoryAuditor::printinfo().

    00069                                {
    00070   static cleanup c;
    00071   if(inst==0)
    00072     inst = new ProcStats;
    00073   return inst;
    00074 }

bool ProcStats::fetch | ( | procInfo & | fill_me | ) |

Definition at line 102 of file ProcStats.cpp.

References linux_proc::blocked, buf, linux_proc::cmajflt, linux_proc::cminflt, linux_proc::comm, linux_proc::counter, cout, linux_proc::cstime, curr, linux_proc::cutime, linux_proc::endcode, endl(), fd, linux_proc::flags, linux_proc::itrealvalue, linux_proc::kstkeip, linux_proc::kstkesp, linux_proc::majflt, linux_proc::minflt, pg_size, linux_proc::pgrp, linux_proc::pid, linux_proc::ppid, linux_proc::priority, linux_proc::rlim, procInfo::rss, linux_proc::rss, linux_proc::session, linux_proc::sigcatch, linux_proc::sigignore, linux_proc::signal, linux_proc::startcode, linux_proc::startstack, linux_proc::starttime, linux_proc::state, linux_proc::stime, linux_proc::timeout, linux_proc::tpgid, linux_proc::tty, linux_proc::utime, valid, procInfo::vsize, linux_proc::vsize, and linux_proc::wchan.

Referenced by MemStatAuditor::printinfo(), and MemoryAuditor::printinfo().

    00103 {
    00104   if( valid == false ) return false;
    00105
    00106 #ifdef __linux
    00107   double pr_size, pr_rssize;
    00108   linux_proc pinfo;
    00109   int cnt;
    00110
    00111   lseek(fd,0,SEEK_SET);
    00112
    00113   if((cnt=read(fd,buf,sizeof(buf)))<0)
    00114   {
    00115     cout << "LINUX Read of Proc file failed:" << endl;
    00116     return false;
    00117   }
    00118
    00119   if(cnt>0)
    00120   {
    00121     buf[cnt]='\0';
    00122
    00123     sscanf(buf,
    00124       "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u",
    00125       &pinfo.pid, // %d
    00126       pinfo.comm, // %s
    00127       &pinfo.state, // %c
    00128       &pinfo.ppid, // %d
    00129       &pinfo.pgrp, // %d
    00130       &pinfo.session, // %d
    00131       &pinfo.tty, // %d
    00132       &pinfo.tpgid, // %d
    00133       &pinfo.flags, // %u
    00134       &pinfo.minflt, // %u
    00135       &pinfo.cminflt, // %u
    00136       &pinfo.majflt, // %u
    00137       &pinfo.cmajflt, // %u
    00138       &pinfo.utime, // %d
    00139       &pinfo.stime, // %d
    00140       &pinfo.cutime, // %d
    00141       &pinfo.cstime, // %d
    00142       &pinfo.counter, // %d
    00143       &pinfo.priority, // %d
    00144       &pinfo.timeout, // %u
    00145       &pinfo.itrealvalue, // %u
    00146       &pinfo.starttime, // %d
    00147       &pinfo.vsize, // %u
    00148       &pinfo.rss, // %u
    00149       &pinfo.rlim, // %u
    00150       &pinfo.startcode, // %u
    00151       &pinfo.endcode, // %u
    00152       &pinfo.startstack, // %u
    00153       &pinfo.kstkesp, // %u
    00154       &pinfo.kstkeip, // %u
    00155       &pinfo.signal, // %d
    00156       &pinfo.blocked, // %d
    00157       &pinfo.sigignore, // %d
    00158       &pinfo.sigcatch, // %d
    00159       &pinfo.wchan // %u
    00160       );
    00161
    00162       // resident set size in pages
    00163     pr_size = (double)pinfo.vsize;
    00164     pr_rssize = (double)pinfo.rss;
    00165
    00166     f.vsize = pr_size   / (1024*1024);
    00167     f.rss   = pr_rssize * pg_size / (1024*1024);
    00168   }
    00169
    00170 #else
    00171   f.vsize = 0;
    00172   f.rss   = 0;
    00173 #endif
    00174
    00175   bool rc = (curr==f)?false:true;
    00176
    00177   curr.rss=f.rss;
    00178   curr.vsize=f.vsize;
    00179
    00180   return rc;
    00181 }

double ProcStats::pageSize | ( |  | ) | const`[inline]`

Definition at line 31 of file ProcStats.h.

References pg_size.

    00031 { return pg_size; }

## Friends And Related Function Documentation

friend struct cleanup`[friend]`

Definition at line 43 of file ProcStats.h.

## Member Data Documentation

int ProcStats::fd`[private]`

Definition at line 45 of file ProcStats.h.

Referenced by fetch(), ProcStats(), and ~ProcStats().

double ProcStats::pg_size`[private]`

Definition at line 46 of file ProcStats.h.

Referenced by fetch(), pageSize(), and ProcStats().

procInfo ProcStats::curr`[private]`

Definition at line 47 of file ProcStats.h.

Referenced by fetch().

std::string ProcStats::fname`[private]`

Definition at line 48 of file ProcStats.h.

Referenced by ProcStats().

char ProcStats::buf[500]`[private]`

Definition at line 49 of file ProcStats.h.

Referenced by fetch().

bool ProcStats::valid`[private]`

Definition at line 50 of file ProcStats.h.

Referenced by fetch(), and ProcStats().

ProcStats * ProcStats::inst`[static, private]`

Definition at line 52 of file ProcStats.h.

Referenced by instance(), and ProcStats::cleanup::~cleanup().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiAud/v8r6/src/ProcStats.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiAud/v8r6/src/ProcStats.cpp