| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# ProcStats Class Reference

`#include <ProcStats.h>`

Collaboration diagram for ProcStats:

[legend]

List of all members.

## 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 = 0
## Friends
struct | cleanup
## Classes
struct | cleanup

## Detailed Description

Definition at line 25 of file ProcStats.h.

## Constructor & Destructor Documentation

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

Definition at line 78 of file ProcStats.cpp.

    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.

    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.

    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.

    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.

    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.

double ProcStats::pg_size`[private]`

Definition at line 46 of file ProcStats.h.

procInfo ProcStats::curr`[private]`

Definition at line 47 of file ProcStats.h.

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

Definition at line 48 of file ProcStats.h.

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

Definition at line 49 of file ProcStats.h.

bool ProcStats::valid`[private]`

Definition at line 50 of file ProcStats.h.

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

Definition at line 52 of file ProcStats.h.

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

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