CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
edm::service::ProcInfoFetcher Class Reference

#include <ProcInfoFetcher.h>

Public Member Functions

ProcInfo fetch () const
 
ProcInfoFetcheroperator= (ProcInfoFetcher const &)=delete
 
 ProcInfoFetcher ()
 
 ProcInfoFetcher (ProcInfoFetcher const &)=delete
 
 ~ProcInfoFetcher ()
 

Private Attributes

char buf_ [500]
 
int fd_
 
double pg_size_
 

Detailed Description

Definition at line 44 of file ProcInfoFetcher.h.

Constructor & Destructor Documentation

ProcInfoFetcher::ProcInfoFetcher ( )

Definition at line 179 of file ProcInfoFetcher.cc.

References edm::errors::Configuration, Exception, and fd_.

179  :
180  pg_size_(sysconf(_SC_PAGESIZE)) {
181 #ifdef __linux__
182  std::ostringstream ost;
183  ost << "/proc/" << getpid() << "/stat";
184 
185  if((fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
187  << "Failed to open " << ost.str() << std::endl;
188  }
189 #endif
190  }
ProcInfoFetcher::~ProcInfoFetcher ( )

Definition at line 191 of file ProcInfoFetcher.cc.

References fd_.

191  {
192 #ifdef LINUX
193  close(fd_);
194 #endif
195  }
edm::service::ProcInfoFetcher::ProcInfoFetcher ( ProcInfoFetcher const &  )
delete

Member Function Documentation

ProcInfo ProcInfoFetcher::fetch ( ) const

Definition at line 196 of file ProcInfoFetcher.cc.

References buf_, fd_, pg_size_, SiPixelLorentzAngle_cfi::read, runTheMatrix::ret, edm::service::ProcInfo::rss, and edm::service::ProcInfo::vsize.

Referenced by edm::service::ResourceEnforcer::check(), and edm::service::SimpleMemoryCheck::fetch().

196  {
197  ProcInfo ret;
198 
199 #ifdef __linux__
200  double pr_size = 0.0, pr_rssize = 0.0;
201 
202  linux_proc pinfo;
203  int cnt;
204 
205  lseek(fd_, 0, SEEK_SET);
206 
207  if((cnt = read(fd_, buf_, sizeof(buf_) - 1)) < 0) {
208  perror("Read of Proc file failed:");
209  return ProcInfo();
210  }
211 
212  if(cnt > 0) {
213  buf_[cnt] = '\0';
214 
215 
216  try {
217  Fetcher fetcher(buf_);
218  fetcher >> pinfo.pid
219  >> pinfo.comm
220  >> pinfo.state
221  >> pinfo.ppid
222  >> pinfo.pgrp
223  >> pinfo.session
224  >> pinfo.tty
225  >> pinfo.tpgid
226  >> pinfo.flags
227  >> pinfo.minflt
228  >> pinfo.cminflt
229  >> pinfo.majflt
230  >> pinfo.cmajflt
231  >> pinfo.utime
232  >> pinfo.stime
233  >> pinfo.cutime
234  >> pinfo.cstime
235  >> pinfo.priority
236  >> pinfo.nice
237  >> pinfo.num_threads
238  >> pinfo.itrealvalue
239  >> pinfo.starttime
240  >> pinfo.vsize
241  >> pinfo.rss
242  >> pinfo.rlim
243  >> pinfo.startcode
244  >> pinfo.endcode
245  >> pinfo.startstack
246  >> pinfo.kstkesp
247  >> pinfo.kstkeip
248  >> pinfo.signal
249  >> pinfo.blocked
250  >> pinfo.sigignore
251  >> pinfo.sigcatch
252  >> pinfo.wchan;
253  } catch (boost::bad_lexical_cast& iE) {
254  LogWarning("ProcInfoFetcher")<<"Parsing of Prof file failed:"<<iE.what()<<std::endl;
255  return ProcInfo();
256  }
257 
258  // resident set size in pages
259  pr_size = (double)pinfo.vsize;
260  pr_rssize = (double)pinfo.rss;
261 
262  ret.vsize = pr_size / (1024.0*1024.0);
263  ret.rss = (pr_rssize * pg_size_) / (1024.0*1024.0);
264  }
265 #else
266  ret.vsize = 0;
267  ret.rss = 0;
268 #endif
269  return ret;
270  }
tuple ret
prodAgent to be discontinued
ProcInfoFetcher& edm::service::ProcInfoFetcher::operator= ( ProcInfoFetcher const &  )
delete

Member Data Documentation

char edm::service::ProcInfoFetcher::buf_[500]
mutableprivate

Definition at line 55 of file ProcInfoFetcher.h.

Referenced by fetch().

int edm::service::ProcInfoFetcher::fd_
private

Definition at line 54 of file ProcInfoFetcher.h.

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

double edm::service::ProcInfoFetcher::pg_size_
private

Definition at line 53 of file ProcInfoFetcher.h.

Referenced by fetch().