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 174 of file ProcInfoFetcher.cc.

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

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

Definition at line 186 of file ProcInfoFetcher.cc.

References fd_.

186  {
187 #ifdef LINUX
188  close(fd_);
189 #endif
190  }
edm::service::ProcInfoFetcher::ProcInfoFetcher ( ProcInfoFetcher const &  )
delete

Member Function Documentation

ProcInfo ProcInfoFetcher::fetch ( ) const

Definition at line 191 of file ProcInfoFetcher.cc.

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

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

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