| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 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 37 of file ProcStats.h.

## Constructor & Destructor Documentation

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

Definition at line 83 of file ProcStats.cpp.

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

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

Definition at line 100 of file ProcStats.cpp.

    00101 {
    00102 #ifdef __linux
    00103   close(fd);
    00104 #endif
    00105 }

## Member Function Documentation

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

Definition at line 74 of file ProcStats.cpp.

    00074                                {
    00075   static cleanup c;
    00076   if(inst==0)
    00077     inst = new ProcStats;
    00078   return inst;
    00079 }

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

Definition at line 107 of file ProcStats.cpp.

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

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

Definition at line 43 of file ProcStats.h.

    00043 { return pg_size; }

## Friends And Related Function Documentation

friend struct cleanup`[friend]`

Definition at line 55 of file ProcStats.h.

## Member Data Documentation

int ProcStats::fd`[private]`

Definition at line 57 of file ProcStats.h.

double ProcStats::pg_size`[private]`

Definition at line 58 of file ProcStats.h.

procInfo ProcStats::curr`[private]`

Definition at line 59 of file ProcStats.h.

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

Definition at line 60 of file ProcStats.h.

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

Definition at line 61 of file ProcStats.h.

bool ProcStats::valid`[private]`

Definition at line 62 of file ProcStats.h.

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

Definition at line 64 of file ProcStats.h.

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

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