| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ProcStats Class Reference

`#include <ProcStats.h>`

Collaboration diagram for ProcStats:
[legend]

## Classes
struct | cleanup

## 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

## Detailed Description

Definition at line 37 of file ProcStats.h.

## Constructor & Destructor Documentation

ProcStats::ProcStats | ( |  | ) |
| private

Definition at line 249 of file ProcStats.cpp.

:valid(false)
{
#ifdef __linux
pg_size = sysconf(_SC_PAGESIZE); // getpagesize();
std::ostringstream ost;
ost << "/proc/" << getpid() << "/stat";
fname = ost.str();
if((fd=open(fname.c_str(),O_RDONLY))<0)
{
cerr << "Failed to open " << ost.str() << endl;
return;
}
#endif
valid=true;
}

ProcStats::~ProcStats | ( |  | ) |
| private

Definition at line 266 of file ProcStats.cpp.

{
#ifdef __linux
close(fd);
#endif
}

## Member Function Documentation

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

Definition at line 273 of file ProcStats.cpp.

{
if( valid == false ) return false;
#ifdef __linux
double pr_size, pr_rssize;
linux_proc pinfo;
int cnt;
lseek(fd,0,SEEK_SET);
if((cnt=read(fd,buf,sizeof(buf)))<0)
{
cout << "LINUX Read of Proc file failed:" << endl;
return false;
}
if(cnt>0)
{
buf[cnt]='\0';
sscanf(buf,
//1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 20 1 2 3 4 5 6 7 8 9 30 1 2 3 4 5
"%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
&pinfo.pid,
pinfo.comm,
&pinfo.state,
&pinfo.ppid,
&pinfo.pgrp,
&pinfo.session,
&pinfo.tty,
&pinfo.tpgid,
&pinfo.flags,
&pinfo.minflt,
&pinfo.cminflt,
&pinfo.majflt,
&pinfo.cmajflt,
&pinfo.utime,
&pinfo.stime,
&pinfo.cutime,
&pinfo.cstime,
&pinfo.priority,
&pinfo.nice,
&pinfo.num_threads,
&pinfo.itrealvalue,
&pinfo.starttime,
&pinfo.vsize,
&pinfo.rss,
&pinfo.rlim,
&pinfo.startcode,
&pinfo.endcode,
&pinfo.startstack,
&pinfo.kstkesp,
&pinfo.kstkeip,
&pinfo.signal,
&pinfo.blocked,
&pinfo.sigignore,
&pinfo.sigcatch,
&pinfo.wchan
);
// resident set size in pages
pr_size = (double)pinfo.vsize;
pr_rssize = (double)pinfo.rss;
f.vsize = pr_size / (1024*1024);
f.rss = pr_rssize * pg_size / (1024*1024);
}
#else
f.vsize = 0;
f.rss = 0;
#endif
bool rc = (curr==f)?false:true;
curr.rss=f.rss;
curr.vsize=f.vsize;
return rc;
}

ProcStats * ProcStats::instance | ( |  | ) |
| static

Definition at line 240 of file ProcStats.cpp.

{
static cleanup c;
if(inst==0)
inst = new ProcStats;
return inst;
}

double ProcStats::pageSize | ( |  | ) | const
| inline

Definition at line 43 of file ProcStats.h.

{ return pg_size; }

## Friends And Related Function Documentation

friend struct cleanup
| friend

Definition at line 55 of file ProcStats.h.

## Member Data Documentation

char ProcStats::buf[500]
| private

Definition at line 61 of file ProcStats.h.

procInfo ProcStats::curr
| private

Definition at line 59 of file ProcStats.h.

int ProcStats::fd
| private

Definition at line 57 of file ProcStats.h.

std::string ProcStats::fname
| private

Definition at line 60 of file ProcStats.h.

ProcStats * ProcStats::inst = 0
| static private

Definition at line 64 of file ProcStats.h.

double ProcStats::pg_size
| private

Definition at line 58 of file ProcStats.h.

bool ProcStats::valid
| private

Definition at line 62 of file ProcStats.h.

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

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